@paraswap/dex-lib 2.47.4 → 2.47.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/abi/Redstone.json +739 -0
- package/build/abi/angle/stagToken.json +963 -0
- package/build/abi/angle-transmuter/Pyth.json +1534 -0
- package/build/abi/angle-transmuter/Transmuter.json +1719 -0
- package/build/abi/smardex/smardex-factory.json +185 -0
- package/build/abi/smardex/smardex-pool.json +578 -0
- package/build/abi/smardex/smardex-router.json +648 -0
- package/build/abi/trader-joe-v2_1/FactoryABI.json +1208 -0
- package/build/abi/trader-joe-v2_1/PairABI.json +1493 -0
- package/build/abi/trader-joe-v2_1/RouterABI.json +1489 -0
- package/build/abi/trader-joe-v2_1/StateMulticall.json +193 -0
- package/build/abi/wombat/pool.json +1289 -0
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.d.ts +53 -0
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.js +175 -0
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.js.map +1 -0
- package/build/dex/angle-staked-stable/angle-staked-stable.d.ts +42 -0
- package/build/dex/angle-staked-stable/angle-staked-stable.js +232 -0
- package/build/dex/angle-staked-stable/angle-staked-stable.js.map +1 -0
- package/build/dex/angle-staked-stable/config.d.ts +4 -0
- package/build/dex/angle-staked-stable/config.js +26 -0
- package/build/dex/angle-staked-stable/config.js.map +1 -0
- package/build/dex/angle-staked-stable/types.d.ts +15 -0
- package/build/dex/angle-staked-stable/types.js +3 -0
- package/build/dex/angle-staked-stable/types.js.map +1 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.d.ts +43 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.js +309 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.js.map +1 -0
- package/build/dex/angle-transmuter/angle-transmuter.d.ts +46 -0
- package/build/dex/angle-transmuter/angle-transmuter.js +233 -0
- package/build/dex/angle-transmuter/angle-transmuter.js.map +1 -0
- package/build/dex/angle-transmuter/backedOracle.d.ts +19 -0
- package/build/dex/angle-transmuter/backedOracle.js +56 -0
- package/build/dex/angle-transmuter/backedOracle.js.map +1 -0
- package/build/dex/angle-transmuter/config.d.ts +4 -0
- package/build/dex/angle-transmuter/config.js +20 -0
- package/build/dex/angle-transmuter/config.js.map +1 -0
- package/build/dex/angle-transmuter/constants.d.ts +4 -0
- package/build/dex/angle-transmuter/constants.js +8 -0
- package/build/dex/angle-transmuter/constants.js.map +1 -0
- package/build/dex/angle-transmuter/pyth.d.ts +19 -0
- package/build/dex/angle-transmuter/pyth.js +71 -0
- package/build/dex/angle-transmuter/pyth.js.map +1 -0
- package/build/dex/angle-transmuter/redstone.d.ts +20 -0
- package/build/dex/angle-transmuter/redstone.js +73 -0
- package/build/dex/angle-transmuter/redstone.js.map +1 -0
- package/build/dex/angle-transmuter/transmuter.d.ts +50 -0
- package/build/dex/angle-transmuter/transmuter.js +314 -0
- package/build/dex/angle-transmuter/transmuter.js.map +1 -0
- package/build/dex/angle-transmuter/types.d.ts +144 -0
- package/build/dex/angle-transmuter/types.js +31 -0
- package/build/dex/angle-transmuter/types.js.map +1 -0
- package/build/dex/angle-transmuter/utils.d.ts +9 -0
- package/build/dex/angle-transmuter/utils.js +264 -0
- package/build/dex/angle-transmuter/utils.js.map +1 -0
- package/build/dex/balancer-v2/balancer-v2.d.ts +3 -6
- package/build/dex/balancer-v2/balancer-v2.js +35 -55
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/balancer-v2/types.d.ts +1 -24
- package/build/dex/balancer-v2/types.js +0 -2
- package/build/dex/balancer-v2/types.js.map +1 -1
- package/build/dex/balancer-v2/utils.d.ts +0 -8
- package/build/dex/balancer-v2/utils.js +1 -17
- package/build/dex/balancer-v2/utils.js.map +1 -1
- package/build/dex/hashflow/hashflow.js +2 -1
- package/build/dex/hashflow/hashflow.js.map +1 -1
- package/build/dex/smardex/subgraph-queries.d.ts +1 -0
- package/build/dex/smardex/subgraph-queries.js +17 -0
- package/build/dex/smardex/subgraph-queries.js.map +1 -0
- package/build/dex/smardex/usd-reserves.d.ts +23 -0
- package/build/dex/smardex/usd-reserves.js +86 -0
- package/build/dex/smardex/usd-reserves.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/config.d.ts +4 -0
- package/build/dex/trader-joe-v2-1-2/config.js +47 -0
- package/build/dex/trader-joe-v2-1-2/config.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/constants.d.ts +20 -0
- package/build/dex/trader-joe-v2-1-2/constants.js +22 -0
- package/build/dex/trader-joe-v2-1-2/constants.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/math/index.d.ts +37 -0
- package/build/dex/trader-joe-v2-1-2/math/index.js +291 -0
- package/build/dex/trader-joe-v2-1-2/math/index.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.d.ts +60 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js +248 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.d.ts +53 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js +307 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/types.d.ts +82 -0
- package/build/dex/trader-joe-v2-1-2/types.js +9 -0
- package/build/dex/trader-joe-v2-1-2/types.js.map +1 -0
- package/build/dex/trader-joe-v2_1/config.d.ts +4 -0
- package/build/dex/trader-joe-v2_1/config.js +47 -0
- package/build/dex/trader-joe-v2_1/config.js.map +1 -0
- package/build/dex/trader-joe-v2_1/constants.d.ts +20 -0
- package/build/dex/trader-joe-v2_1/constants.js +22 -0
- package/build/dex/trader-joe-v2_1/constants.js.map +1 -0
- package/build/dex/trader-joe-v2_1/math/index.d.ts +37 -0
- package/build/dex/trader-joe-v2_1/math/index.js +291 -0
- package/build/dex/trader-joe-v2_1/math/index.js.map +1 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.d.ts +0 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js +384 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js.map +1 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.d.ts +60 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js +247 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js.map +1 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.d.ts +53 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js +307 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js.map +1 -0
- package/build/dex/trader-joe-v2_1/types.d.ts +82 -0
- package/build/dex/trader-joe-v2_1/types.js +9 -0
- package/build/dex/trader-joe-v2_1/types.js.map +1 -0
- package/build/dex/wombat/wombat-pool-poller.d.ts +22 -0
- package/build/dex/wombat/wombat-pool-poller.js +164 -0
- package/build/dex/wombat/wombat-pool-poller.js.map +1 -0
- package/package.json +1 -2
- package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +0 -94
- package/src/dex/balancer-v2/balancer-v2-integration.test.ts +112 -253
- package/src/dex/balancer-v2/balancer-v2.ts +69 -105
- package/src/dex/balancer-v2/types.ts +0 -26
- package/src/dex/balancer-v2/utils.ts +0 -16
- package/src/dex/hashflow/hashflow.ts +4 -1
- package/src/dex/synthetix/synthetix-state.ts +2 -2
- package/tests/constants-e2e.ts +0 -26
- package/build/abi/balancer-v2/gyro-e.abi.json +0 -1595
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.d.ts +0 -32
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.js +0 -149
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.js.map +0 -1
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.d.ts +0 -37
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.js +0 -222
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.js.map +0 -1
- package/build/dex/balancer-v2/pools/gyro/gyro-helpers.d.ts +0 -2
- package/build/dex/balancer-v2/pools/gyro/gyro-helpers.js +0 -19
- package/build/dex/balancer-v2/pools/gyro/gyro-helpers.js.map +0 -1
- package/build/dex/balancer-v2/queryOnChain.d.ts +0 -1
- package/build/dex/balancer-v2/queryOnChain.js +0 -40
- package/build/dex/balancer-v2/queryOnChain.js.map +0 -1
- package/src/abi/balancer-v2/gyro-e.abi.json +0 -1595
- package/src/dex/balancer-v2/balancer-v2-gyro3.test.ts +0 -268
- package/src/dex/balancer-v2/balancer-v2-gyroE.test.ts +0 -401
- package/src/dex/balancer-v2/pools/gyro/Gyro3Pool.ts +0 -255
- package/src/dex/balancer-v2/pools/gyro/GyroEPool.ts +0 -403
- package/src/dex/balancer-v2/pools/gyro/gyro-helpers.ts +0 -15
- package/src/dex/balancer-v2/queryOnChain.ts +0 -48
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
AdapterExchangeParam,
|
|
6
6
|
Address,
|
|
7
7
|
ExchangePrices,
|
|
8
|
-
ExchangeTxInfo,
|
|
9
8
|
Log,
|
|
10
9
|
Logger,
|
|
10
|
+
TxInfo,
|
|
11
|
+
PreprocessTransactionOptions,
|
|
12
|
+
ExchangeTxInfo,
|
|
11
13
|
PoolLiquidity,
|
|
12
14
|
PoolPrices,
|
|
13
|
-
PreprocessTransactionOptions,
|
|
14
15
|
SimpleExchangeParam,
|
|
15
16
|
Token,
|
|
16
|
-
TxInfo,
|
|
17
17
|
} from '../../types';
|
|
18
18
|
import {
|
|
19
19
|
ETHER_ADDRESS,
|
|
@@ -29,14 +29,12 @@ import { StablePool } from './pools/stable/StablePool';
|
|
|
29
29
|
import { WeightedPool } from './pools/weighted/WeightedPool';
|
|
30
30
|
import { PhantomStablePool } from './pools/phantom-stable/PhantomStablePool';
|
|
31
31
|
import { LinearPool } from './pools/linear/LinearPool';
|
|
32
|
-
import { Gyro3Pool } from './pools/gyro/Gyro3Pool';
|
|
33
|
-
import { GyroEPool } from './pools/gyro/GyroEPool';
|
|
34
32
|
import VaultABI from '../../abi/balancer-v2/vault.json';
|
|
35
33
|
import DirectSwapABI from '../../abi/DirectSwap.json';
|
|
36
34
|
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
37
35
|
import {
|
|
38
|
-
getBigIntPow,
|
|
39
36
|
getDexKeysWithNetwork,
|
|
37
|
+
getBigIntPow,
|
|
40
38
|
uuidToBytes16,
|
|
41
39
|
} from '../../utils';
|
|
42
40
|
import { IDex } from '../../dex/idex';
|
|
@@ -46,12 +44,12 @@ import {
|
|
|
46
44
|
BalancerPoolTypes,
|
|
47
45
|
BalancerSwap,
|
|
48
46
|
BalancerV2Data,
|
|
49
|
-
BalancerV2DirectParam,
|
|
50
47
|
OptimizedBalancerV2Data,
|
|
51
48
|
PoolState,
|
|
52
49
|
PoolStateCache,
|
|
53
50
|
PoolStateMap,
|
|
54
51
|
SubgraphPoolAddressDictionary,
|
|
52
|
+
BalancerV2DirectParam,
|
|
55
53
|
SubgraphPoolBase,
|
|
56
54
|
SwapTypes,
|
|
57
55
|
} from './types';
|
|
@@ -59,7 +57,7 @@ import {
|
|
|
59
57
|
getLocalDeadlineAsFriendlyPlaceholder,
|
|
60
58
|
SimpleExchange,
|
|
61
59
|
} from '../simple-exchange';
|
|
62
|
-
import {
|
|
60
|
+
import { BalancerConfig, Adapters } from './config';
|
|
63
61
|
import {
|
|
64
62
|
getAllPoolsUsedInPaths,
|
|
65
63
|
isSameAddress,
|
|
@@ -93,8 +91,6 @@ const enabledPoolTypes = [
|
|
|
93
91
|
BalancerPoolTypes.SiloLinear,
|
|
94
92
|
BalancerPoolTypes.TetuLinear,
|
|
95
93
|
BalancerPoolTypes.YearnLinear,
|
|
96
|
-
BalancerPoolTypes.GyroE,
|
|
97
|
-
BalancerPoolTypes.Gyro3,
|
|
98
94
|
];
|
|
99
95
|
|
|
100
96
|
const disabledPoolIds = [
|
|
@@ -190,15 +186,12 @@ const fetchAllPools = `query ($count: Int) {
|
|
|
190
186
|
id
|
|
191
187
|
address
|
|
192
188
|
poolType
|
|
193
|
-
poolTypeVersion
|
|
194
189
|
tokens (orderBy: index) {
|
|
195
190
|
address
|
|
196
191
|
decimals
|
|
197
192
|
}
|
|
198
193
|
mainIndex
|
|
199
194
|
wrappedIndex
|
|
200
|
-
|
|
201
|
-
root3Alpha
|
|
202
195
|
}
|
|
203
196
|
}`;
|
|
204
197
|
// skipping low liquidity composableStablePool (0xbd482ffb3e6e50dc1c437557c3bea2b68f3683ee0000000000000000000003c6) with oracle issues. Experimental.
|
|
@@ -231,23 +224,12 @@ export class BalancerV2EventPool extends StatefulEventSubscriber<PoolStateMap> {
|
|
|
231
224
|
} = {};
|
|
232
225
|
|
|
233
226
|
pools: {
|
|
234
|
-
[type: string]:
|
|
235
|
-
| WeightedPool
|
|
236
|
-
| StablePool
|
|
237
|
-
| LinearPool
|
|
238
|
-
| PhantomStablePool
|
|
239
|
-
| Gyro3Pool
|
|
240
|
-
| GyroEPool;
|
|
227
|
+
[type: string]: WeightedPool | StablePool | LinearPool | PhantomStablePool;
|
|
241
228
|
};
|
|
242
229
|
|
|
243
230
|
public allPools: SubgraphPoolBase[] = [];
|
|
244
231
|
vaultDecoder: (log: Log) => any;
|
|
245
232
|
|
|
246
|
-
buySupportedPoolTypes: BalancerPoolTypes[] = [
|
|
247
|
-
BalancerPoolTypes.Weighted,
|
|
248
|
-
BalancerPoolTypes.GyroE,
|
|
249
|
-
];
|
|
250
|
-
|
|
251
233
|
eventSupportedPoolTypes: BalancerPoolTypes[] = [
|
|
252
234
|
BalancerPoolTypes.Stable,
|
|
253
235
|
BalancerPoolTypes.Weighted,
|
|
@@ -305,8 +287,6 @@ export class BalancerV2EventPool extends StatefulEventSubscriber<PoolStateMap> {
|
|
|
305
287
|
true,
|
|
306
288
|
);
|
|
307
289
|
const linearPool = new LinearPool(this.vaultAddress, this.vaultInterface);
|
|
308
|
-
const gyro3Pool = new Gyro3Pool(this.vaultAddress, this.vaultInterface);
|
|
309
|
-
const gyroEPool = new GyroEPool(this.vaultAddress, this.vaultInterface);
|
|
310
290
|
|
|
311
291
|
this.pools = {};
|
|
312
292
|
this.pools[BalancerPoolTypes.Weighted] = weightedPool;
|
|
@@ -328,10 +308,6 @@ export class BalancerV2EventPool extends StatefulEventSubscriber<PoolStateMap> {
|
|
|
328
308
|
this.pools[BalancerPoolTypes.BeefyLinear] = linearPool;
|
|
329
309
|
// Beets uses "Linear" generically for all linear pool types
|
|
330
310
|
this.pools[BalancerPoolTypes.Linear] = linearPool;
|
|
331
|
-
|
|
332
|
-
this.pools[BalancerPoolTypes.Gyro3] = gyro3Pool;
|
|
333
|
-
this.pools[BalancerPoolTypes.GyroE] = gyroEPool;
|
|
334
|
-
|
|
335
311
|
this.vaultDecoder = (log: Log) => this.vaultInterface.parseLog(log);
|
|
336
312
|
this.addressesSubscribed = [vaultAddress];
|
|
337
313
|
|
|
@@ -387,6 +363,9 @@ export class BalancerV2EventPool extends StatefulEventSubscriber<PoolStateMap> {
|
|
|
387
363
|
return allPools;
|
|
388
364
|
}
|
|
389
365
|
|
|
366
|
+
this.logger.info(
|
|
367
|
+
`Fetching ${this.parentName}_${this.network} Pools from subgraph`,
|
|
368
|
+
);
|
|
390
369
|
const variables = {
|
|
391
370
|
count: MAX_POOL_CNT,
|
|
392
371
|
};
|
|
@@ -422,7 +401,6 @@ export class BalancerV2EventPool extends StatefulEventSubscriber<PoolStateMap> {
|
|
|
422
401
|
this.logger.info(
|
|
423
402
|
`Got ${allPools.length} ${this.parentName}_${this.network} pools from subgraph`,
|
|
424
403
|
);
|
|
425
|
-
|
|
426
404
|
return allPools;
|
|
427
405
|
}
|
|
428
406
|
|
|
@@ -486,7 +464,7 @@ export class BalancerV2EventPool extends StatefulEventSubscriber<PoolStateMap> {
|
|
|
486
464
|
}
|
|
487
465
|
|
|
488
466
|
if (
|
|
489
|
-
|
|
467
|
+
subgraphPool.poolType !== BalancerPoolTypes.Weighted &&
|
|
490
468
|
side === SwapSide.BUY
|
|
491
469
|
) {
|
|
492
470
|
return null;
|
|
@@ -824,7 +802,6 @@ export class BalancerV2
|
|
|
824
802
|
}
|
|
825
803
|
|
|
826
804
|
const allPools = this.getPoolsWithTokenPair(_from, _to);
|
|
827
|
-
|
|
828
805
|
const allowedPools = limitPools
|
|
829
806
|
? allPools.filter(({ address }) =>
|
|
830
807
|
limitPools.includes(`${this.dexKey}_${address.toLowerCase()}`),
|
|
@@ -876,85 +853,72 @@ export class BalancerV2
|
|
|
876
853
|
|
|
877
854
|
const poolPrices = allowedPools
|
|
878
855
|
.map((pool: SubgraphPoolBase) => {
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
);
|
|
856
|
+
const poolAddress = pool.address.toLowerCase();
|
|
857
|
+
|
|
858
|
+
const path = poolGetPathForTokenInOut(
|
|
859
|
+
_from.address,
|
|
860
|
+
_to.address,
|
|
861
|
+
pool,
|
|
862
|
+
this.poolAddressMap,
|
|
863
|
+
side,
|
|
864
|
+
);
|
|
889
865
|
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
for (let i = 0; i < path.length; i++) {
|
|
894
|
-
const poolAddress = path[i].pool.address.toLowerCase();
|
|
895
|
-
const poolState = (eventPoolStates[poolAddress] ||
|
|
896
|
-
nonEventPoolStates[poolAddress]) as PoolState | undefined;
|
|
897
|
-
if (!poolState) {
|
|
898
|
-
this.logger.error(
|
|
899
|
-
`Unable to find the poolState ${poolAddress}`,
|
|
900
|
-
);
|
|
901
|
-
return null;
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
const unitVolume = getBigIntPow(
|
|
905
|
-
(side === SwapSide.SELL ? path[i].tokenIn : path[i].tokenOut)
|
|
906
|
-
.decimals,
|
|
907
|
-
);
|
|
908
|
-
|
|
909
|
-
const res = this.eventPools.getPricesPool(
|
|
910
|
-
path[i].tokenIn,
|
|
911
|
-
path[i].tokenOut,
|
|
912
|
-
path[i].pool,
|
|
913
|
-
poolState,
|
|
914
|
-
pathAmounts,
|
|
915
|
-
unitVolume,
|
|
916
|
-
side,
|
|
917
|
-
);
|
|
918
|
-
|
|
919
|
-
if (!res) {
|
|
920
|
-
return null;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
pathAmounts = res.prices;
|
|
924
|
-
|
|
925
|
-
if (i === path.length - 1) {
|
|
926
|
-
resOut = res;
|
|
927
|
-
}
|
|
928
|
-
}
|
|
866
|
+
let pathAmounts = amounts;
|
|
867
|
+
let resOut: { unit: bigint; prices: bigint[] } | null = null;
|
|
929
868
|
|
|
930
|
-
|
|
869
|
+
for (let i = 0; i < path.length; i++) {
|
|
870
|
+
const poolAddress = path[i].pool.address.toLowerCase();
|
|
871
|
+
const poolState = (eventPoolStates[poolAddress] ||
|
|
872
|
+
nonEventPoolStates[poolAddress]) as PoolState | undefined;
|
|
873
|
+
if (!poolState) {
|
|
874
|
+
this.logger.error(`Unable to find the poolState ${poolAddress}`);
|
|
931
875
|
return null;
|
|
932
876
|
}
|
|
933
877
|
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
// TODO: re-check what should be the current block time stamp
|
|
948
|
-
} catch (e) {
|
|
949
|
-
this.logger.warn(
|
|
950
|
-
`Error_getPrices ${from.symbol || from.address}, ${
|
|
951
|
-
to.symbol || to.address
|
|
952
|
-
}, ${side}, ${pool.address}:`,
|
|
953
|
-
e,
|
|
878
|
+
const unitVolume = getBigIntPow(
|
|
879
|
+
(side === SwapSide.SELL ? path[i].tokenIn : path[i].tokenOut)
|
|
880
|
+
.decimals,
|
|
881
|
+
);
|
|
882
|
+
|
|
883
|
+
const res = this.eventPools.getPricesPool(
|
|
884
|
+
path[i].tokenIn,
|
|
885
|
+
path[i].tokenOut,
|
|
886
|
+
path[i].pool,
|
|
887
|
+
poolState,
|
|
888
|
+
pathAmounts,
|
|
889
|
+
unitVolume,
|
|
890
|
+
side,
|
|
954
891
|
);
|
|
955
892
|
|
|
956
|
-
|
|
893
|
+
if (!res) {
|
|
894
|
+
return null;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
pathAmounts = res.prices;
|
|
898
|
+
|
|
899
|
+
if (i === path.length - 1) {
|
|
900
|
+
resOut = res;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
if (!resOut) {
|
|
905
|
+
return null;
|
|
957
906
|
}
|
|
907
|
+
|
|
908
|
+
return {
|
|
909
|
+
unit: resOut.unit,
|
|
910
|
+
prices: resOut.prices,
|
|
911
|
+
data: {
|
|
912
|
+
poolId: pool.id,
|
|
913
|
+
},
|
|
914
|
+
poolAddresses: [poolAddress],
|
|
915
|
+
exchange: this.dexKey,
|
|
916
|
+
gasCost:
|
|
917
|
+
STABLE_GAS_COST + VARIABLE_GAS_COST_PER_CYCLE * path.length,
|
|
918
|
+
poolIdentifier: `${this.dexKey}_${poolAddress}`,
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
// TODO: re-check what should be the current block time stamp
|
|
958
922
|
})
|
|
959
923
|
.filter(p => !!p);
|
|
960
924
|
return poolPrices as ExchangePrices<BalancerV2Data>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NumberAsString } from '@paraswap/core';
|
|
2
2
|
import { Address } from '../../types';
|
|
3
|
-
import { DerivedGyroEParams, GyroEParams } from '@balancer-labs/sor';
|
|
4
3
|
|
|
5
4
|
// These should match the Balancer Pool types available on Subgraph
|
|
6
5
|
export enum BalancerPoolTypes {
|
|
@@ -21,8 +20,6 @@ export enum BalancerPoolTypes {
|
|
|
21
20
|
SiloLinear = 'SiloLinear',
|
|
22
21
|
TetuLinear = 'TetuLinear',
|
|
23
22
|
YearnLinear = 'YearnLinear',
|
|
24
|
-
Gyro3 = 'Gyro3',
|
|
25
|
-
GyroE = 'GyroE',
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
export type TokenState = {
|
|
@@ -35,10 +32,6 @@ export type PoolState = {
|
|
|
35
32
|
tokens: {
|
|
36
33
|
[address: string]: TokenState;
|
|
37
34
|
};
|
|
38
|
-
tokenRates?: bigint[];
|
|
39
|
-
rateProviders?: string[];
|
|
40
|
-
gyroParams?: GyroEParams;
|
|
41
|
-
gyroDerivedParams?: DerivedGyroEParams;
|
|
42
35
|
swapFee: bigint;
|
|
43
36
|
orderedTokens: string[];
|
|
44
37
|
rate?: bigint;
|
|
@@ -78,31 +71,12 @@ export interface SubgraphPoolBase {
|
|
|
78
71
|
id: string;
|
|
79
72
|
address: string;
|
|
80
73
|
poolType: BalancerPoolTypes;
|
|
81
|
-
poolTypeVersion: number;
|
|
82
74
|
tokens: SubgraphToken[];
|
|
83
75
|
tokensMap: { [tokenAddress: string]: SubgraphToken };
|
|
84
76
|
mainIndex: number;
|
|
85
77
|
wrappedIndex: number;
|
|
86
78
|
|
|
87
79
|
mainTokens: SubgraphMainToken[];
|
|
88
|
-
|
|
89
|
-
// gyro3
|
|
90
|
-
root3Alpha: string;
|
|
91
|
-
// gyroE
|
|
92
|
-
alpha: string;
|
|
93
|
-
beta: string;
|
|
94
|
-
c: string;
|
|
95
|
-
s: string;
|
|
96
|
-
lambda: string;
|
|
97
|
-
tauAlphaX: string;
|
|
98
|
-
tauAlphaY: string;
|
|
99
|
-
tauBetaX: string;
|
|
100
|
-
tauBetaY: string;
|
|
101
|
-
u: string;
|
|
102
|
-
v: string;
|
|
103
|
-
w: string;
|
|
104
|
-
z: string;
|
|
105
|
-
dSq: string;
|
|
106
80
|
}
|
|
107
81
|
|
|
108
82
|
export type BalancerSwapV2 = {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getAddress } from '@ethersproject/address';
|
|
2
2
|
import { Interface, Result } from '@ethersproject/abi';
|
|
3
|
-
import { parseFixed, BigNumber } from '@ethersproject/bignumber';
|
|
4
3
|
import { getBigIntPow } from '../../utils';
|
|
5
4
|
import { BI_POWS } from '../../bigint-constants';
|
|
6
5
|
import { SwapSide } from '../../constants';
|
|
@@ -20,21 +19,6 @@ interface BalancerPathHop {
|
|
|
20
19
|
tokenOut: SubgraphToken;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
/**
|
|
24
|
-
* Parses a fixed-point decimal string into a BigNumber. If we do not have enough decimals to express the number, we truncate it.
|
|
25
|
-
* @param value
|
|
26
|
-
* @param decimals
|
|
27
|
-
* @returns BigNumber
|
|
28
|
-
*/
|
|
29
|
-
export function safeParseFixed(value: string, decimals = 0): BigNumber {
|
|
30
|
-
const [integer, fraction] = value.split('.');
|
|
31
|
-
if (!fraction) {
|
|
32
|
-
return parseFixed(value, decimals);
|
|
33
|
-
}
|
|
34
|
-
const safeValue = integer + '.' + fraction.slice(0, decimals);
|
|
35
|
-
return parseFixed(safeValue, decimals);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
22
|
export const isSameAddress = (address1: string, address2: string): boolean =>
|
|
39
23
|
getAddress(address1) === getAddress(address2);
|
|
40
24
|
|
|
@@ -714,7 +714,7 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
|
|
|
714
714
|
} catch (e) {
|
|
715
715
|
if (
|
|
716
716
|
e instanceof Error &&
|
|
717
|
-
e.message.
|
|
717
|
+
e.message?.toLowerCase().includes('user is restricted')
|
|
718
718
|
) {
|
|
719
719
|
this.logger.warn(
|
|
720
720
|
`${this.dexKey}-${this.network}: Encountered restricted user=${options.txOrigin}. Adding to local blacklist cache`,
|
|
@@ -726,6 +726,9 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
|
|
|
726
726
|
`${this.dexKey}-${this.network}: Market Maker ${mm} failed to build transaction on side ${side} with too strict slippage. Skipping restriction`,
|
|
727
727
|
);
|
|
728
728
|
} else {
|
|
729
|
+
this.logger.warn(
|
|
730
|
+
`${this.dexKey}-${this.network} MM unknown preprocess transaction error: ${e}`,
|
|
731
|
+
);
|
|
729
732
|
await this.restrictMM(mm);
|
|
730
733
|
}
|
|
731
734
|
}
|
|
@@ -407,7 +407,7 @@ export class SynthetixState {
|
|
|
407
407
|
Address,
|
|
408
408
|
bigint,
|
|
409
409
|
bigint,
|
|
410
|
-
...Address[]
|
|
410
|
+
...Address[]
|
|
411
411
|
];
|
|
412
412
|
|
|
413
413
|
const [
|
|
@@ -437,7 +437,7 @@ export class SynthetixState {
|
|
|
437
437
|
Address,
|
|
438
438
|
Address,
|
|
439
439
|
bigint,
|
|
440
|
-
...string[]
|
|
440
|
+
...string[]
|
|
441
441
|
];
|
|
442
442
|
|
|
443
443
|
_require(
|
package/tests/constants-e2e.ts
CHANGED
|
@@ -41,14 +41,6 @@ export const Tokens: {
|
|
|
41
41
|
addBalance: balancesFn,
|
|
42
42
|
addAllowance: allowedFn,
|
|
43
43
|
},
|
|
44
|
-
R: {
|
|
45
|
-
address: '0x183015a9ba6ff60230fdeadc3f43b3d788b13e21',
|
|
46
|
-
decimals: 18,
|
|
47
|
-
},
|
|
48
|
-
sDAI: {
|
|
49
|
-
address: '0x83f20f44975d03b1b09e64809b757c47f942beea',
|
|
50
|
-
decimals: 18,
|
|
51
|
-
},
|
|
52
44
|
CUSDC: {
|
|
53
45
|
address: '0x39AA39c021dfbaE8faC545936693aC917d5E7563',
|
|
54
46
|
decimals: 8,
|
|
@@ -343,10 +335,6 @@ export const Tokens: {
|
|
|
343
335
|
address: '0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6',
|
|
344
336
|
decimals: 19,
|
|
345
337
|
},
|
|
346
|
-
GYD: {
|
|
347
|
-
address: '0xe07f9d810a48ab5c3c914ba3ca53af14e4491e8a',
|
|
348
|
-
decimals: 18,
|
|
349
|
-
},
|
|
350
338
|
},
|
|
351
339
|
[Network.ROPSTEN]: {
|
|
352
340
|
DAI: {
|
|
@@ -477,22 +465,10 @@ export const Tokens: {
|
|
|
477
465
|
address: '0xa3fa99a148fa48d14ed51d610c367c61876997f1',
|
|
478
466
|
decimals: 18,
|
|
479
467
|
},
|
|
480
|
-
BUSD: {
|
|
481
|
-
address: '0x9C9e5fD8bbc25984B178FdCE6117Defa39d2db39',
|
|
482
|
-
decimals: 18,
|
|
483
|
-
},
|
|
484
|
-
TUSD: {
|
|
485
|
-
address: '0x2e1ad108ff1d8c782fcbbb89aad783ac49586756',
|
|
486
|
-
decimals: 18,
|
|
487
|
-
},
|
|
488
468
|
SDEX: {
|
|
489
469
|
address: '0x6899fAcE15c14348E1759371049ab64A3a06bFA6',
|
|
490
470
|
decimals: 18,
|
|
491
471
|
},
|
|
492
|
-
MATICX: {
|
|
493
|
-
address: '0xfa68fb4628dff1028cfec22b4162fccd0d45efb6',
|
|
494
|
-
decimals: 18,
|
|
495
|
-
},
|
|
496
472
|
},
|
|
497
473
|
[Network.FANTOM]: {
|
|
498
474
|
FTM: { address: ETHER_ADDRESS, decimals: 18 },
|
|
@@ -1055,8 +1031,6 @@ export const Holders: {
|
|
|
1055
1031
|
WETH: '0x2fEb1512183545f48f6b9C5b4EbfCaF49CfCa6F3',
|
|
1056
1032
|
USDT: '0x8A446971dbB112f3be15bc38C14D44B94D9E94b9',
|
|
1057
1033
|
XAUT: '0xc4e161e8d8a4bc4ac762ab33a28bbac5474203d7',
|
|
1058
|
-
R: '0xBfe4c9D3235475C138a61f62e9e72FaD94A3303b',
|
|
1059
|
-
sDAI: '0x8846163Fedc6b881526A6B48321601b474D40923',
|
|
1060
1034
|
CVX: '0x0aCA67Fa70B142A3b9bF2eD89A81B40ff85dACdC',
|
|
1061
1035
|
MIM: '0xa046a8660e66d178ee07ec97c585eeb6aa18c26c',
|
|
1062
1036
|
AnkETH: '0xF7260D4ADc48fEefd5a19a9Eb23f9747CeE15C92',
|