generated from bgd-labs/bgd-forge-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from AaveChan/aavechan/SUSD
feat: CAPO for USDS & sUSDS
- Loading branch information
Showing
6 changed files
with
166 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.19; | ||
|
||
import {IERC4626} from 'forge-std/interfaces/IERC4626.sol'; | ||
import {IACLManager} from 'aave-address-book/AaveV3.sol'; | ||
|
||
import {PriceCapAdapterBase, IPriceCapAdapter} from '../PriceCapAdapterBase.sol'; | ||
|
||
/** | ||
* @title sUSDSPriceCapAdapter | ||
* @author BGD Labs | ||
* @notice Price capped adapter to calculate price of (sUSDS / USD) pair by using | ||
* @notice Capped adapter for (USDS <-> DAI / USD) and (sUSDS / USDS) ratio. | ||
*/ | ||
contract sUSDSPriceCapAdapter is PriceCapAdapterBase { | ||
/** | ||
* @param capAdapterParams parameters to create cap adapter | ||
*/ | ||
constructor( | ||
CapAdapterParams memory capAdapterParams | ||
) | ||
PriceCapAdapterBase( | ||
CapAdapterBaseParams({ | ||
aclManager: capAdapterParams.aclManager, | ||
baseAggregatorAddress: capAdapterParams.baseAggregatorAddress, | ||
ratioProviderAddress: capAdapterParams.ratioProviderAddress, | ||
pairDescription: capAdapterParams.pairDescription, | ||
ratioDecimals: 18, | ||
minimumSnapshotDelay: capAdapterParams.minimumSnapshotDelay, | ||
priceCapParams: capAdapterParams.priceCapParams | ||
}) | ||
) | ||
{} | ||
|
||
/// @inheritdoc IPriceCapAdapter | ||
function getRatio() public view override returns (int256) { | ||
return int256(IERC4626(RATIO_PROVIDER).convertToAssets(10 ** RATIO_DECIMALS)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 {CapAdaptersCodeEthereum} from '../../scripts/DeployEthereum.s.sol'; | ||
|
||
contract USDSPriceCapAdapterTest is BaseStableTest { | ||
constructor() | ||
BaseStableTest( | ||
CapAdaptersCodeEthereum.USDSAdapterCode(), | ||
10, | ||
ForkParams({network: 'mainnet', blockNumber: 20729672}) | ||
) | ||
{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
|
||
import 'forge-std/Test.sol'; | ||
import '../BaseTest.sol'; | ||
|
||
import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; | ||
import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol'; | ||
import {sUSDSPriceCapAdapter} from '../../src/contracts/lst-adapters/sUSDSPriceCapAdapter.sol'; | ||
import {CapAdaptersCodeEthereum} from '../../scripts/DeployEthereum.s.sol'; | ||
|
||
contract sUSDSPriceCapAdapterTest is BaseTest { | ||
constructor() | ||
BaseTest( | ||
CapAdaptersCodeEthereum.sUSDSAdapterCode(), | ||
3, | ||
ForkParams({network: 'mainnet', blockNumber: 20729672}), | ||
'sUSDS_Ethereum' | ||
) | ||
{ | ||
} | ||
|
||
function test_latestAnswer() public override { | ||
GovV3Helpers.deployDeterministic(CapAdaptersCodeEthereum.USDSAdapterCode()); | ||
IPriceCapAdapter adapter = IPriceCapAdapter(GovV3Helpers.deployDeterministic(deploymentCode)); | ||
|
||
int256 price = adapter.latestAnswer(); | ||
int256 priceOfReferenceAdapter = adapter.BASE_TO_USD_AGGREGATOR().latestAnswer(); | ||
|
||
assertFalse(adapter.isCapped()); | ||
assertGe( | ||
price, | ||
priceOfReferenceAdapter, | ||
'lst price is not greater than the reference adapter price' | ||
); | ||
} | ||
|
||
function test_latestAnswerRetrospective() public override { | ||
assert(true); | ||
} | ||
|
||
function test_cappedLatestAnswer() public override pure { | ||
assert(true); | ||
} | ||
|
||
function _createAdapter( | ||
IPriceCapAdapter.CapAdapterParams memory capAdapterParams | ||
) internal override returns (IPriceCapAdapter) { | ||
return new sUSDSPriceCapAdapter(capAdapterParams); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters