Skip to content

Commit

Permalink
Merge 79d0944 into 10fa0e5
Browse files Browse the repository at this point in the history
  • Loading branch information
ylv-io authored Feb 1, 2025
2 parents 10fa0e5 + 79d0944 commit f4e54a4
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 29 deletions.
70 changes: 70 additions & 0 deletions broadcast/02-upgrade_bridger.s.sol/42161/run-1738424026.json

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions broadcast/02-upgrade_bridger.s.sol/42161/run-latest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion script/migrations/arbitrum/02-upgrade_bridger.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ contract UpgradeBridgerScript is Constants, Test, MigrationHelper {
assertEq(bridger.SOLV_BTC(), 0x3647c54c4c2C65bC7a2D63c0Da2809B399DBBDC0, "Invalid SolvBtc address");

// Save address
saveContractAddress("BridgerV14-impl", newImpl);
saveContractAddress("BridgerV15-impl", newImpl);
}
}
4 changes: 2 additions & 2 deletions src/bridger/Bridger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ contract Bridger is
amount,
IERC20(inputAsset),
// If the final asset is sUSDe, swap to USDe first and then stake
// If the final asset is wUSDM, swap to USDC first, then swap to USDM using Curve, and finally wrap
// If the final asset is wUSDM, swap to USDM first and then stake
IERC20(_getFinalAssetByAsset(finalAsset)),
swapCallData
);
Expand Down Expand Up @@ -475,7 +475,7 @@ contract Bridger is
return USDe;
}
if (finalAsset == wUSDM) {
return USDC;
return USDM;
}
if (finalAsset == stUSD) {
return USDC;
Expand Down
5 changes: 3 additions & 2 deletions test/artifacts/42161/addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
"AaveBorrowWorkflow": "0xD0187Ca378f7B26D53e0A91fBe8D7ba80498EF10",
"AccessManager": "0xacc0003a4aAE5dA4ba12F771C7350D40147Cd7D4",
"BridgerV13-impl": "0xbA6FD752CE93879c381fb7ffdbe7baB233D6e6e4",
"BridgerV14-impl": "0x363EFf1981E664107EF4E8568Cc4321B74558DAA"
}
"BridgerV14-impl": "0x363EFf1981E664107EF4E8568Cc4321B74558DAA",
"BridgerV15-impl": "0x30592A2E419Db1338A6759279c547A9fdf2cd1DF"
}
66 changes: 66 additions & 0 deletions test/data/swap-usdc-to-usdm-arb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"blockNumber": "21746939",
"buyAmount": "1000020215920662956",
"buyToken": "0x59d9356e565ab3a36dd77763fc0d87feaf85508c",
"fees": {
"integratorFee": null,
"zeroExFee": null,
"gasFee": null
},
"issues": {
"allowance": {
"actual": "0",
"spender": "0x0000000000001ff3684f28c67538d4d072c22734"
},
"balance": {
"token": "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
"actual": "0",
"expected": "1000000"
},
"simulationIncomplete": false,
"invalidSourcesPassed": []
},
"liquidityAvailable": true,
"minBuyAmount": "990020013761453400",
"route": {
"fills": [
{
"from": "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
"to": "0x59d9356e565ab3a36dd77763fc0d87feaf85508c",
"source": "Curve",
"proportionBps": "10000"
}
],
"tokens": [
{
"address": "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
"symbol": "USDC"
},
{
"address": "0x59d9356e565ab3a36dd77763fc0d87feaf85508c",
"symbol": "USDM"
}
]
},
"sellAmount": "1000000",
"sellToken": "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
"tokenMetadata": {
"buyToken": {
"buyTaxBps": "0",
"sellTaxBps": "0"
},
"sellToken": {
"buyTaxBps": "0",
"sellTaxBps": "0"
}
},
"totalNetworkFee": "5165430000000",
"transaction": {
"to": "0x0000000000001ff3684f28c67538d4d072c22734",
"data": "0x2213bc0b0000000000000000000000006db4d3b89b06d3c8bd2074ee1f1b440baf122ead000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000f42400000000000000000000000006db4d3b89b06d3c8bd2074ee1f1b440baf122ead00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003c41fff991f000000000000000000000000b7dfe09cf3950141dfb7db8abca90ddef8d06ec000000000000000000000000059d9356e565ab3a36dd77763fc0d87feaf85508c0000000000000000000000000000000000000000000000000dbd41f508c75d5800000000000000000000000000000000000000000000000000000000000000a01a1bfdbeedfa26fb28419b21000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000e4c1fb425e0000000000000000000000006db4d3b89b06d3c8bd2074ee1f1b440baf122ead000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000f4240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000679d35b600000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016438c9c147000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000027100000000000000000000000004bd135524897333bec344e50ddd85126554e58b4000000000000000000000000000000000000000000000000000000000000004400000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000843df021240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gas": "516543",
"gasPrice": "10000000",
"value": "0"
},
"zid": "0x1a1bfdbeedfa26fb28419b21"
}
60 changes: 59 additions & 1 deletion test/fork/bridger/Bridger.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ contract BridgerTest is SignatureHelper, ForkTest, ArtifactsReader, BridgeDataHe
address internal ENA;
address internal wstETH;
address internal weETH;
address internal usdmCurvePool;

