@@ -33,8 +33,6 @@ describe('Chain abstraction orchestrator', () => {
33
33
34
34
// Amount to send to Optimism
35
35
const amount_to_send = 3_000_000
36
- // Amount bridging slippage
37
- const amount_slippage = 2 ; // +2% topup
38
36
39
37
let usdc_contracts = { } ;
40
38
usdc_contracts [ chain_id_optimism ] = "0x0b2c639c533813f4aa9d7837caf62653d097ff85" ;
@@ -133,7 +131,6 @@ describe('Chain abstraction orchestrator', () => {
133
131
134
132
// How much needs to be topped up
135
133
const amount_to_topup = Math . round ( amount_to_send - usdc_funds [ chain_id_optimism ] ) ;
136
- const amount_to_topup_with_fees = Math . round ( ( ( amount_to_topup * amount_slippage ) / 100 ) + amount_to_topup ) ;
137
134
138
135
const data_encoded = erc20Interface . encodeFunctionData ( 'transfer' , [
139
136
receiver_address ,
@@ -167,7 +164,7 @@ describe('Chain abstraction orchestrator', () => {
167
164
expect ( approvalTransaction . nonce ) . not . toBe ( "0x00" )
168
165
expect ( ( ) => BigInt ( approvalTransaction . gasLimit ) ) . not . toThrow ( ) ;
169
166
const decodedData = erc20Interface . decodeFunctionData ( 'approve' , approvalTransaction . input ) ;
170
- if ( decodedData . amount < BigInt ( amount_to_topup_with_fees ) ) {
167
+ if ( decodedData . amount <= BigInt ( amount_to_topup ) ) {
171
168
throw new Error ( `Expected amount is lower then the minimal required` ) ;
172
169
}
173
170
@@ -188,10 +185,10 @@ describe('Chain abstraction orchestrator', () => {
188
185
expect ( fundingFrom . chainId ) . toBe ( chain_id_base )
189
186
expect ( fundingFrom . symbol ) . toBe ( usdc_token_symbol )
190
187
expect ( fundingFrom . tokenContract ) . toBe ( usdc_contracts [ chain_id_base ] . toLowerCase ( ) )
191
- if ( BigInt ( fundingFrom . amount ) <= BigInt ( amount_to_topup_with_fees ) ) {
188
+ if ( BigInt ( fundingFrom . amount ) <= BigInt ( amount_to_topup ) ) {
192
189
throw new Error ( `Expected amount is lower then the minimal required` ) ;
193
190
}
194
- if ( BigInt ( fundingFrom . bridgingFee ) != BigInt ( fundingFrom . amount - amount_to_topup ) ) {
191
+ if ( BigInt ( fundingFrom . bridgingFee ) < BigInt ( fundingFrom . amount - amount_to_topup ) ) {
195
192
throw new Error ( `Expected bridging fee is incorrect. ` ) ;
196
193
}
197
194
// Check the initialTransaction metadata
@@ -212,7 +209,6 @@ describe('Chain abstraction orchestrator', () => {
212
209
213
210
// How much needs to be topped up
214
211
const amount_to_topup = Math . round ( amount_to_send - usdt_funds [ chain_id_optimism ] ) ;
215
- const amount_to_topup_with_fees = Math . round ( ( ( amount_to_topup * amount_slippage ) / 100 ) + amount_to_topup ) ;
216
212
217
213
const data_encoded = erc20Interface . encodeFunctionData ( 'transfer' , [
218
214
receiver_address ,
@@ -246,7 +242,7 @@ describe('Chain abstraction orchestrator', () => {
246
242
expect ( approvalTransaction . nonce ) . not . toBe ( "0x00" )
247
243
expect ( ( ) => BigInt ( approvalTransaction . gasLimit ) ) . not . toThrow ( ) ;
248
244
const decodedData = erc20Interface . decodeFunctionData ( 'approve' , approvalTransaction . input ) ;
249
- if ( decodedData . amount < BigInt ( amount_to_topup_with_fees ) ) {
245
+ if ( decodedData . amount <= BigInt ( amount_to_topup ) ) {
250
246
throw new Error ( `Expected amount is lower then the minimal required` ) ;
251
247
}
252
248
@@ -267,10 +263,10 @@ describe('Chain abstraction orchestrator', () => {
267
263
expect ( fundingFrom . chainId ) . toBe ( chain_id_arbitrum )
268
264
expect ( fundingFrom . symbol ) . toBe ( usdt_token_symbol )
269
265
expect ( fundingFrom . tokenContract ) . toBe ( usdt_contracts [ chain_id_arbitrum ] . toLowerCase ( ) )
270
- if ( BigInt ( fundingFrom . amount ) <= BigInt ( amount_to_topup_with_fees ) ) {
266
+ if ( BigInt ( fundingFrom . amount ) <= BigInt ( amount_to_topup ) ) {
271
267
throw new Error ( `Expected amount is lower then the minimal required` ) ;
272
268
}
273
- if ( BigInt ( fundingFrom . bridgingFee ) != BigInt ( fundingFrom . amount - amount_to_topup ) ) {
269
+ if ( BigInt ( fundingFrom . bridgingFee ) < BigInt ( fundingFrom . amount - amount_to_topup ) ) {
274
270
throw new Error ( `Expected bridging fee is incorrect. ` ) ;
275
271
}
276
272
// Check the initialTransaction metadata
0 commit comments