@@ -41,6 +41,7 @@ import {
41
41
chainIsEvm ,
42
42
isValidEvmAddress ,
43
43
duplicateEvent ,
44
+ invalidOutputToken ,
44
45
} from "../../utils" ;
45
46
import winston from "winston" ;
46
47
import {
@@ -321,6 +322,7 @@ export class BundleDataClient {
321
322
// @dev This helper function should probably be moved to the InventoryClient
322
323
async getApproximateRefundsForBlockRange ( chainIds : number [ ] , blockRanges : number [ ] [ ] ) : Promise < CombinedRefunds > {
323
324
const refundsForChain : CombinedRefunds = { } ;
325
+ const bundleEndBlockForMainnet = blockRanges [ 0 ] [ 1 ] ;
324
326
for ( const chainId of chainIds ) {
325
327
if ( this . spokePoolClients [ chainId ] === undefined ) {
326
328
continue ;
@@ -335,7 +337,8 @@ export class BundleDataClient {
335
337
if (
336
338
fill . blockNumber < blockRanges [ chainIndex ] [ 0 ] ||
337
339
fill . blockNumber > blockRanges [ chainIndex ] [ 1 ] ||
338
- isZeroValueFillOrSlowFillRequest ( fill )
340
+ isZeroValueFillOrSlowFillRequest ( fill ) ||
341
+ invalidOutputToken ( fill )
339
342
) {
340
343
return false ;
341
344
}
@@ -362,17 +365,19 @@ export class BundleDataClient {
362
365
_fill ,
363
366
spokeClient . spokePool . provider ,
364
367
matchingDeposit ,
365
- this . clients . hubPoolClient
368
+ this . clients . hubPoolClient ,
369
+ bundleEndBlockForMainnet
366
370
) ;
367
371
if ( ! isDefined ( fill ) ) {
368
372
return ;
369
373
}
370
374
const { chainToSendRefundTo, repaymentToken } = getRefundInformationFromFill (
371
- fill ,
375
+ {
376
+ ...fill ,
377
+ fromLiteChain : matchingDeposit . fromLiteChain ,
378
+ } ,
372
379
this . clients . hubPoolClient ,
373
- blockRanges ,
374
- this . chainIdListForBundleEvaluationBlockNumbers ,
375
- matchingDeposit . fromLiteChain
380
+ bundleEndBlockForMainnet
376
381
) ;
377
382
// Assume that lp fees are 0 for the sake of speed. In the future we could batch compute
378
383
// these or make hardcoded assumptions based on the origin-repayment chain direction. This might result
@@ -635,6 +640,7 @@ export class BundleDataClient {
635
640
}
636
641
637
642
const chainIds = this . clients . configStoreClient . getChainIdIndicesForBlock ( blockRangesForChains [ 0 ] [ 0 ] ) ;
643
+ const bundleEndBlockForMainnet = blockRangesForChains [ 0 ] [ 1 ] ;
638
644
639
645
if ( blockRangesForChains . length > chainIds . length ) {
640
646
throw new Error (
@@ -671,7 +677,7 @@ export class BundleDataClient {
671
677
deposit . originChainId ,
672
678
deposit . outputToken ,
673
679
deposit . destinationChainId ,
674
- deposit . quoteBlockNumber
680
+ bundleEndBlockForMainnet
675
681
) &&
676
682
// Cannot slow fill from or to a lite chain.
677
683
! deposit . fromLiteChain &&
@@ -848,7 +854,10 @@ export class BundleDataClient {
848
854
// tokens to the filler. We can't remove non-empty message deposit here in case there is a slow fill
849
855
// request for the deposit, we'd want to see the fill took place.
850
856
. filter (
851
- ( fill ) => fill . blockNumber <= destinationChainBlockRange [ 1 ] && ! isZeroValueFillOrSlowFillRequest ( fill )
857
+ ( fill ) =>
858
+ fill . blockNumber <= destinationChainBlockRange [ 1 ] &&
859
+ ! isZeroValueFillOrSlowFillRequest ( fill ) &&
860
+ ! invalidOutputToken ( fill )
852
861
) ,
853
862
async ( fill ) => {
854
863
fillCounter ++ ;
@@ -867,7 +876,8 @@ export class BundleDataClient {
867
876
fill ,
868
877
destinationClient . spokePool . provider ,
869
878
deposits [ 0 ] ,
870
- this . clients . hubPoolClient
879
+ this . clients . hubPoolClient ,
880
+ bundleEndBlockForMainnet
871
881
) ;
872
882
if ( ! isDefined ( fillToRefund ) ) {
873
883
bundleUnrepayableFillsV3 . push ( fill ) ;
@@ -971,7 +981,8 @@ export class BundleDataClient {
971
981
fill ,
972
982
destinationClient . spokePool . provider ,
973
983
matchedDeposit ,
974
- this . clients . hubPoolClient
984
+ this . clients . hubPoolClient ,
985
+ bundleEndBlockForMainnet
975
986
) ;
976
987
if ( ! isDefined ( fillToRefund ) ) {
977
988
bundleUnrepayableFillsV3 . push ( fill ) ;
@@ -1017,7 +1028,9 @@ export class BundleDataClient {
1017
1028
. getSlowFillRequestsForOriginChain ( originChainId )
1018
1029
. filter (
1019
1030
( request ) =>
1020
- request . blockNumber <= destinationChainBlockRange [ 1 ] && ! isZeroValueFillOrSlowFillRequest ( request )
1031
+ request . blockNumber <= destinationChainBlockRange [ 1 ] &&
1032
+ ! isZeroValueFillOrSlowFillRequest ( request ) &&
1033
+ ! invalidOutputToken ( request )
1021
1034
) ,
1022
1035
async ( slowFillRequest : SlowFillRequestWithBlock ) => {
1023
1036
const relayDataHash = getRelayEventKey ( slowFillRequest ) ;
@@ -1149,7 +1162,8 @@ export class BundleDataClient {
1149
1162
fill ,
1150
1163
destinationClient . spokePool . provider ,
1151
1164
deposits [ 0 ] ,
1152
- this . clients . hubPoolClient
1165
+ this . clients . hubPoolClient ,
1166
+ bundleEndBlockForMainnet
1153
1167
) ;
1154
1168
if ( ! isDefined ( fillToRefund ) ) {
1155
1169
bundleUnrepayableFillsV3 . push ( fill ) ;
@@ -1205,7 +1219,8 @@ export class BundleDataClient {
1205
1219
prefill ,
1206
1220
destinationClient . spokePool . provider ,
1207
1221
deposit ,
1208
- this . clients . hubPoolClient
1222
+ this . clients . hubPoolClient ,
1223
+ bundleEndBlockForMainnet
1209
1224
) ;
1210
1225
if ( ! isDefined ( verifiedFill ) ) {
1211
1226
bundleUnrepayableFillsV3 . push ( prefill ) ;
@@ -1339,11 +1354,12 @@ export class BundleDataClient {
1339
1354
const matchedDeposit = deposits [ 0 ] ;
1340
1355
assert ( isDefined ( matchedDeposit ) , "Deposit should exist in relay hash dictionary." ) ;
1341
1356
const { chainToSendRefundTo : paymentChainId } = getRefundInformationFromFill (
1342
- fill ,
1357
+ {
1358
+ ...fill ,
1359
+ fromLiteChain : matchedDeposit . fromLiteChain ,
1360
+ } ,
1343
1361
this . clients . hubPoolClient ,
1344
- blockRangesForChains ,
1345
- chainIds ,
1346
- matchedDeposit . fromLiteChain
1362
+ bundleEndBlockForMainnet
1347
1363
) ;
1348
1364
return {
1349
1365
...fill ,
@@ -1385,11 +1401,12 @@ export class BundleDataClient {
1385
1401
const associatedDeposit = deposits [ 0 ] ;
1386
1402
assert ( isDefined ( associatedDeposit ) , "Deposit should exist in relay hash dictionary." ) ;
1387
1403
const { chainToSendRefundTo, repaymentToken } = getRefundInformationFromFill (
1388
- fill ,
1404
+ {
1405
+ ...fill ,
1406
+ fromLiteChain : associatedDeposit . fromLiteChain ,
1407
+ } ,
1389
1408
this . clients . hubPoolClient ,
1390
- blockRangesForChains ,
1391
- chainIds ,
1392
- associatedDeposit . fromLiteChain
1409
+ bundleEndBlockForMainnet
1393
1410
) ;
1394
1411
updateBundleFillsV3 ( bundleFillsV3 , fill , realizedLpFeePct , chainToSendRefundTo , repaymentToken , fill . relayer ) ;
1395
1412
} ) ;
0 commit comments