Skip to content

Commit

Permalink
add test for HybridUSDCTokenPool bugfix and changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
jhweintraub committed Dec 23, 2024
1 parent 8f58fd4 commit 817ad6f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions contracts/.changeset/chilly-news-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/contracts': minor
---

#feature Add two new pool types: Siloed-LockRelease and BurnToAddress and fix bug in HybridUSDCTokenPool for transferLiqudity #bugfix
1 change: 1 addition & 0 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ FeeQuoter_updateTokenPriceFeeds:test_ZeroFeeds() (gas: 12471)
FeeQuoter_validateDestFamilyAddress:test_ValidEVMAddress() (gas: 6789)
FeeQuoter_validateDestFamilyAddress:test_ValidNonEVMAddress() (gas: 6514)
HybridLockReleaseUSDCTokenPool_TransferLiquidity:test_transferLiquidity() (gas: 167715)
HybridLockReleaseUSDCTokenPool_TransferLiquidity:test_transferLiquidity_MultipleChainsSequentially() (gas: 233095)
HybridLockReleaseUSDCTokenPool_lockOrBurn:test_PrimaryMechanism() (gas: 130356)
HybridLockReleaseUSDCTokenPool_lockOrBurn:test_onLockReleaseMechanism() (gas: 140104)
HybridLockReleaseUSDCTokenPool_lockOrBurn:test_onLockReleaseMechanism_thenSwitchToPrimary() (gas: 202967)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,34 @@ contract HybridLockReleaseUSDCTokenPool_TransferLiquidity is HybridLockReleaseUS
);
}

function test_transferLiquidity_MultipleChainsSequentially() public {
// Set as the OWNER so we can provide liquidity
vm.startPrank(OWNER);

uint64 RANDOM_CHAIN_SELECTOR = DEST_CHAIN_SELECTOR + 1;

s_usdcTokenPool.setLiquidityProvider(DEST_CHAIN_SELECTOR, OWNER);
s_usdcTokenPool.setLiquidityProvider(RANDOM_CHAIN_SELECTOR, OWNER);

s_token.approve(address(s_usdcTokenPool), type(uint256).max);

uint256 liquidityAmount = 1e9;

// Provide some liquidity to the pool
s_usdcTokenPool.provideLiquidity(DEST_CHAIN_SELECTOR, liquidityAmount);
s_usdcTokenPool.provideLiquidity(RANDOM_CHAIN_SELECTOR, liquidityAmount);

// Set the new token pool as the rebalancer
s_usdcTokenPool.transferOwnership(address(s_usdcTokenPoolTransferLiquidity));

// Test the ability to transfer liquidity from multiple chains in multiple sequential calls
s_usdcTokenPoolTransferLiquidity.transferLiquidity(address(s_usdcTokenPool), DEST_CHAIN_SELECTOR);
s_usdcTokenPoolTransferLiquidity.transferLiquidity(address(s_usdcTokenPool), RANDOM_CHAIN_SELECTOR);

assertEq(s_token.balanceOf(address(s_usdcTokenPoolTransferLiquidity)), liquidityAmount * 2);
assertEq(s_usdcTokenPoolTransferLiquidity.getLockedTokensForChain(RANDOM_CHAIN_SELECTOR), liquidityAmount);
}

function test_RevertWhen_cannotTransferLiquidityDuringPendingMigration() public {
// Set as the OWNER so we can provide liquidity
vm.startPrank(OWNER);
Expand Down

0 comments on commit 817ad6f

Please sign in to comment.