Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ipfs tools #90

Merged
merged 7 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"prettier-plugin-solidity": "^1.1.3"
},
"dependencies": {
"@bgd-labs/report-engine": "^0.0.11"
"@bgd-labs/aave-cli": "^0.0.8"
}
}
9 changes: 5 additions & 4 deletions src/CommonTestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ contract CommonTestBase is Test {
string memory beforePath = string(abi.encodePacked('./reports/', reportBefore, '.json'));
string memory afterPath = string(abi.encodePacked('./reports/', reportAfter, '.json'));

string[] memory inputs = new string[](6);
string[] memory inputs = new string[](7);
inputs[0] = 'npx';
inputs[1] = '@bgd-labs/report-engine';
inputs[2] = 'diff';
inputs[1] = 'aave-cli';
inputs[2] = 'diff-snapshot';
inputs[3] = beforePath;
inputs[4] = afterPath;
inputs[5] = outPath;
inputs[5] = '-o';
inputs[6] = outPath;
vm.ffi(inputs);
}

Expand Down
16 changes: 16 additions & 0 deletions src/GovHelpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ library GovHelpers {
bytes callData;
}

function ipfsHashFile(Vm vm, string memory filePath, bool upload) internal returns (bytes32) {
string[] memory inputs = new string[](6);
inputs[0] = 'npx';
inputs[1] = 'aave-cli';
inputs[2] = 'ipfs';
inputs[3] = filePath;
inputs[4] = '-u';
inputs[5] = vm.toString(upload);
bytes memory bs58Hash = vm.ffi(inputs);
return bytes32(bs58Hash);
}

function ipfsHashFile(Vm vm, string memory filePath) internal returns (bytes32) {
return ipfsHashFile(vm, filePath, false);
}

function buildMainnet(address payloadAddress) internal pure returns (Payload memory) {
require(
payloadAddress != AaveGovernanceV2.CROSSCHAIN_FORWARDER_OPTIMISM &&
Expand Down
21 changes: 21 additions & 0 deletions src/test/GovTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ contract GovernanceTest is Test {
GovHelpers.createProposal(payloads, bytes32('ipfs'));
vm.stopPrank();
}

function testCreateProposalDynamicIpfsHash() public {
GovHelpers.Payload[] memory payloads = new GovHelpers.Payload[](2);
payloads[0] = GovHelpers.buildMainnet(address(1));
payloads[1] = GovHelpers.buildPolygon(address(2));

vm.startPrank(AaveMisc.ECOSYSTEM_RESERVE);
GovHelpers.createProposal(payloads, GovHelpers.ipfsHashFile(vm, 'src/test/mocks/proposal.md'));
vm.stopPrank();
}
}

contract GovernanceL2ExecutorTest is Test {
Expand Down Expand Up @@ -52,3 +62,14 @@ contract GovernanceMainnetExecutorTest is Test {
GovHelpers.executePayload(vm, address(payload), AaveGovernanceV2.SHORT_EXECUTOR);
}
}

contract GovernanceIpfsTest is Test {
function testIpfsHashCreation() public {
bytes32 bs58Hash = GovHelpers.ipfsHashFile(vm, 'src/test/mocks/proposal.md');
assertEq(
bs58Hash,
0x12f2d9c91e4e23ae4009ab9ef5862ee0ae79498937b66252213221f04a5d5b32,
'HASH_MUST_MATCH'
);
}
}
4 changes: 4 additions & 0 deletions src/test/mocks/proposal-invalid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: TestTitle
discussions: TestDiscussion
---
74 changes: 74 additions & 0 deletions src/test/mocks/proposal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
title: Add 1INCH to Aave v2 market
status: Proposed
author: Governance House - [Llama](https://twitter.com/llama), [Matthew Graham](https://twitter.com/Matthew_Graham_), [defijesus.eth](https://twitter.com/eldefijesus)
shortDescription: Add 1INCH as collateral on the Aave V2 market
discussions: https://governance.aave.com/t/arc-add-1inch-as-collateral/8056
created: 2022-07-18
---


## Simple Summary

Llama proposes listing 1INCH, the governance token of the 1inch Network, on Aave v2 mainnet as collateral with borrowing enabled. The risk parameters detailed within have been provided by Gauntlet.

## Abstract

1inch is a network of decentralized protocols designed to provide the fastest and most efficient operations in the DeFi space. The 1inch Network was launched in May 2019 with the release of its Aggregation Protocol v1. The 1inch Aggregation Protocol is both the oldest and most trusted DEX aggregator in the DeFi space.

Listing 1INCH on Aave v2 will enable lenders to receive yield and borrowers of 1INCH to partake in 1inch’s tokenomics to vote and be reimbursed their gas cost to perform swaps on 1inch’s Aggregation Platform.

## Motivation

Listing 1INCH on the Aave v2 market would allow Aave to benefit from the first mover advantage and recognise the efforts of the 1inch team for being supportive of Aave since before v1.

Since the original proposal to list 1INCH the team has removed minting roles on the token, introduced a progressive vesting schedule and created use cases for aTokens. The 1INCH token is supported by a Chainlink oracle feed and has favourable on-chain liquidity conditions.

## Specification

This proposal initializes the 1INCH reserve, enables variable borrowing, sets a reserve factor and configures the reserve as collateral. As needed, it also connects a price source on the AaveOracle.

## Test Cases

All the components involved in this proposal (tokens' implementations, interest rate strategy, oracle feed, proposal payload) have been tested and reviewed, including simulations on mainnet of the whole proposal lifecycle.

Link to Test Cases: [End-to-end test suite](https://github.com/defijesus/bdg-labs-aave-v2-listings/blob/master/src/test/Validation1InchListing.sol), [aToken/stableDebtToken/variableDebtToken verification](https://github.com/defijesus/bdg-labs-aave-v2-listings/tree/master/diffs), [deployment script](https://github.com/defijesus/bdg-labs-aave-v2-listings/blob/master/scripts/1InchListingPayload.s.sol)

## Implementation

We recommend the following risk parameters.

### Risk Parameters:

LTV 40%

Liquidation Threshold 50%

Liquidation Bonus 8.5%

Reserve Factor 20%

### Variable Interest Rate Parameters:

UOptimal 45%

R_0 0%

R_s1 7%

R_s2 300%


The snapshot vote to add 1INCH on Aave v2 mainnet market can be found [here](https://snapshot.org/#/aave.eth/proposal/0x2ea76814a0dfcad7ea1a7b3c597f059a8d574f8143886b23043918998505f5a7).


- [ProposalPayload](https://etherscan.io/address/0xd417d07c20e31f6e129fa68182054b641fbec8bd#code)
- [aINCH implementation](https://etherscan.io/address/0x130FBED7dBA2b370f0F93b0Caea2cfD9b811D66D#code)
- [Variable Debt 1INCH implementation](https://etherscan.io/address/0x4d3707566Ee8a0ed6DE424a262050C7587da8152#code)
- [Stable Debt 1INCH implementation](https://etherscan.io/address/0x9C2114Bf70774C36E9b8d6c790c9C14FF0d6799E#code)
- [Interest rate strategy](https://etherscan.io/address/0xb2eD1eCE1c13455Ce9299d35D3B00358529f3Dc8#code)
- [1INCH/ETH price feed](https://etherscan.io/address/0x72AFAECF99C9d9C8215fF44C77B94B99C28741e8#code)

## Copyright

Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
Loading