Skip to content

Commit

Permalink
Merge branch 'bgd-labs:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Zeller authored Sep 22, 2023
2 parents 1e272c6 + fe8b736 commit 59f506e
Show file tree
Hide file tree
Showing 22 changed files with 720 additions and 6 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/ipfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ jobs:
run: |
cat .github/outputs/all_changed_files.json
- name: replace main with hash
if: github.event_name != 'pull_request' && steps.changed-files.outputs.any_changed == 'true'
run: |
json_array=($(jq -r '.[]' ".github/outputs/all_changed_files.json"))
for i in "${json_array[@]}"
do
sed -i 's@https://github.com/bgd-labs/aave-proposals/blob/main/@https://github.com/bgd-labs/aave-proposals/blob/${{ github.sha }}/@g' $i
done
- name: Upload
if: steps.changed-files.outputs.any_changed == 'true'
env:
Expand All @@ -55,3 +64,12 @@ jobs:
do
npx aave-cli ipfs $i -u ${{ github.event_name != 'pull_request'}}
done
- name: Create Pull Request
uses: peter-evans/create-pull-request@712add83f26c1e359c046a6ca3dd677fb7017626
if: github.event_name != 'pull_request' && steps.changed-files.outputs.any_changed == 'true'
with:
committer: Ipfs-bot <[email protected]>
commit-message: "chore(ipfs): automated branch/hash replacement [skip ci]"
title: "chore(ipfs): automated branch/hash replacement"
base: "main"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ broadcast
reports/*
src/etherscan
!reports/.empty

# ci artifacts
.github/outputs/
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Reserve changes

### Reserves altered

#### CRV ([0xD533a949740bb3306d119CC777fa900bA034cd52](https://etherscan.io/address/0xD533a949740bb3306d119CC777fa900bA034cd52))

| description | value before | value after |
| --- | --- | --- |
| liquidationThreshold | 47 % | 45 % |


## Raw diff

```json
{
"reserves": {
"0xD533a949740bb3306d119CC777fa900bA034cd52": {
"liquidationThreshold": {
"from": 4700,
"to": 4500
}
}
}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## Reserve changes

### Reserve altered

#### sAVAX ([0x2b2C81e08f1Af8835a78Bb2A90AE924ACE0eA4bE](https://snowtrace.io/address/0x2b2C81e08f1Af8835a78Bb2A90AE924ACE0eA4bE))

| description | value before | value after |
| --- | --- | --- |
| ltv | 20 % | 30 % |
| liquidationThreshold | 30 % | 40 % |


#### LINK.e ([0x5947BB275c521040051D82396192181b413227A3](https://snowtrace.io/address/0x5947BB275c521040051D82396192181b413227A3))

| description | value before | value after |
| --- | --- | --- |
| ltv | 53 % | 56 % |
| liquidationThreshold | 68 % | 71 % |


#### WAVAX ([0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7](https://snowtrace.io/address/0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7))

| description | value before | value after |
| --- | --- | --- |
| liquidationBonus | 10 % | 9 % |


## Raw diff

```json
{
"reserves": {
"0x2b2C81e08f1Af8835a78Bb2A90AE924ACE0eA4bE": {
"liquidationThreshold": {
"from": 3000,
"to": 4000
},
"ltv": {
"from": 2000,
"to": 3000
}
},
"0x5947BB275c521040051D82396192181b413227A3": {
"liquidationThreshold": {
"from": 6800,
"to": 7100
},
"ltv": {
"from": 5300,
"to": 5600
}
},
"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7": {
"liquidationBonus": {
"from": 11000,
"to": 10900
}
}
}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Raw diff

```json
{}
```
1 change: 1 addition & 0 deletions generator/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export function getAlias(chain) {

export function pascalCase(str) {
return str
.replace(/[\W]/g, ' ')
.replace(/(\w)(\w*)/g, function (g0, g1, g2) {
return g1.toUpperCase() + g2;
})
Expand Down
8 changes: 4 additions & 4 deletions generator/features/collateralUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,26 @@ export const collateralUpdates: FeatureModule<CollateralUpdates> = {
code: {
dependencies: [DEPENDENCIES.Assets, DEPENDENCIES.Engine],
fn: [
`function capsUpdates() public pure override returns (IEngine.CapsUpdate[] memory) {
`function collateralsUpdates() public pure override returns (IEngine.CollateralUpdate[] memory) {
IEngine.CollateralUpdate[] memory collateralUpdate = new IEngine.CollateralUpdate[](${
cfg[chain].length
});
${cfg[chain]
.map(
(cfg, ix) => `capsUpdate[${ix}] = IEngine.CapsUpdate({
(cfg, ix) => `collateralUpdate[${ix}] = IEngine.CollateralUpdate({
asset: Aave${opt.protocolVersion}${chain}Assets.${cfg.asset}_UNDERLYING,
ltv: ${jsPercentToSol(cfg.ltv)},
liqThreshold: ${jsPercentToSol(cfg.liqThreshold)},
liqBonus: ${jsPercentToSol(cfg.liqBonus)},
debtCeiling: ${jsNumberToSol(cfg.debtCeiling)},
liqProtocolFee: ${jsPercentToSol(cfg.liqProtocolFee)},
eModeCategory: ${cfg.eModeCategory}
eModeCategory: ${(cfg.eModeCategory === ENGINE_FLAGS.KEEP_CURRENT) ? `EngineFlags.KEEP_CURRENT` : cfg.eModeCategory}
});`
)
.join('\n')}
return capsUpdate;
return collateralUpdate;
}`,
],
},
Expand Down
2 changes: 0 additions & 2 deletions generator/templates/proposal.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const proposalTemplate = (options: Options, chain, artifacts: CodeArtifac
const {protocolVersion, title, author, snapshot, discussion, features} = options;
const contractName = generateContractName(options, chain);

console.log(artifacts.map((a) => a[chain].code));
const dependencies = [
...new Set(
artifacts
Expand All @@ -36,7 +35,6 @@ export const proposalTemplate = (options: Options, chain, artifacts: CodeArtifac
.filter((f) => f !== undefined)
),
];
console.log(dependencies);
const imports = buildImport(options, chain, dependencies as DEPENDENCIES[]);
const constants = artifacts
.map((artifact) => artifact[chain].code?.constants)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3PayloadAvalanche, IEngine, EngineFlags} from 'aave-helpers/v3-config-engine/AaveV3PayloadAvalanche.sol';
import {AaveV3AvalancheAssets} from 'aave-address-book/AaveV3Avalanche.sol';

/**
* @title Chaos Labs Risk Parameter Updates Aave V3 Avalanche
* @author Chaos Labs
* - Snapshot: https://snapshot.org/#/aave.eth/proposal/0x0c7fc4246c5795a9d9901c08a9a8279e7e6ed1069f2155fe48239c92e4e43193
* - Discussion: https://governance.aave.com/t/arfc-chaos-labs-risk-parameter-updates-aave-v3-avalanche-2023-09-06/14774/1
*/
contract AaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918 is
AaveV3PayloadAvalanche
{
function collateralsUpdates() public pure override returns (IEngine.CollateralUpdate[] memory) {
IEngine.CollateralUpdate[] memory collateralUpdate = new IEngine.CollateralUpdate[](3);

collateralUpdate[0] = IEngine.CollateralUpdate({
asset: AaveV3AvalancheAssets.WAVAX_UNDERLYING,
ltv: EngineFlags.KEEP_CURRENT,
liqThreshold: EngineFlags.KEEP_CURRENT,
liqBonus: 9_00,
debtCeiling: EngineFlags.KEEP_CURRENT,
liqProtocolFee: EngineFlags.KEEP_CURRENT,
eModeCategory: EngineFlags.KEEP_CURRENT
});
collateralUpdate[1] = IEngine.CollateralUpdate({
asset: AaveV3AvalancheAssets.sAVAX_UNDERLYING,
ltv: 30_00,
liqThreshold: 40_00,
liqBonus: EngineFlags.KEEP_CURRENT,
debtCeiling: EngineFlags.KEEP_CURRENT,
liqProtocolFee: EngineFlags.KEEP_CURRENT,
eModeCategory: EngineFlags.KEEP_CURRENT
});
collateralUpdate[2] = IEngine.CollateralUpdate({
asset: AaveV3AvalancheAssets.LINKe_UNDERLYING,
ltv: 56_00,
liqThreshold: 71_00,
liqBonus: EngineFlags.KEEP_CURRENT,
debtCeiling: EngineFlags.KEEP_CURRENT,
liqProtocolFee: EngineFlags.KEEP_CURRENT,
eModeCategory: EngineFlags.KEEP_CURRENT
});

return collateralUpdate;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import 'forge-std/Test.sol';
import {GovHelpers} from 'aave-helpers/GovHelpers.sol';
import {AaveV3Avalanche, AaveV3AvalancheAssets} from 'aave-address-book/AaveV3Avalanche.sol';
import {ProtocolV3TestBase, ReserveConfig} from 'aave-helpers/ProtocolV3TestBase.sol';
import {AaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918} from './AaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918.sol';

/**
* @dev Test for AaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918
* command: make test-contract filter=AaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918
*/
contract AaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918_Test is
ProtocolV3TestBase
{
AaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918 internal proposal;

uint256 public constant WAVAX_LIQUIDATION_BONUS = 109_00; // 10% => 9%
uint256 public constant SAVAX_LIQUIDATION_THRESHOLD = 40_00; // 30% => 40%
uint256 public constant SAVAX_LOAN_TO_VALUE = 30_00; // 20% => 30%
uint256 public constant LINK_E_LIQUIDATION_THRESHOLD = 71_00; // 68% => 71%
uint256 public constant LINK_E_LOAN_TO_VALUE = 56_00; // 53% => 56%

function setUp() public {
vm.createSelectFork(vm.rpcUrl('avalanche'), 35348781);
proposal = new AaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918();
}

function testProposalExecution() public {
// 1. create snapshot before payload execution
ReserveConfig[] memory allConfigsBefore = createConfigurationSnapshot(
'preAaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918',
AaveV3Avalanche.POOL
);

// 2. execute payload
GovHelpers.executePayload(
vm,
address(proposal),
0xa35b76E4935449E33C56aB24b23fcd3246f13470 // avalanche guardian
);

// 3. create snapshot after payload execution
ReserveConfig[] memory allConfigsAfter = createConfigurationSnapshot(
'postAaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918',
AaveV3Avalanche.POOL
);

// 4. Verify payloads
// WAVAX
ReserveConfig memory WAVAX_UNDERLYING_CONFIG = _findReserveConfig(
allConfigsBefore,
AaveV3AvalancheAssets.WAVAX_UNDERLYING
);
WAVAX_UNDERLYING_CONFIG.liquidationBonus = WAVAX_LIQUIDATION_BONUS;
_validateReserveConfig(WAVAX_UNDERLYING_CONFIG, allConfigsAfter);

// sAVAX
ReserveConfig memory SAVAX_UNDERLYING_CONFIG = _findReserveConfig(
allConfigsBefore,
AaveV3AvalancheAssets.sAVAX_UNDERLYING
);
SAVAX_UNDERLYING_CONFIG.liquidationThreshold = SAVAX_LIQUIDATION_THRESHOLD;
SAVAX_UNDERLYING_CONFIG.ltv = SAVAX_LOAN_TO_VALUE;
_validateReserveConfig(SAVAX_UNDERLYING_CONFIG, allConfigsAfter);

// LINKe
ReserveConfig memory LINK_E_UNDERLYING_CONFIG = _findReserveConfig(
allConfigsBefore,
AaveV3AvalancheAssets.LINKe_UNDERLYING
);
LINK_E_UNDERLYING_CONFIG.liquidationThreshold = LINK_E_LIQUIDATION_THRESHOLD;
LINK_E_UNDERLYING_CONFIG.ltv = LINK_E_LOAN_TO_VALUE;
_validateReserveConfig(LINK_E_UNDERLYING_CONFIG, allConfigsAfter);

// 5. compare snapshots
diffReports(
'preAaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918',
'postAaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918'
);

// 6. E2E test
e2eTest(AaveV3Avalanche.POOL);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {GovHelpers} from 'aave-helpers/GovHelpers.sol';
import {EthereumScript, AvalancheScript} from 'aave-helpers/ScriptUtils.sol';
import {AaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918} from './AaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918.sol';

/**
* @dev Deploy AaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918
* command: make deploy-ledger contract=src/20230918_AaveV3_Ava_ChaosLabsRiskParameterUpdatesAaveV3Avalanche/AaveV3_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918.s.sol:DeployAvalanche chain=avalanche
*/
contract DeployAvalanche is AvalancheScript {
function run() external broadcast {
new AaveV3_Avalanche_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918();
}
}

/**
* @dev Create Proposal
* command: make deploy-ledger contract=src/20230918_AaveV3_Ava_ChaosLabsRiskParameterUpdatesAaveV3Avalanche/AaveV3_ChaosLabsRiskParameterUpdatesAaveV3Avalanche_20230918.s.sol:CreateProposal chain=mainnet
*/
contract CreateProposal is EthereumScript {
function run() external broadcast {
GovHelpers.Payload[] memory payloads = new GovHelpers.Payload[](0);

GovHelpers.createProposal(
payloads,
GovHelpers.ipfsHashFile(
vm,
'src/20230918_AaveV3_Ava_ChaosLabsRiskParameterUpdatesAaveV3Avalanche/ChaosLabsRiskParameterUpdatesAaveV3Avalanche.md'
)
);
}
}
Loading

0 comments on commit 59f506e

Please sign in to comment.