BridgerHarness internal bridger;

Expand Down Expand Up @@ -280,6 +279,65 @@ contract BridgerTest is SignatureHelper, ForkTest, ArtifactsReader, BridgeDataHe
);
}

// USDC to wUSDM
function testDepositBySig_WhenUSDCToWUSDM() public {
setUpArbitrumFork();
vm.rollFork(301295138); // block number in which the 0x API data was fetched
upgradeBridger();

IBridger.BridgeData memory data = bridgeData[block.chainid][wUSDM];
address assetToDeposit = USDC_ARBITRUM;
uint256 amountToDeposit = 1e6;
uint256 sharesBefore = ERC20(wUSDM).balanceOf(address(bridger));
uint256 vaultSharesBefore = ERC20(wUSDM).balanceOf(address(data.vault));

deal(assetToDeposit, _user, amountToDeposit);
deal(_user, data.gasFee);

assertEq(ERC20(assetToDeposit).balanceOf(_user), amountToDeposit);

IBridger.SignatureData memory sigdata = _auxCreateBridgeSignature(
kintoWalletL2,
bridger,
_user,
assetToDeposit,
wUSDM,
amountToDeposit,
968e3,
_userPk,
block.timestamp + 1000
);

bytes memory permitSignature = _auxCreatePermitSignature(
IBridger.Permit(
_user,
address(bridger),
amountToDeposit,
ERC20Permit(assetToDeposit).nonces(_user),
block.timestamp + 1000
),
_userPk,
ERC20Permit(assetToDeposit)
);
uint256 nonce = bridger.nonces(_user);

vm.prank(bridger.owner());
bridger.setBridgeVault(data.vault, true);

// USDC to USDM quote's swapData
// curl 'https://api.0x.org/swap/allowance-holder/quote?chainId=42161&buyToken=0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C&sellToken=0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1&sellAmount=1000000000000000000&taker=0xb7DfE09Cf3950141DFb7DB8ABca90dDef8d06Ec0' -H '0x-api-key: key' -H '0x-version: v2' | jq > ./test/data/swap-usdc-to-usdm-arb.json
bytes memory swapCalldata = vm.readFile("./test/data/swap-usdc-to-usdm-arb.json").readBytes(".transaction.data");

vm.deal(address(bridger), data.gasFee);
vm.prank(_owner);
bridger.depositBySig(permitSignature, sigdata, swapCalldata, data);
assertEq(bridger.nonces(_user), nonce + 1);

uint256 shares = ERC4626(wUSDM).previewDeposit(1000020215920662957);
assertEq(ERC20(wUSDM).balanceOf(address(bridger)), sharesBefore, "Invalid balance of the Bridger");
assertEq(ERC20(wUSDM).balanceOf(data.vault), vaultSharesBefore + shares, "Invalid balance of the Vault");
}

// DAI to wUSDM
function testDepositBySig_WhenDaiToWUSDM() public {
setUpArbitrumFork();
Expand Down

0 comments on commit f4e54a4

Please sign in to comment.