@paraswap/dex-lib 2.50.5 → 2.50.6-sdai
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/maker-psm/pot.json +322 -0
- package/build/abi/{angle/stagToken.json → sdai/SavingsDai.abi.json} +177 -263
- package/build/config.js +2 -1
- package/build/config.js.map +1 -1
- package/build/dex/curve-v1-factory/config.js +11 -128
- package/build/dex/curve-v1-factory/config.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +0 -1
- package/build/dex/curve-v1-factory/curve-v1-factory.js +17 -29
- package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-pool-manager.js +0 -1
- package/build/dex/curve-v1-factory/curve-v1-pool-manager.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js +0 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js +1 -4
- package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js +0 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js +0 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js +0 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js +0 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js +0 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/constants.js +0 -10
- package/build/dex/curve-v1-factory/price-handlers/functions/constants.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js +0 -40
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js +0 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js +0 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js +0 -24
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js +0 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js +0 -53
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js +0 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/utils.d.ts +0 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/utils.js +1 -5
- package/build/dex/curve-v1-factory/price-handlers/functions/utils.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/types.d.ts +2 -2
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.d.ts +2 -3
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js +6 -38
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js.map +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/pool-polling-base.js.map +1 -1
- package/build/dex/curve-v1-factory/types.d.ts +2 -11
- package/build/dex/curve-v1-factory/types.js +0 -3
- package/build/dex/curve-v1-factory/types.js.map +1 -1
- package/build/dex/hashflow/constants.d.ts +0 -27
- package/build/dex/hashflow/constants.js +1 -29
- package/build/dex/hashflow/constants.js.map +1 -1
- package/build/dex/hashflow/hashflow.d.ts +2 -3
- package/build/dex/hashflow/hashflow.js +12 -69
- package/build/dex/hashflow/hashflow.js.map +1 -1
- package/build/dex/hashflow/types.d.ts +0 -11
- package/build/dex/hashflow/types.js +0 -9
- package/build/dex/hashflow/types.js.map +1 -1
- package/build/dex/idex.d.ts +1 -1
- package/build/dex/index.d.ts +2 -2
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/pancakeswap-v3/config.js +0 -15
- package/build/dex/pancakeswap-v3/config.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js.map +1 -1
- package/build/dex/sdai/config.d.ts +11 -0
- package/build/dex/sdai/config.js +24 -0
- package/build/dex/sdai/config.js.map +1 -0
- package/build/dex/sdai/constants.d.ts +2 -0
- package/build/dex/sdai/constants.js +6 -0
- package/build/dex/sdai/constants.js.map +1 -0
- package/build/dex/sdai/scripts/validate-state.d.ts +1 -0
- package/build/dex/sdai/scripts/validate-state.js +102 -0
- package/build/dex/sdai/scripts/validate-state.js.map +1 -0
- package/build/dex/sdai/sdai-pool.d.ts +16 -0
- package/build/dex/sdai/sdai-pool.js +85 -0
- package/build/dex/sdai/sdai-pool.js.map +1 -0
- package/build/dex/sdai/sdai.d.ts +51 -0
- package/build/dex/sdai/sdai.js +172 -0
- package/build/dex/sdai/sdai.js.map +1 -0
- package/build/dex/sdai/types.d.ts +21 -0
- package/build/dex/sdai/types.js +11 -0
- package/build/dex/sdai/types.js.map +1 -0
- package/build/dex/sdai/utils.d.ts +4 -0
- package/build/dex/sdai/utils.js +39 -0
- package/build/dex/sdai/utils.js.map +1 -0
- package/build/dex/woo-fi-v2/config.js +4 -4
- package/package.json +1 -1
- package/src/abi/maker-psm/pot.json +322 -0
- package/src/abi/sdai/SavingsDai.abi.json +877 -0
- package/src/abi/uniswap-v3/AlienBaseV3Router.abi.json +52 -0
- package/src/config.ts +2 -1
- package/src/dex/curve-v1-factory/config.ts +11 -128
- package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +1 -123
- package/src/dex/curve-v1-factory/curve-v1-factory-integration.test.ts +0 -392
- package/src/dex/curve-v1-factory/curve-v1-factory.ts +39 -61
- package/src/dex/curve-v1-factory/curve-v1-pool-manager.ts +0 -1
- package/src/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.ts +0 -2
- package/src/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.ts +2 -6
- package/src/dex/curve-v1-factory/price-handlers/functions/_rates.ts +0 -2
- package/src/dex/curve-v1-factory/price-handlers/functions/_xp.ts +0 -2
- package/src/dex/curve-v1-factory/price-handlers/functions/_xp_mem.ts +0 -2
- package/src/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.ts +0 -2
- package/src/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.ts +0 -2
- package/src/dex/curve-v1-factory/price-handlers/functions/constants.ts +0 -11
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D.ts +1 -59
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D_mem.ts +0 -2
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.ts +0 -2
- package/src/dex/curve-v1-factory/price-handlers/functions/get_dy.ts +0 -51
- package/src/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.ts +0 -2
- package/src/dex/curve-v1-factory/price-handlers/functions/get_y.ts +1 -68
- package/src/dex/curve-v1-factory/price-handlers/functions/get_y_D.ts +0 -2
- package/src/dex/curve-v1-factory/price-handlers/functions/utils.ts +0 -4
- package/src/dex/curve-v1-factory/price-handlers/types.ts +1 -8
- package/src/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.ts +18 -71
- package/src/dex/curve-v1-factory/state-polling-pools/pool-polling-base.ts +0 -1
- package/src/dex/curve-v1-factory/types.ts +1 -12
- package/src/dex/hashflow/constants.ts +0 -32
- package/src/dex/hashflow/hashflow.ts +19 -121
- package/src/dex/hashflow/types.ts +2 -20
- package/src/dex/idex.ts +1 -1
- package/src/dex/index.ts +4 -2
- package/src/dex/pancakeswap-v3/config.ts +0 -16
- package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +1 -3
- package/src/dex/sdai/config.ts +28 -0
- package/src/dex/sdai/constants.ts +2 -0
- package/src/dex/sdai/scripts/validate-state.ts +144 -0
- package/src/dex/sdai/sdai-e2e.test.ts +96 -0
- package/src/dex/sdai/sdai-events.test.ts +105 -0
- package/src/dex/sdai/sdai-integration.test.ts +148 -0
- package/src/dex/sdai/sdai-pool.ts +113 -0
- package/src/dex/sdai/sdai.ts +233 -0
- package/src/dex/sdai/types.ts +23 -0
- package/src/dex/sdai/utils.ts +48 -0
- package/src/dex/woo-fi-v2/config.ts +4 -4
- package/tests/constants-e2e.ts +3 -38
- package/tests/utils-e2e.ts +0 -1
- package/build/abi/Redstone.json +0 -739
- package/build/abi/angle-transmuter/MorphoOracle.json +0 -193
- package/build/abi/angle-transmuter/MorphoVault.json +0 -2506
- package/build/abi/angle-transmuter/Pyth.json +0 -1534
- package/build/abi/angle-transmuter/Transmuter.json +0 -1711
- package/build/abi/pharaoh/PharaohPool.abi.json +0 -1582
- package/build/abi/smardex/smardex-factory.json +0 -185
- package/build/abi/smardex/smardex-pool.json +0 -578
- package/build/abi/smardex/smardex-router.json +0 -648
- package/build/abi/trader-joe-v2_1/FactoryABI.json +0 -1208
- package/build/abi/trader-joe-v2_1/PairABI.json +0 -1493
- package/build/abi/trader-joe-v2_1/RouterABI.json +0 -1489
- package/build/abi/trader-joe-v2_1/StateMulticall.json +0 -193
- package/build/abi/wombat/pool.json +0 -1289
- package/build/dex/aave-v2/tokens-avalanche.json +0 -44
- package/build/dex/aave-v2/tokens-mainnet.json +0 -188
- package/build/dex/aave-v2/tokens-polygon.json +0 -44
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.d.ts +0 -55
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.js +0 -183
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.js.map +0 -1
- package/build/dex/angle-staked-stable/angle-staked-stable.d.ts +0 -50
- package/build/dex/angle-staked-stable/angle-staked-stable.js +0 -228
- package/build/dex/angle-staked-stable/angle-staked-stable.js.map +0 -1
- package/build/dex/angle-staked-stable/config.d.ts +0 -4
- package/build/dex/angle-staked-stable/config.js +0 -139
- package/build/dex/angle-staked-stable/config.js.map +0 -1
- package/build/dex/angle-staked-stable/types.d.ts +0 -15
- package/build/dex/angle-staked-stable/types.js +0 -3
- package/build/dex/angle-staked-stable/types.js.map +0 -1
- package/build/dex/angle-transmuter/angle-transmuter-pool.d.ts +0 -61
- package/build/dex/angle-transmuter/angle-transmuter-pool.js +0 -415
- package/build/dex/angle-transmuter/angle-transmuter-pool.js.map +0 -1
- package/build/dex/angle-transmuter/angle-transmuter.d.ts +0 -59
- package/build/dex/angle-transmuter/angle-transmuter.js +0 -262
- package/build/dex/angle-transmuter/angle-transmuter.js.map +0 -1
- package/build/dex/angle-transmuter/backedOracle.d.ts +0 -19
- package/build/dex/angle-transmuter/backedOracle.js +0 -56
- package/build/dex/angle-transmuter/backedOracle.js.map +0 -1
- package/build/dex/angle-transmuter/config.d.ts +0 -4
- package/build/dex/angle-transmuter/config.js +0 -30
- package/build/dex/angle-transmuter/config.js.map +0 -1
- package/build/dex/angle-transmuter/constants.d.ts +0 -77
- package/build/dex/angle-transmuter/constants.js +0 -94
- package/build/dex/angle-transmuter/constants.js.map +0 -1
- package/build/dex/angle-transmuter/morphoOracle.d.ts +0 -42
- package/build/dex/angle-transmuter/morphoOracle.js +0 -179
- package/build/dex/angle-transmuter/morphoOracle.js.map +0 -1
- package/build/dex/angle-transmuter/morphoVault.d.ts +0 -19
- package/build/dex/angle-transmuter/morphoVault.js +0 -78
- package/build/dex/angle-transmuter/morphoVault.js.map +0 -1
- package/build/dex/angle-transmuter/pyth.d.ts +0 -19
- package/build/dex/angle-transmuter/pyth.js +0 -70
- package/build/dex/angle-transmuter/pyth.js.map +0 -1
- package/build/dex/angle-transmuter/redstone.d.ts +0 -20
- package/build/dex/angle-transmuter/redstone.js +0 -73
- package/build/dex/angle-transmuter/redstone.js.map +0 -1
- package/build/dex/angle-transmuter/transmuter.d.ts +0 -52
- package/build/dex/angle-transmuter/transmuter.js +0 -374
- package/build/dex/angle-transmuter/transmuter.js.map +0 -1
- package/build/dex/angle-transmuter/types.d.ts +0 -188
- package/build/dex/angle-transmuter/types.js +0 -33
- package/build/dex/angle-transmuter/types.js.map +0 -1
- package/build/dex/angle-transmuter/utils.d.ts +0 -9
- package/build/dex/angle-transmuter/utils.js +0 -252
- package/build/dex/angle-transmuter/utils.js.map +0 -1
- package/build/dex/smardex/subgraph-queries.d.ts +0 -1
- package/build/dex/smardex/subgraph-queries.js +0 -17
- package/build/dex/smardex/subgraph-queries.js.map +0 -1
- package/build/dex/smardex/usd-reserves.d.ts +0 -23
- package/build/dex/smardex/usd-reserves.js +0 -86
- package/build/dex/smardex/usd-reserves.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/config.d.ts +0 -4
- package/build/dex/trader-joe-v2-1-2/config.js +0 -47
- package/build/dex/trader-joe-v2-1-2/config.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/constants.d.ts +0 -20
- package/build/dex/trader-joe-v2-1-2/constants.js +0 -22
- package/build/dex/trader-joe-v2-1-2/constants.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/math/index.d.ts +0 -37
- package/build/dex/trader-joe-v2-1-2/math/index.js +0 -291
- package/build/dex/trader-joe-v2-1-2/math/index.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.d.ts +0 -60
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js +0 -248
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.d.ts +0 -53
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js +0 -307
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/types.d.ts +0 -82
- package/build/dex/trader-joe-v2-1-2/types.js +0 -9
- package/build/dex/trader-joe-v2-1-2/types.js.map +0 -1
- package/build/dex/trader-joe-v2_1/config.d.ts +0 -4
- package/build/dex/trader-joe-v2_1/config.js +0 -47
- package/build/dex/trader-joe-v2_1/config.js.map +0 -1
- package/build/dex/trader-joe-v2_1/constants.d.ts +0 -20
- package/build/dex/trader-joe-v2_1/constants.js +0 -22
- package/build/dex/trader-joe-v2_1/constants.js.map +0 -1
- package/build/dex/trader-joe-v2_1/math/index.d.ts +0 -37
- package/build/dex/trader-joe-v2_1/math/index.js +0 -291
- package/build/dex/trader-joe-v2_1/math/index.js.map +0 -1
- 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 +0 -384
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js.map +0 -1
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.d.ts +0 -60
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js +0 -247
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js.map +0 -1
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.d.ts +0 -53
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js +0 -307
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js.map +0 -1
- package/build/dex/trader-joe-v2_1/types.d.ts +0 -82
- package/build/dex/trader-joe-v2_1/types.js +0 -9
- package/build/dex/trader-joe-v2_1/types.js.map +0 -1
- package/build/dex/wombat/wombat-pool-poller.d.ts +0 -22
- package/build/dex/wombat/wombat-pool-poller.js +0 -164
- package/build/dex/wombat/wombat-pool-poller.js.map +0 -1
- package/build/dex-helper/Cache.d.ts +0 -31
- package/build/dex-helper/Cache.js +0 -106
- package/build/dex-helper/Cache.js.map +0 -1
- package/build/dex-helper/RedisBatcher.d.ts +0 -20
- package/build/dex-helper/RedisBatcher.js +0 -75
- package/build/dex-helper/RedisBatcher.js.map +0 -1
- package/build/dex-helper/RedisWrapper.d.ts +0 -37
- package/build/dex-helper/RedisWrapper.js +0 -165
- package/build/dex-helper/RedisWrapper.js.map +0 -1
|
@@ -33,14 +33,11 @@ import {
|
|
|
33
33
|
SimpleExchangeParam,
|
|
34
34
|
Token,
|
|
35
35
|
} from '../../types';
|
|
36
|
-
import { getDexKeysWithNetwork
|
|
36
|
+
import { getDexKeysWithNetwork } from '../../utils';
|
|
37
37
|
import { TooStrictSlippageCheckError } from '../generic-rfq/types';
|
|
38
38
|
import { SimpleExchange } from '../simple-exchange';
|
|
39
39
|
import { Adapters, HashflowConfig } from './config';
|
|
40
40
|
import {
|
|
41
|
-
CONSECUTIVE_ERROR_THRESHOLD,
|
|
42
|
-
CONSECUTIVE_ERROR_TIMESPAN_MS,
|
|
43
|
-
ERROR_CODE_TO_RESTRICT_TTL,
|
|
44
41
|
HASHFLOW_API_CLIENT_NAME,
|
|
45
42
|
HASHFLOW_API_MARKET_MAKERS_POLLING_INTERVAL_MS,
|
|
46
43
|
HASHFLOW_API_PRICES_POLLING_INTERVAL_MS,
|
|
@@ -51,12 +48,9 @@ import {
|
|
|
51
48
|
HASHFLOW_MIN_SLIPPAGE_FACTOR_THRESHOLD_FOR_RESTRICTION,
|
|
52
49
|
HASHFLOW_MM_RESTRICT_TTL_S,
|
|
53
50
|
HASHFLOW_PRICES_CACHES_TTL_S,
|
|
54
|
-
UNKNOWN_ERROR_CODE,
|
|
55
51
|
} from './constants';
|
|
56
52
|
import { RateFetcher } from './rate-fetcher';
|
|
57
53
|
import {
|
|
58
|
-
CacheErrorCodesData,
|
|
59
|
-
ErrorCode,
|
|
60
54
|
HashflowData,
|
|
61
55
|
PriceLevel,
|
|
62
56
|
RfqError,
|
|
@@ -75,7 +69,6 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
|
|
|
75
69
|
private hashFlowAuthToken: string;
|
|
76
70
|
private disabledMMs: Set<string>;
|
|
77
71
|
private runtimeMMsRestrictHashMapKey: string;
|
|
78
|
-
private runtimeMMsRestrictHashMapErrorCodesKey: string;
|
|
79
72
|
|
|
80
73
|
private pricesCacheKey: string;
|
|
81
74
|
private marketMakersCacheKey: string;
|
|
@@ -115,8 +108,6 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
|
|
|
115
108
|
this.disabledMMs = new Set(dexHelper.config.data.hashFlowDisabledMMs);
|
|
116
109
|
this.runtimeMMsRestrictHashMapKey =
|
|
117
110
|
`${CACHE_PREFIX}_${this.dexKey}_${this.network}_restricted_mms`.toLowerCase();
|
|
118
|
-
this.runtimeMMsRestrictHashMapErrorCodesKey =
|
|
119
|
-
`${CACHE_PREFIX}_${this.dexKey}_${this.network}_restricted_mms_error_codes`.toLowerCase();
|
|
120
111
|
|
|
121
112
|
this.rateFetcher = new RateFetcher(
|
|
122
113
|
this.dexHelper,
|
|
@@ -604,7 +595,7 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
|
|
|
604
595
|
normalizedDestToken.address,
|
|
605
596
|
)}: ${JSON.stringify(rfq)}`;
|
|
606
597
|
this.logger.warn(message);
|
|
607
|
-
throw new RfqError(message
|
|
598
|
+
throw new RfqError(message);
|
|
608
599
|
} else if (!rfq.quotes[0].quoteData) {
|
|
609
600
|
const message = `${this.dexKey}-${
|
|
610
601
|
this.network
|
|
@@ -613,7 +604,7 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
|
|
|
613
604
|
normalizedDestToken.address,
|
|
614
605
|
)}. Missing quote data`;
|
|
615
606
|
this.logger.warn(message);
|
|
616
|
-
throw new RfqError(message
|
|
607
|
+
throw new RfqError(message);
|
|
617
608
|
} else if (!rfq.quotes[0].signature) {
|
|
618
609
|
const message = `${this.dexKey}-${
|
|
619
610
|
this.network
|
|
@@ -622,7 +613,7 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
|
|
|
622
613
|
normalizedDestToken.address,
|
|
623
614
|
)}. Missing signature`;
|
|
624
615
|
this.logger.warn(message);
|
|
625
|
-
throw new RfqError(message
|
|
616
|
+
throw new RfqError(message);
|
|
626
617
|
}
|
|
627
618
|
|
|
628
619
|
assert(
|
|
@@ -738,13 +729,7 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
|
|
|
738
729
|
this.logger.warn(
|
|
739
730
|
`${this.dexKey}-${this.network} MM unknown preprocess transaction error: ${e}`,
|
|
740
731
|
);
|
|
741
|
-
|
|
742
|
-
e instanceof RfqError || e instanceof SlippageCheckError
|
|
743
|
-
? e?.code || UNKNOWN_ERROR_CODE
|
|
744
|
-
: UNKNOWN_ERROR_CODE;
|
|
745
|
-
await this.restrictMM(mm, code).catch(err =>
|
|
746
|
-
this.logger.warn(`Failed to restrict MM ${mm}: ${err}`),
|
|
747
|
-
);
|
|
732
|
+
await this.restrictMM(mm);
|
|
748
733
|
}
|
|
749
734
|
}
|
|
750
735
|
|
|
@@ -752,111 +737,24 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
|
|
|
752
737
|
}
|
|
753
738
|
}
|
|
754
739
|
|
|
755
|
-
async restrictMM(mm: string
|
|
756
|
-
|
|
757
|
-
this.
|
|
758
|
-
mm,
|
|
740
|
+
async restrictMM(mm: string): Promise<void> {
|
|
741
|
+
this.logger.warn(
|
|
742
|
+
`${this.dexKey}-${this.network}: ${mm} was restricted for ${HASHFLOW_MM_RESTRICT_TTL_S} sec. due to fails`,
|
|
759
743
|
);
|
|
760
744
|
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
745
|
+
// We use timestamp for creation date to later discern if it already expired or not
|
|
746
|
+
await this.dexHelper.cache.hset(
|
|
747
|
+
this.runtimeMMsRestrictHashMapKey,
|
|
748
|
+
mm,
|
|
749
|
+
Date.now().toString(),
|
|
750
|
+
);
|
|
764
751
|
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
this.logger.warn(
|
|
770
|
-
`${this.dexKey}-${this.network}: First encounter of error code=${errorCode} for ${mm} OR error ocurred outside of threshold, setting up counter`,
|
|
771
|
-
);
|
|
772
|
-
const data: CacheErrorCodesData = {
|
|
773
|
-
...errorCodes,
|
|
774
|
-
[errorCode]: {
|
|
775
|
-
count: 1,
|
|
776
|
-
addedDatetimeMS: Date.now(),
|
|
777
|
-
},
|
|
778
|
-
};
|
|
779
|
-
await this.dexHelper.cache.hset(
|
|
780
|
-
this.runtimeMMsRestrictHashMapErrorCodesKey,
|
|
781
|
-
mm,
|
|
782
|
-
Utils.Serialize(data),
|
|
752
|
+
// Expiry cache because it has levels for blacklisted MM
|
|
753
|
+
this.dexHelper.cache.del(this.dexKey, this.network, 'levels').catch(e => {
|
|
754
|
+
this.logger.error(
|
|
755
|
+
`${this.dexKey}-${this.network}: Failed to delete levels cache: ${e.message}`,
|
|
783
756
|
);
|
|
784
|
-
|
|
785
|
-
} else {
|
|
786
|
-
const restrictTTLMs =
|
|
787
|
-
ERROR_CODE_TO_RESTRICT_TTL[errorCode] ||
|
|
788
|
-
ERROR_CODE_TO_RESTRICT_TTL[UNKNOWN_ERROR_CODE];
|
|
789
|
-
|
|
790
|
-
if (error.count + 1 > CONSECUTIVE_ERROR_THRESHOLD) {
|
|
791
|
-
this.logger.warn(
|
|
792
|
-
`${this.dexKey}-${this.network}: ${mm} was restricted for ${
|
|
793
|
-
restrictTTLMs / 1000
|
|
794
|
-
} sec. due to ${errorCode} happening ${
|
|
795
|
-
error.count + 1
|
|
796
|
-
} times within last ${Math.floor(
|
|
797
|
-
CONSECUTIVE_ERROR_TIMESPAN_MS / 1000 / 60,
|
|
798
|
-
)} minutes`,
|
|
799
|
-
);
|
|
800
|
-
|
|
801
|
-
// date added is checked against HASHFLOW_MM_RESTRICT_TTL_S, as a hack we set a date so that it's checked against specific ttls based on error type to not change parsing logic for mms
|
|
802
|
-
//
|
|
803
|
-
// Example1: ttl for a particular error is 20 minutes (< default 60 minutes)
|
|
804
|
-
// Meaning we need to set `addedDatetimeMS` for restrict hash as Date.now() - 40 minutes (diff between default restrict ttl=1h and particular error restrict ttl = 20 minutes). So the `addedDatetimeMS` is in the past, and after 20 minutes mm will not be considered as restricted
|
|
805
|
-
//
|
|
806
|
-
// Example 2: ttl for a particular error is 80 minutes (> default 60 minutes)
|
|
807
|
-
// Meaning we need to set `addedDatetimeMS` for restrict hash as Date.now() + 20 minutes (in the future), then after an hour (default) it'll still be 20 minutes left for restriction to be cleared
|
|
808
|
-
|
|
809
|
-
const defaultRestrictTTLMS = Math.floor(
|
|
810
|
-
HASHFLOW_MM_RESTRICT_TTL_S * 1000,
|
|
811
|
-
);
|
|
812
|
-
const dateModifierMS =
|
|
813
|
-
defaultRestrictTTLMS > restrictTTLMs
|
|
814
|
-
? -(defaultRestrictTTLMS - restrictTTLMs)
|
|
815
|
-
: restrictTTLMs - defaultRestrictTTLMS;
|
|
816
|
-
|
|
817
|
-
const date = (Date.now() + dateModifierMS).toString();
|
|
818
|
-
|
|
819
|
-
// We use timestamp for creation date to later discern if it already expired or not
|
|
820
|
-
await this.dexHelper.cache.hset(
|
|
821
|
-
this.runtimeMMsRestrictHashMapKey,
|
|
822
|
-
mm,
|
|
823
|
-
date,
|
|
824
|
-
);
|
|
825
|
-
|
|
826
|
-
// resetting error count
|
|
827
|
-
const data: CacheErrorCodesData = {
|
|
828
|
-
...errorCodes,
|
|
829
|
-
[errorCode]: {
|
|
830
|
-
count: 1,
|
|
831
|
-
addedDatetimeMS: Date.now(),
|
|
832
|
-
},
|
|
833
|
-
};
|
|
834
|
-
await this.dexHelper.cache.hset(
|
|
835
|
-
this.runtimeMMsRestrictHashMapErrorCodesKey,
|
|
836
|
-
mm,
|
|
837
|
-
Utils.Serialize(data),
|
|
838
|
-
);
|
|
839
|
-
|
|
840
|
-
return;
|
|
841
|
-
} else {
|
|
842
|
-
const newCount = +error.count + 1;
|
|
843
|
-
this.logger.warn(
|
|
844
|
-
`${this.dexKey}-${this.network}: ${mm} Error with code: ${errorCode} happened ${newCount} times (below or equal to the limit: ${CONSECUTIVE_ERROR_THRESHOLD}), updating counter`,
|
|
845
|
-
);
|
|
846
|
-
const data: CacheErrorCodesData = {
|
|
847
|
-
...errorCodes,
|
|
848
|
-
[errorCode]: {
|
|
849
|
-
count: newCount,
|
|
850
|
-
addedDatetimeMS: error.addedDatetimeMS, // initial date stays
|
|
851
|
-
},
|
|
852
|
-
};
|
|
853
|
-
await this.dexHelper.cache.hset(
|
|
854
|
-
this.runtimeMMsRestrictHashMapErrorCodesKey,
|
|
855
|
-
mm,
|
|
856
|
-
Utils.Serialize(data),
|
|
857
|
-
);
|
|
858
|
-
}
|
|
859
|
-
}
|
|
757
|
+
});
|
|
860
758
|
}
|
|
861
759
|
|
|
862
760
|
getCalldataGasCost(poolPrices: PoolPrices<HashflowData>): number | number[] {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Chain, QuoteData } from '@hashflow/taker-js/dist/types/common';
|
|
2
2
|
import { RequestHeaders } from '../../dex-helper';
|
|
3
|
-
import { ERROR_CODE_TO_RESTRICT_TTL, UNKNOWN_ERROR_CODE } from './constants';
|
|
4
3
|
|
|
5
4
|
export type HashflowData = {
|
|
6
5
|
mm: string;
|
|
@@ -17,22 +16,14 @@ export interface PriceLevel {
|
|
|
17
16
|
p: string;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
export class RfqError extends Error {
|
|
21
|
-
code: ErrorCode;
|
|
22
|
-
constructor(message: string, code: ErrorCode = UNKNOWN_ERROR_CODE) {
|
|
23
|
-
super(message);
|
|
24
|
-
this.code = code;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
19
|
+
export class RfqError extends Error {}
|
|
27
20
|
|
|
28
21
|
export enum RFQType {
|
|
29
22
|
RFQT = 0,
|
|
30
23
|
RFQM = 1,
|
|
31
24
|
}
|
|
32
25
|
|
|
33
|
-
export class SlippageCheckError extends Error {
|
|
34
|
-
code: ErrorCode = 'SLIPPAGE';
|
|
35
|
-
}
|
|
26
|
+
export class SlippageCheckError extends Error {}
|
|
36
27
|
|
|
37
28
|
export type HashflowRatesLevel = {
|
|
38
29
|
pair: Record<string, string>;
|
|
@@ -72,12 +63,3 @@ export type HashflowRateFetcherConfig = {
|
|
|
72
63
|
marketMakersCacheTTLSecs: number;
|
|
73
64
|
};
|
|
74
65
|
};
|
|
75
|
-
|
|
76
|
-
export type ErrorCode = keyof typeof ERROR_CODE_TO_RESTRICT_TTL;
|
|
77
|
-
|
|
78
|
-
export type CacheErrorCodesData = {
|
|
79
|
-
[code in ErrorCode]: {
|
|
80
|
-
addedDatetimeMS: number;
|
|
81
|
-
count: number;
|
|
82
|
-
} | null;
|
|
83
|
-
};
|
package/src/dex/idex.ts
CHANGED
|
@@ -194,7 +194,7 @@ export interface IDex<
|
|
|
194
194
|
IDexPooltracker {}
|
|
195
195
|
|
|
196
196
|
// Defines the static objects of the IDex class
|
|
197
|
-
export interface
|
|
197
|
+
export interface DexContructor<
|
|
198
198
|
ExchangeData,
|
|
199
199
|
DirectParam = null,
|
|
200
200
|
OptimizedExchangeData = ExchangeData,
|
package/src/dex/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { UnoptimizedRate } from '../types';
|
|
3
3
|
import { CurveV2 } from './curve-v2';
|
|
4
|
-
import { IDexTxBuilder,
|
|
4
|
+
import { IDexTxBuilder, DexContructor, IDex, IRouteOptimizer } from './idex';
|
|
5
5
|
import { Jarvis } from './jarvis';
|
|
6
6
|
import { JarvisV6 } from './jarvis-v6/jarvis-v6';
|
|
7
7
|
import { StablePool } from './stable-pool';
|
|
@@ -87,6 +87,7 @@ import { Wombat } from './wombat/wombat';
|
|
|
87
87
|
import { Swell } from './swell/swell';
|
|
88
88
|
import { PharaohV1 } from './solidly/forks-override/pharaohV1';
|
|
89
89
|
import { EtherFi } from './etherfi';
|
|
90
|
+
import { SDai } from './sdai/sdai';
|
|
90
91
|
|
|
91
92
|
const LegacyDexes = [
|
|
92
93
|
CurveV2,
|
|
@@ -170,6 +171,7 @@ const Dexes = [
|
|
|
170
171
|
Wombat,
|
|
171
172
|
Swell,
|
|
172
173
|
PharaohV1,
|
|
174
|
+
SDai,
|
|
173
175
|
];
|
|
174
176
|
|
|
175
177
|
export type LegacyDexConstructor = new (dexHelper: IDexHelper) => IDexTxBuilder<
|
|
@@ -183,7 +185,7 @@ interface IGetDirectFunctionName {
|
|
|
183
185
|
|
|
184
186
|
export class DexAdapterService {
|
|
185
187
|
dexToKeyMap: {
|
|
186
|
-
[key: string]: LegacyDexConstructor |
|
|
188
|
+
[key: string]: LegacyDexConstructor | DexContructor<any, any, any>;
|
|
187
189
|
} = {};
|
|
188
190
|
directFunctionsNames: string[];
|
|
189
191
|
dexInstances: {
|
|
@@ -69,22 +69,6 @@ export const PancakeswapV3Config: DexConfigMap<DexParams> = {
|
|
|
69
69
|
'https://api.studio.thegraph.com/query/45376/exchange-v3-base/version/latest',
|
|
70
70
|
},
|
|
71
71
|
},
|
|
72
|
-
DackieSwapV3: {
|
|
73
|
-
[Network.BASE]: {
|
|
74
|
-
factory: '0x3D237AC6D2f425D2E890Cc99198818cc1FA48870',
|
|
75
|
-
quoter: '0x4fDBD73aD4B1DDde594BF05497C15f76308eFfb9',
|
|
76
|
-
deployer: '0x4f205D69834f9B101b9289F7AFFAc9B77B3fF9b7',
|
|
77
|
-
router: '0x4030ebafeb76e5fc848891076dfe315993800ba5',
|
|
78
|
-
supportedFees: [10000n, 2500n, 500n, 100n],
|
|
79
|
-
stateMulticall: '0xeBF40A40CA3D4310Bf53048F48e860656e1D7C81',
|
|
80
|
-
uniswapMulticall: '0x091e99cb1C49331a94dD62755D168E941AbD0693',
|
|
81
|
-
chunksCount: 10,
|
|
82
|
-
initRetryFrequency: 10,
|
|
83
|
-
initHash: `0x6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2`,
|
|
84
|
-
subgraphURL:
|
|
85
|
-
'https://api.studio.thegraph.com/query/50473/exchange-clmm/version/latest',
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
72
|
};
|
|
89
73
|
|
|
90
74
|
export const Adapters: Record<number, AdapterMappings> = {
|
|
@@ -87,9 +87,7 @@ export class PancakeswapV3
|
|
|
87
87
|
intervalTask?: NodeJS.Timeout;
|
|
88
88
|
|
|
89
89
|
public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
|
|
90
|
-
getDexKeysWithNetwork(
|
|
91
|
-
_.pick(PancakeswapV3Config, ['PancakeswapV3', 'DackieSwapV3']),
|
|
92
|
-
);
|
|
90
|
+
getDexKeysWithNetwork(_.pick(PancakeswapV3Config, ['PancakeswapV3']));
|
|
93
91
|
|
|
94
92
|
logger: Logger;
|
|
95
93
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SDaiParams } from './types';
|
|
2
|
+
import { DexConfigMap } from '../../types';
|
|
3
|
+
import { Network } from '../../constants';
|
|
4
|
+
import { SwapSide } from '@paraswap/core';
|
|
5
|
+
|
|
6
|
+
export const SDaiConfig: DexConfigMap<SDaiParams> = {
|
|
7
|
+
SDai: {
|
|
8
|
+
[Network.MAINNET]: {
|
|
9
|
+
sdaiAddress: '0x83F20F44975D03b1b09e64809B757c47f942BEeA',
|
|
10
|
+
daiAddress: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
|
11
|
+
potAddress: '0x197E90f9FAD81970bA7976f33CbD77088E5D7cf7',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const Adapters: {
|
|
17
|
+
[chainId: number]: {
|
|
18
|
+
[side: string]: { name: string; index: number }[];
|
|
19
|
+
};
|
|
20
|
+
} = {
|
|
21
|
+
[Network.MAINNET]: {
|
|
22
|
+
// TODO: uncomment this when SDAI integration got deployed
|
|
23
|
+
// [SwapSide.SELL]: [{ name: 'Adapter06', index: 2 }],
|
|
24
|
+
// [SwapSide.BUY]: [{ name: 'BuyAdapter02', index: 5 }],
|
|
25
|
+
[SwapSide.SELL]: [{ name: 'Adapter06', index: 1 }],
|
|
26
|
+
[SwapSide.BUY]: [{ name: 'BuyAdapter02', index: 4 }],
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
|
|
5
|
+
import { Network } from '../../../constants';
|
|
6
|
+
import { DummyDexHelper } from '../../../dex-helper';
|
|
7
|
+
import { SDaiPoolState } from '../types';
|
|
8
|
+
import { BlockHeader } from 'web3-eth';
|
|
9
|
+
import { ethers } from 'ethers';
|
|
10
|
+
import { SDai } from '../sdai';
|
|
11
|
+
import { SDaiConfig } from '../config';
|
|
12
|
+
import { getOnChainState } from '../utils';
|
|
13
|
+
import { Interface } from '@ethersproject/abi';
|
|
14
|
+
import PotAbi from '../../../abi/maker-psm/pot.json';
|
|
15
|
+
|
|
16
|
+
const network = Network.MAINNET;
|
|
17
|
+
const dexKey = 'SDai';
|
|
18
|
+
|
|
19
|
+
const { potAddress } = SDaiConfig[dexKey][network];
|
|
20
|
+
const blockHeaders: Record<number, BlockHeader> = {};
|
|
21
|
+
|
|
22
|
+
const dexHelper = new DummyDexHelper(network);
|
|
23
|
+
const logger = dexHelper.getLogger(dexKey);
|
|
24
|
+
|
|
25
|
+
function preprocessField(value: any): string {
|
|
26
|
+
if (
|
|
27
|
+
typeof value === 'bigint' ||
|
|
28
|
+
typeof value === 'number' ||
|
|
29
|
+
ethers.BigNumber.isBigNumber(value)
|
|
30
|
+
) {
|
|
31
|
+
return value.toString();
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function compareAndLogDifferences<T extends object, Y extends object>(
|
|
37
|
+
obj1: T,
|
|
38
|
+
obj2: Y,
|
|
39
|
+
keyNames: Array<keyof T & keyof Y>,
|
|
40
|
+
checkEachKey = false,
|
|
41
|
+
) {
|
|
42
|
+
let isValid = true;
|
|
43
|
+
let keys = keyNames;
|
|
44
|
+
|
|
45
|
+
if (checkEachKey) {
|
|
46
|
+
// find common keys
|
|
47
|
+
const keys1 = Object.keys(obj1);
|
|
48
|
+
const keys2 = new Set(Object.keys(obj2));
|
|
49
|
+
keys = keys1.filter(key => keys2.has(key)) as Array<keyof T & keyof Y>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
for (let fieldName of keys) {
|
|
53
|
+
const value1 = preprocessField(obj1[fieldName]);
|
|
54
|
+
const value2 = preprocessField(obj2[fieldName]);
|
|
55
|
+
|
|
56
|
+
if (value1 !== value2) {
|
|
57
|
+
console.log(
|
|
58
|
+
`${fieldName.toString()} mismatch: actual: ${value1} vs pool: ${value2}`,
|
|
59
|
+
);
|
|
60
|
+
isValid = false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return isValid;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function isPoolStateEqualToReal(
|
|
68
|
+
state: SDaiPoolState,
|
|
69
|
+
blockNumber: number,
|
|
70
|
+
) {
|
|
71
|
+
const expected = await getOnChainState(
|
|
72
|
+
dexHelper.multiContract,
|
|
73
|
+
potAddress,
|
|
74
|
+
new Interface(PotAbi),
|
|
75
|
+
blockNumber,
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const isValidState = compareAndLogDifferences(state, expected, [
|
|
79
|
+
'rho',
|
|
80
|
+
'dsr',
|
|
81
|
+
'dsr',
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
return isValidState;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function checkPoolStateForBlockRange(
|
|
88
|
+
startBlockNumber: number,
|
|
89
|
+
endBlockNumber: number,
|
|
90
|
+
): Promise<boolean> {
|
|
91
|
+
const network = Network.MAINNET;
|
|
92
|
+
const dexKey = 'SDai';
|
|
93
|
+
const dexHelper = new DummyDexHelper(network);
|
|
94
|
+
|
|
95
|
+
const sdai = new SDai(network, dexKey, dexHelper);
|
|
96
|
+
const pool = await sdai.eventPool;
|
|
97
|
+
|
|
98
|
+
const logsToDispatch = await dexHelper.provider.getLogs({
|
|
99
|
+
fromBlock: startBlockNumber,
|
|
100
|
+
toBlock: endBlockNumber,
|
|
101
|
+
address: potAddress,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
console.log(logsToDispatch.length);
|
|
105
|
+
|
|
106
|
+
// group logs by block number
|
|
107
|
+
const logsByBlockNumber: Record<number, any[]> = {};
|
|
108
|
+
for (let log of logsToDispatch) {
|
|
109
|
+
if (!logsByBlockNumber[log.blockNumber]) {
|
|
110
|
+
logsByBlockNumber[log.blockNumber] = [];
|
|
111
|
+
}
|
|
112
|
+
logsByBlockNumber[log.blockNumber].push(log);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const sortedBlocks = Object.keys(logsByBlockNumber)
|
|
116
|
+
.map(Number)
|
|
117
|
+
.sort((a, b) => Number(a) - Number(b));
|
|
118
|
+
|
|
119
|
+
for (let blockNumber of sortedBlocks) {
|
|
120
|
+
if (!blockHeaders[blockNumber]) {
|
|
121
|
+
blockHeaders[blockNumber] = await dexHelper.web3Provider.eth.getBlock(
|
|
122
|
+
blockNumber,
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
await pool?.update(logsByBlockNumber[blockNumber], {
|
|
127
|
+
[blockNumber]: blockHeaders[blockNumber],
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const state = pool?.getState(startBlockNumber) as SDaiPoolState;
|
|
132
|
+
return isPoolStateEqualToReal(state, endBlockNumber);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function main() {
|
|
136
|
+
// use findBreakingBlock to find the block where the state is broken
|
|
137
|
+
// console.log(await findBreakingBlock(startBlockNumber, endBlockNumber));
|
|
138
|
+
// previously broken block 150502863
|
|
139
|
+
console.log(await checkPoolStateForBlockRange(19199247 - 10000, 19199247));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
main()
|
|
143
|
+
.then(() => console.log('Done'))
|
|
144
|
+
.catch(e => console.error(e));
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
dotenv.config();
|
|
3
|
+
|
|
4
|
+
import { testE2E } from '../../../tests/utils-e2e';
|
|
5
|
+
import { Tokens, Holders } from '../../../tests/constants-e2e';
|
|
6
|
+
import { Network, ContractMethod, SwapSide } from '../../constants';
|
|
7
|
+
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
8
|
+
import { generateConfig } from '../../config';
|
|
9
|
+
|
|
10
|
+
function testForNetwork(
|
|
11
|
+
network: Network,
|
|
12
|
+
dexKey: string,
|
|
13
|
+
tokenASymbol: string,
|
|
14
|
+
tokenBSymbol: string,
|
|
15
|
+
tokenAAmount: string,
|
|
16
|
+
tokenBAmount: string,
|
|
17
|
+
) {
|
|
18
|
+
const provider = new StaticJsonRpcProvider(
|
|
19
|
+
generateConfig(network).privateHttpProvider,
|
|
20
|
+
network,
|
|
21
|
+
);
|
|
22
|
+
const tokens = Tokens[network];
|
|
23
|
+
const holders = Holders[network];
|
|
24
|
+
|
|
25
|
+
const sideToContractMethods = new Map([
|
|
26
|
+
[
|
|
27
|
+
SwapSide.SELL,
|
|
28
|
+
[
|
|
29
|
+
ContractMethod.simpleSwap,
|
|
30
|
+
ContractMethod.multiSwap,
|
|
31
|
+
ContractMethod.megaSwap,
|
|
32
|
+
],
|
|
33
|
+
],
|
|
34
|
+
[SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
describe(`${network}`, () => {
|
|
38
|
+
sideToContractMethods.forEach((contractMethods, side) =>
|
|
39
|
+
describe(`${side}`, () => {
|
|
40
|
+
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
41
|
+
describe(`${contractMethod}`, () => {
|
|
42
|
+
it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
|
|
43
|
+
await testE2E(
|
|
44
|
+
tokens[tokenASymbol],
|
|
45
|
+
tokens[tokenBSymbol],
|
|
46
|
+
holders[tokenASymbol],
|
|
47
|
+
side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
|
|
48
|
+
side,
|
|
49
|
+
dexKey,
|
|
50
|
+
contractMethod,
|
|
51
|
+
network,
|
|
52
|
+
provider,
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
|
|
56
|
+
await testE2E(
|
|
57
|
+
tokens[tokenBSymbol],
|
|
58
|
+
tokens[tokenASymbol],
|
|
59
|
+
holders[tokenBSymbol],
|
|
60
|
+
side === SwapSide.SELL ? tokenBAmount : tokenAAmount,
|
|
61
|
+
side,
|
|
62
|
+
dexKey,
|
|
63
|
+
contractMethod,
|
|
64
|
+
network,
|
|
65
|
+
provider,
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
describe('sDAI E2E', () => {
|
|
76
|
+
const dexKey = 'sdai';
|
|
77
|
+
|
|
78
|
+
describe('Mainnet', () => {
|
|
79
|
+
const network = Network.MAINNET;
|
|
80
|
+
|
|
81
|
+
const tokenASymbol: string = 'DAI';
|
|
82
|
+
const tokenBSymbol: string = 'sDAI';
|
|
83
|
+
|
|
84
|
+
const tokenAAmount: string = '1000000000000000000';
|
|
85
|
+
const tokenBAmount: string = '1000000000000000000';
|
|
86
|
+
|
|
87
|
+
testForNetwork(
|
|
88
|
+
network,
|
|
89
|
+
dexKey,
|
|
90
|
+
tokenASymbol,
|
|
91
|
+
tokenBSymbol,
|
|
92
|
+
tokenAAmount,
|
|
93
|
+
tokenBAmount,
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
});
|