From 986d151132d0073f1e1d74332309908e9f1c7f8b Mon Sep 17 00:00:00 2001 From: Ian Flexa <85500650+ianflexa@users.noreply.github.com> Date: Wed, 27 Nov 2024 08:51:49 -0400 Subject: [PATCH] feat: AUSD capo (#55) * feat: AUSD capo * Update scripts/DeployAvalanche.s.sol Co-authored-by: Pavel <56404416+pavelvm5@users.noreply.github.com> --------- Co-authored-by: Pavel <56404416+pavelvm5@users.noreply.github.com> --- Makefile | 2 ++ scripts/DeployAvalanche.s.sol | 35 +++++++++++++++++++ tests/avalanche/AUSDPriceCapAdapterTest.t.sol | 16 +++++++++ 3 files changed, 53 insertions(+) create mode 100644 scripts/DeployAvalanche.s.sol create mode 100644 tests/avalanche/AUSDPriceCapAdapterTest.t.sol diff --git a/Makefile b/Makefile index 7779751..bf3bb30 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,8 @@ deploy-sdai-gnosis :; forge script scripts/DeployGnosis.s.sol:DeploySDaiGnosis - deploy-rseth-mainnet :; forge script scripts/DeployEthereum.s.sol:DeployRsEthEthereum --rpc-url mainnet $(common-flags) +deploy-ausd-avalanche :; forge script scripts/DeployAvalanche.s.sol:DeployAUSDAvalanche --rpc-url avalanche $(common-flags) + # Utilities download :; cast etherscan-source --chain ${chain} -d src/etherscan/${chain}_${address} ${address} git-diff : diff --git a/scripts/DeployAvalanche.s.sol b/scripts/DeployAvalanche.s.sol new file mode 100644 index 0000000..1962d4d --- /dev/null +++ b/scripts/DeployAvalanche.s.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol'; +import {AvalancheScript} from 'solidity-utils/contracts/utils/ScriptUtils.sol'; +import {AaveV3Avalanche} from 'aave-address-book/AaveV3Avalanche.sol'; + +import {PriceCapAdapterStable} from '../src/contracts/PriceCapAdapterStable.sol'; +import {IChainlinkAggregator} from '../src/interfaces/IPriceCapAdapter.sol'; +import {IPriceCapAdapterStable} from '../src/interfaces/IPriceCapAdapterStable.sol'; + +library CapAdaptersCodeAvalanche { + address public constant AUSD_PRICE_FEED = 0x5C2d58627Fbe746f5ea24Ef6D618f09f8e3f0122; + + function AUSDAdapterCode() internal pure returns (bytes memory) { + return + abi.encodePacked( + type(PriceCapAdapterStable).creationCode, + abi.encode( + IPriceCapAdapterStable.CapAdapterStableParams({ + aclManager: AaveV3Avalanche.ACL_MANAGER, + assetToUsdAggregator: IChainlinkAggregator(AUSD_PRICE_FEED), + adapterDescription: 'Capped AUSD / USD', + priceCap: int256(1.04 * 1e8) + }) + ) + ); + } +} + +contract DeployAUSDAvalanche is AvalancheScript { + function run() external broadcast { + GovV3Helpers.deployDeterministic(CapAdaptersCodeAvalanche.AUSDAdapterCode()); + } +} diff --git a/tests/avalanche/AUSDPriceCapAdapterTest.t.sol b/tests/avalanche/AUSDPriceCapAdapterTest.t.sol new file mode 100644 index 0000000..c25c8be --- /dev/null +++ b/tests/avalanche/AUSDPriceCapAdapterTest.t.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../BaseStableTest.sol'; +import {PriceCapAdapterStable} from '../../src/contracts/PriceCapAdapterStable.sol'; +import {CapAdaptersCodeAvalanche} from '../../scripts/DeployAvalanche.s.sol'; + +contract AUSDPriceCapAdapterTest is BaseStableTest { + constructor() + BaseStableTest( + CapAdaptersCodeAvalanche.AUSDAdapterCode(), + 10, + ForkParams({network: 'avalanche', blockNumber: 53614500}) + ) + {} +} \ No newline at end of file