Skip to content

Commit

Permalink
Merge pull request #15 from bgd-labs/feat/bnb-fdusd
Browse files Browse the repository at this point in the history
feat: fdusd adapter for bnb
  • Loading branch information
rustboyar authored Mar 6, 2024
2 parents 5071736 + c40297f commit dd5e53e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
Binary file modified certora/CAPO report.pdf
Binary file not shown.
11 changes: 11 additions & 0 deletions scripts/DeployBnb.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ library CapAdaptersCodeBnb {
int256(1.04 * 1e8)
)
);
bytes public constant FDUSD_ADAPTER_CODE =
abi.encodePacked(
type(PriceCapAdapterStable).creationCode,
abi.encode(
AaveV3BNB.ACL_MANAGER,
AaveV3BNBAssets.FDUSD_ORACLE,
'Capped fdUSD/USD',
int256(1.04 * 1e8)
)
);
}

contract DeployBnbAdaptersAndPayload {
Expand All @@ -36,6 +46,7 @@ contract DeployBnbAdaptersAndPayload {

adapters.usdtAdapter = GovV3Helpers.deployDeterministic(CapAdaptersCodeBnb.USDT_ADAPTER_CODE);
adapters.usdcAdapter = GovV3Helpers.deployDeterministic(CapAdaptersCodeBnb.USDC_ADAPTER_CODE);
adapters.fdusdAdapter = GovV3Helpers.deployDeterministic(CapAdaptersCodeBnb.FDUSD_ADAPTER_CODE);

return
GovV3Helpers.deployDeterministic(
Expand Down
8 changes: 7 additions & 1 deletion src/contracts/payloads/AaveV3BnbPayload.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,30 @@ contract AaveV3BnbPayload is AaveV3PayloadBnb {
struct Adapters {
address usdtAdapter;
address usdcAdapter;
address fdusdAdapter;
}

address public immutable USDT_ADAPTER;
address public immutable USDC_ADAPTER;
address public immutable FDUSD_ADAPTER;

constructor(Adapters memory adapters) {
USDT_ADAPTER = adapters.usdtAdapter;
USDC_ADAPTER = adapters.usdcAdapter;
FDUSD_ADAPTER = adapters.fdusdAdapter;
}

function priceFeedsUpdates() public view override returns (IEngine.PriceFeedUpdate[] memory) {
IEngine.PriceFeedUpdate[] memory updates = new IEngine.PriceFeedUpdate[](2);
IEngine.PriceFeedUpdate[] memory updates = new IEngine.PriceFeedUpdate[](3);
updates[0].asset = AaveV3BNBAssets.USDT_UNDERLYING;
updates[0].priceFeed = USDT_ADAPTER;

updates[1].asset = AaveV3BNBAssets.USDC_UNDERLYING;
updates[1].priceFeed = USDC_ADAPTER;

updates[2].asset = AaveV3BNBAssets.FDUSD_UNDERLYING;
updates[2].priceFeed = FDUSD_ADAPTER;

return updates;
}
}
2 changes: 2 additions & 0 deletions tests/BaseTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,11 @@ abstract contract BaseTest is Test {
) public {
vm.assume(baseAggregatorAddress != 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f);
vm.assume(baseAggregatorAddress != 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
vm.assume(baseAggregatorAddress != 0x000000000000000000636F6e736F6c652e6c6f67);

vm.assume(ratioProviderAddress != 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f);
vm.assume(ratioProviderAddress != 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
vm.assume(ratioProviderAddress != 0x000000000000000000636F6e736F6c652e6c6f67);

vm.assume(address(aclManager) != address(0) && baseAggregatorAddress != address(0));
vm.assume(snapshotRatio > 0);
Expand Down
7 changes: 7 additions & 0 deletions tests/payloads/AaveV3BnbPayloadTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ contract AaveV3BnbPayloadTest is Test, DeployBnbAdaptersAndPayload {
CapAdaptersCodeBnb.USDC_ADAPTER_CODE
);

address fdusdPredicted = GovV3Helpers.predictDeterministicAddress(
CapAdaptersCodeBnb.FDUSD_ADAPTER_CODE
);

address payload = _deploy();

GovV3Helpers.executePayload(vm, payload);
Expand All @@ -30,5 +34,8 @@ contract AaveV3BnbPayloadTest is Test, DeployBnbAdaptersAndPayload {

address usdcNew = AaveV3BNB.ORACLE.getSourceOfAsset(AaveV3BNBAssets.USDC_UNDERLYING);
assertEq(usdcNew, usdcPredicted);

address fdusdNew = AaveV3BNB.ORACLE.getSourceOfAsset(AaveV3BNBAssets.FDUSD_UNDERLYING);
assertEq(fdusdNew, fdusdPredicted);
}
}

0 comments on commit dd5e53e

Please sign in to comment.