@@ -367,11 +367,6 @@ describe("InventoryClient: Refund chain selection", async function () {
367
367
hubPoolClient . setEnableAllL2Tokens ( true ) ;
368
368
expect ( await inventoryClient . determineRefundChainId ( sampleDepositData ) ) . to . deep . equal ( [ MAINNET ] ) ;
369
369
expect ( lastSpyLogIncludes ( spy , 'expectedPostRelayAllocation":"166666666666666666"' ) ) . to . be . true ;
370
-
371
- // If we set this to false in this test, the destination chain will be default used since the refund data
372
- // will be ignored.
373
- hubPoolClient . setEnableAllL2Tokens ( false ) ;
374
- expect ( await inventoryClient . determineRefundChainId ( sampleDepositData ) ) . to . deep . equal ( [ OPTIMISM , MAINNET ] ) ;
375
370
} ) ;
376
371
377
372
it ( "Normalizes upcoming refunds to correct precision" , async function ( ) {
@@ -394,19 +389,16 @@ describe("InventoryClient: Refund chain selection", async function () {
394
389
hubPoolClient . setEnableAllL2Tokens ( true ) ;
395
390
expect ( await inventoryClient . determineRefundChainId ( sampleDepositData ) ) . to . deep . equal ( [ MAINNET ] ) ;
396
391
expect ( lastSpyLogIncludes ( spy , 'expectedPostRelayAllocation":"166666666666666666"' ) ) . to . be . true ;
397
-
398
- // If we set this to false in this test, the destination chain will be default used since the refund data
399
- // will be ignored.
400
- hubPoolClient . setEnableAllL2Tokens ( false ) ;
401
- expect ( await inventoryClient . determineRefundChainId ( sampleDepositData ) ) . to . deep . equal ( [ OPTIMISM , MAINNET ] ) ;
402
392
} ) ;
403
393
404
394
it ( "Correctly throws when Deposit tokens are not equivalent" , async function ( ) {
405
395
sampleDepositData . inputAmount = toWei ( 5 ) ;
406
396
sampleDepositData . outputAmount = await computeOutputAmount ( sampleDepositData ) ;
407
397
expect ( await inventoryClient . determineRefundChainId ( sampleDepositData ) ) . to . deep . equal ( [ 1 ] ) ;
408
398
409
- sampleDepositData . outputToken = ZERO_ADDRESS ;
399
+ // In this test, output token has a valid pool rebalance mapping but its not the equivalent token as the
400
+ // input token
401
+ sampleDepositData . outputToken = l2TokensForUsdc [ OPTIMISM ] ;
410
402
const srcChain = getNetworkName ( sampleDepositData . originChainId ) ;
411
403
const dstChain = getNetworkName ( sampleDepositData . destinationChainId ) ;
412
404
await assertPromiseError (
@@ -711,92 +703,4 @@ describe("InventoryClient: Refund chain selection", async function () {
711
703
expect ( possibleRepaymentChains . length ) . to . equal ( 4 ) ;
712
704
} ) ;
713
705
} ) ;
714
-
715
- describe ( "In-protocol swap" , async function ( ) {
716
- const nativeUSDC = TOKEN_SYMBOLS_MAP . USDC . addresses ;
717
- const bridgedUSDC = { ...TOKEN_SYMBOLS_MAP [ "USDC.e" ] . addresses , ...TOKEN_SYMBOLS_MAP [ "USDbC" ] . addresses } ;
718
-
719
- beforeEach ( async function ( ) {
720
- hubPoolClient . mapTokenInfo ( nativeUSDC [ ARBITRUM ] , "USDC" , 6 ) ;
721
-
722
- // Sub in a nested USDC config for the existing USDC config.
723
- const usdcConfig = {
724
- [ nativeUSDC [ OPTIMISM ] ] : {
725
- [ OPTIMISM ] : { targetPct : toWei ( 0.12 ) , thresholdPct : toWei ( 0.1 ) , targetOverageBuffer } ,
726
- } ,
727
- [ nativeUSDC [ POLYGON ] ] : {
728
- [ POLYGON ] : { targetPct : toWei ( 0.07 ) , thresholdPct : toWei ( 0.05 ) , targetOverageBuffer } ,
729
- } ,
730
- [ nativeUSDC [ ARBITRUM ] ] : {
731
- [ ARBITRUM ] : { targetPct : toWei ( 0.07 ) , thresholdPct : toWei ( 0.05 ) , targetOverageBuffer } ,
732
- } ,
733
- [ bridgedUSDC [ OPTIMISM ] ] : {
734
- [ OPTIMISM ] : { targetPct : toWei ( 0.12 ) , thresholdPct : toWei ( 0.1 ) , targetOverageBuffer } ,
735
- } ,
736
- [ bridgedUSDC [ POLYGON ] ] : {
737
- [ POLYGON ] : { targetPct : toWei ( 0.07 ) , thresholdPct : toWei ( 0.05 ) , targetOverageBuffer } ,
738
- } ,
739
- [ bridgedUSDC [ ARBITRUM ] ] : {
740
- [ ARBITRUM ] : { targetPct : toWei ( 0.07 ) , thresholdPct : toWei ( 0.05 ) , targetOverageBuffer } ,
741
- } ,
742
- } ;
743
- inventoryConfig . tokenConfig [ mainnetUsdc ] = usdcConfig ;
744
-
745
- const inputAmount = toMegaWei ( 100 ) ;
746
- sampleDepositData = {
747
- depositId : bnZero ,
748
- fromLiteChain : false ,
749
- toLiteChain : false ,
750
- originChainId : ARBITRUM ,
751
- destinationChainId : OPTIMISM ,
752
- depositor : owner . address ,
753
- recipient : owner . address ,
754
- inputToken : nativeUSDC [ ARBITRUM ] ,
755
- inputAmount,
756
- outputToken : bridgedUSDC [ OPTIMISM ] ,
757
- outputAmount : inputAmount ,
758
- message : "0x" ,
759
- messageHash : "0x" ,
760
- quoteTimestamp : hubPoolClient . currentTime ! ,
761
- fillDeadline : 0 ,
762
- exclusivityDeadline : 0 ,
763
- exclusiveRelayer : ZERO_ADDRESS ,
764
- } ;
765
- } ) ;
766
-
767
- it ( "outputToken is not supported as a repaymentToken" , async function ( ) {
768
- // Verify that there is no native USDC anywhere. The relayer is responsible for ensuring that it can make the fill.
769
- enabledChainIds
770
- . filter ( ( chainId ) => chainId !== MAINNET )
771
- . forEach ( ( chainId ) => expect ( tokenClient . getBalance ( chainId , nativeUSDC [ chainId ] ) . eq ( bnZero ) ) . to . be . true ) ;
772
-
773
- // All chains are at target balance; cumulative balance is unchanged but repaymentToken balances on origin chain increases.
774
- expect ( await inventoryClient . determineRefundChainId ( sampleDepositData , mainnetUsdc ) ) . to . deep . equal ( [ MAINNET ] ) ;
775
- expect ( lastSpyLogIncludes ( spy , 'expectedPostRelayAllocation":"78571428571428571"' ) ) . to . be . true ; // (1,000+100)/(14,000)
776
-
777
- // Even when the output amount is equal to the destination's entire balance, take repayment on mainnet.
778
- // This should be th same calculation as above.
779
- sampleDepositData . outputAmount = inventoryClient . getBalanceOnChain ( OPTIMISM , mainnetUsdc ) ;
780
- expect ( await inventoryClient . determineRefundChainId ( sampleDepositData , mainnetUsdc ) ) . to . deep . equal ( [ MAINNET ] ) ;
781
- expect ( lastSpyLogIncludes ( spy , 'expectedPostRelayAllocation":"78571428571428571"' ) ) . to . be . true ; // (1,000+100)/(14,000)
782
-
783
- // Drop the relayer's repaymentToken balance on Optimism. Repayment chain should now be Optimism.
784
- let balance = tokenClient . getBalance ( OPTIMISM , bridgedUSDC [ OPTIMISM ] ) ;
785
- tokenClient . setTokenData ( OPTIMISM , bridgedUSDC [ OPTIMISM ] , bnZero ) ;
786
- expect ( await inventoryClient . determineRefundChainId ( sampleDepositData , mainnetUsdc ) ) . to . deep . equal ( [
787
- OPTIMISM ,
788
- MAINNET ,
789
- ] ) ;
790
-
791
- // Restore the Optimism balance and drop the Arbitrum balance. Repayment chain should now be Arbitrum.
792
- tokenClient . setTokenData ( OPTIMISM , bridgedUSDC [ OPTIMISM ] , balance ) ;
793
-
794
- balance = tokenClient . getBalance ( ARBITRUM , bridgedUSDC [ ARBITRUM ] ) ;
795
- tokenClient . setTokenData ( ARBITRUM , bridgedUSDC [ ARBITRUM ] , bnZero ) ;
796
- expect ( await inventoryClient . determineRefundChainId ( sampleDepositData , mainnetUsdc ) ) . to . deep . equal ( [
797
- ARBITRUM ,
798
- MAINNET ,
799
- ] ) ;
800
- } ) ;
801
- } ) ;
802
706
} ) ;
0 commit comments