@paraswap/dex-lib 2.28.9-take-surplus.0 → 2.28.9-take-surplus.1
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/RamsesV2StateMulticall.abi.json +891 -0
- package/build/abi/aerodrome/aerodrome-pool-factory.json +586 -0
- package/build/abi/algebra/AlgebraFactory-v1_1.abi.json +250 -0
- package/build/abi/api3-proxy.json +53 -0
- package/build/abi/api3-server-v1.json +463 -0
- package/build/abi/nomiswap-v2/nomiswap-v2-pool.json +773 -0
- package/build/abi/pancakeswap-v3/PancakeswapV3Factory.abi.json +300 -0
- package/build/abi/quick-perps/fast-price-events.json +70 -0
- package/build/abi/quick-perps/fast-price-feed.json +741 -0
- package/build/abi/quick-perps/reader.json +313 -0
- package/build/abi/quick-perps/vault-price-feed.json +323 -0
- package/build/abi/quick-perps/vault.json +1953 -0
- package/build/abi/quickPerps/fast-price-events.json +70 -0
- package/build/abi/quickPerps/fast-price-feed.json +748 -0
- package/build/abi/quickPerps/reader.json +313 -0
- package/build/abi/quickPerps/vault-price-feed.json +477 -0
- package/build/abi/quickPerps/vault.json +1953 -0
- package/build/abi/ramses-v2/RamsesV2Pool.abi.json +1599 -0
- package/build/abi/uniswap-v3/UniswapV3Factory.abi.json +148 -0
- package/build/abi/uniswap-v3/UniswapV3QuoterV2.abi.json +155 -0
- package/build/composed-event-subscriber.js +8 -2
- package/build/composed-event-subscriber.js.map +1 -1
- package/build/config.d.ts +0 -1
- package/build/config.js +75 -14
- package/build/config.js.map +1 -1
- package/build/constants.d.ts +2 -1
- package/build/constants.js +1 -0
- package/build/constants.js.map +1 -1
- package/build/dex/algebra/algebra-factory.d.ts +25 -0
- package/build/dex/algebra/algebra-factory.js +43 -0
- package/build/dex/algebra/algebra-factory.js.map +1 -0
- package/build/dex/algebra/algebra-pool-v1_1.d.ts +16 -2
- package/build/dex/algebra/algebra-pool-v1_1.js +166 -4
- package/build/dex/algebra/algebra-pool-v1_1.js.map +1 -1
- package/build/dex/algebra/algebra.d.ts +4 -1
- package/build/dex/algebra/algebra.js +42 -21
- package/build/dex/algebra/algebra.js.map +1 -1
- package/build/dex/algebra/config.js +1 -0
- package/build/dex/algebra/config.js.map +1 -1
- package/build/dex/algebra/lib/TickTable.js +51 -40
- package/build/dex/algebra/lib/TickTable.js.map +1 -1
- package/build/dex/algebra/types.d.ts +5 -2
- package/build/dex/algebra/utils.d.ts +3 -1
- package/build/dex/algebra/utils.js +59 -1
- package/build/dex/algebra/utils.js.map +1 -1
- package/build/dex/balancer-v2/balancer-v2.js +79 -6
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/balancer-v2/config.js +10 -2
- package/build/dex/balancer-v2/config.js.map +1 -1
- package/build/dex/balancer-v2/optimizer.js +38 -51
- package/build/dex/balancer-v2/optimizer.js.map +1 -1
- package/build/dex/balancer-v2/types.d.ts +0 -4
- package/build/dex/balancer-v2/types.js.map +1 -1
- package/build/dex/curve-v1/config.js +40 -38
- package/build/dex/curve-v1/config.js.map +1 -1
- package/build/dex/curve-v1-factory/config.js +17 -9
- package/build/dex/curve-v1-factory/config.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +1 -1
- package/build/dex/curve-v1-factory/curve-v1-factory.js +205 -182
- package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-pool-manager.d.ts +2 -1
- package/build/dex/curve-v1-factory/curve-v1-pool-manager.js +8 -2
- 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 +1 -0
- 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 -0
- 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 +2 -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 +1 -0
- 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 +1 -0
- 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 +61 -14
- 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 +1 -0
- 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 +10 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- 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 +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js.map +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.js +11 -4
- package/build/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.js.map +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.d.ts +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js +2 -2
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js.map +1 -1
- package/build/dex/curve-v1-factory/types.d.ts +4 -1
- package/build/dex/curve-v1-factory/types.js +1 -0
- package/build/dex/curve-v1-factory/types.js.map +1 -1
- package/build/dex/generic-rfq/generic-rfq.d.ts +2 -1
- package/build/dex/generic-rfq/generic-rfq.js +9 -5
- package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
- package/build/dex/generic-rfq/rate-fetcher.d.ts +1 -1
- package/build/dex/generic-rfq/rate-fetcher.js +2 -1
- package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
- package/build/dex/generic-rfq/types.d.ts +1 -0
- package/build/dex/generic-rfq/types.js.map +1 -1
- package/build/dex/hashflow/hashflow.d.ts +1 -0
- package/build/dex/hashflow/hashflow.js +1 -0
- package/build/dex/hashflow/hashflow.js.map +1 -1
- package/build/dex/idex.d.ts +1 -0
- package/build/dex/index.d.ts +1 -0
- package/build/dex/index.js +21 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/maverick-v1/config.js +9 -0
- package/build/dex/maverick-v1/config.js.map +1 -1
- package/build/dex/maverick-v1/maverick-v1.js +11 -2
- package/build/dex/maverick-v1/maverick-v1.js.map +1 -1
- package/build/dex/maverick-v1/scripts/event-sequence.d.ts +1 -0
- package/build/dex/maverick-v1/scripts/event-sequence.js +110 -0
- package/build/dex/maverick-v1/scripts/event-sequence.js.map +1 -0
- package/build/dex/pancakeswap-v3/config.js +17 -0
- package/build/dex/pancakeswap-v3/config.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.d.ts +26 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.js +44 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.js.map +1 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3.d.ts +3 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js +26 -2
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js.map +1 -1
- package/build/dex/quick-perps/config.d.ts +11 -0
- package/build/dex/quick-perps/config.js +27 -0
- package/build/dex/quick-perps/config.js.map +1 -0
- package/build/dex/quick-perps/fast-price-feed.d.ts +26 -0
- package/build/dex/quick-perps/fast-price-feed.js +176 -0
- package/build/dex/quick-perps/fast-price-feed.js.map +1 -0
- package/build/dex/quick-perps/pool.d.ts +21 -0
- package/build/dex/quick-perps/pool.js +225 -0
- package/build/dex/quick-perps/pool.js.map +1 -0
- package/build/dex/quick-perps/quick-perps.d.ts +52 -0
- package/build/dex/quick-perps/quick-perps.js +211 -0
- package/build/dex/quick-perps/quick-perps.js.map +1 -0
- package/build/dex/quick-perps/types.d.ts +98 -0
- package/build/dex/quick-perps/types.js +3 -0
- package/build/dex/quick-perps/types.js.map +1 -0
- package/build/dex/quick-perps/usdq.d.ts +15 -0
- package/build/dex/quick-perps/usdq.js +61 -0
- package/build/dex/quick-perps/usdq.js.map +1 -0
- package/build/dex/quick-perps/vault-price-feed.d.ts +43 -0
- package/build/dex/quick-perps/vault-price-feed.js +194 -0
- package/build/dex/quick-perps/vault-price-feed.js.map +1 -0
- package/build/dex/quick-perps/vault-utils.d.ts +8 -0
- package/build/dex/quick-perps/vault-utils.js +41 -0
- package/build/dex/quick-perps/vault-utils.js.map +1 -0
- package/build/dex/quick-perps/vault.d.ts +46 -0
- package/build/dex/quick-perps/vault.js +166 -0
- package/build/dex/quick-perps/vault.js.map +1 -0
- package/build/dex/solidly/config.js +52 -2
- package/build/dex/solidly/config.js.map +1 -1
- package/build/dex/solidly/forks-override/aerodrome.d.ts +14 -0
- package/build/dex/solidly/forks-override/aerodrome.js +48 -0
- package/build/dex/solidly/forks-override/aerodrome.js.map +1 -0
- package/build/dex/solidly/forks-override/equalizer.d.ts +20 -0
- package/build/dex/solidly/forks-override/equalizer.js +46 -0
- package/build/dex/solidly/forks-override/equalizer.js.map +1 -0
- package/build/dex/solidly/forks-override/ramses.d.ts +44 -0
- package/build/dex/solidly/forks-override/ramses.js +144 -0
- package/build/dex/solidly/forks-override/ramses.js.map +1 -0
- package/build/dex/solidly/forks-override/velodromeV2.d.ts +20 -0
- package/build/dex/solidly/forks-override/velodromeV2.js +50 -0
- package/build/dex/solidly/forks-override/velodromeV2.js.map +1 -0
- package/build/dex/solidly/solidly.js +4 -0
- package/build/dex/solidly/solidly.js.map +1 -1
- package/build/dex/uniswap-v2/nomiswap-v2.d.ts +24 -0
- package/build/dex/uniswap-v2/nomiswap-v2.js +44 -0
- package/build/dex/uniswap-v2/nomiswap-v2.js.map +1 -0
- package/build/dex/uniswap-v3/config.js +166 -0
- package/build/dex/uniswap-v3/config.js.map +1 -1
- package/build/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.d.ts +19 -0
- package/build/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.js +99 -0
- package/build/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.js.map +1 -0
- package/build/dex/uniswap-v3/forks/ramses-v2/utils.d.ts +4 -0
- package/build/dex/uniswap-v3/forks/ramses-v2/utils.js +63 -0
- package/build/dex/uniswap-v3/forks/ramses-v2/utils.js.map +1 -0
- package/build/dex/uniswap-v3/types.d.ts +10 -1
- package/build/dex/uniswap-v3/types.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3-factory.d.ts +26 -0
- package/build/dex/uniswap-v3/uniswap-v3-factory.js +44 -0
- package/build/dex/uniswap-v3/uniswap-v3-factory.js.map +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-pool.d.ts +8 -6
- package/build/dex/uniswap-v3/uniswap-v3-pool.js +5 -2
- package/build/dex/uniswap-v3/uniswap-v3-pool.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.d.ts +7 -4
- package/build/dex/uniswap-v3/uniswap-v3.js +51 -10
- package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
- package/build/dex/weth/config.js +3 -0
- package/build/dex/weth/config.js.map +1 -1
- package/build/dex/woo-fi-v2/config.js +13 -0
- package/build/dex/woo-fi-v2/config.js.map +1 -1
- package/build/dex-helper/dummy-dex-helper.js +7 -1
- package/build/dex-helper/dummy-dex-helper.js.map +1 -1
- package/build/dex-helper/icache.d.ts +1 -0
- package/build/lib/api3-feed.d.ts +30 -0
- package/build/lib/api3-feed.js +100 -0
- package/build/lib/api3-feed.js.map +1 -0
- package/build/lib/decoders.d.ts +3 -0
- package/build/lib/decoders.js +9 -1
- package/build/lib/decoders.js.map +1 -1
- package/build/stateful-event-subscriber.d.ts +1 -0
- package/build/stateful-event-subscriber.js +6 -0
- package/build/stateful-event-subscriber.js.map +1 -1
- package/build/types.d.ts +2 -0
- package/build/workers.d.ts +0 -0
- package/build/workers.js +2 -0
- package/build/workers.js.map +1 -0
- package/package.json +1 -1
- package/src/abi/RamsesV2Pool.abi.json +1554 -0
- package/src/abi/RamsesV2Quoter.abi.json +274 -0
- package/src/abi/RamsesV2StateMulticall.abi.json +891 -0
- package/src/abi/aerodrome/aerodrome-pool-factory.json +586 -0
- package/src/abi/algebra/AlgebraFactory-v1_1.abi.json +250 -0
- package/src/abi/api3-proxy.json +53 -0
- package/src/abi/api3-server-v1.json +463 -0
- package/src/abi/nomiswap-v2/nomiswap-v2-pool.json +773 -0
- package/src/abi/pancakeswap-v3/PancakeswapV3Factory.abi.json +300 -0
- package/src/abi/quick-perps/fast-price-events.json +70 -0
- package/src/abi/quick-perps/fast-price-feed.json +741 -0
- package/src/abi/quick-perps/reader.json +313 -0
- package/src/abi/quick-perps/vault-price-feed.json +323 -0
- package/src/abi/quick-perps/vault.json +1953 -0
- package/src/abi/ramses-v2/RamsesV2Pool.abi.json +1599 -0
- package/src/composed-event-subscriber.ts +16 -11
- package/src/config.ts +80 -14
- package/src/constants.ts +1 -0
- package/src/dex/algebra/algebra-factory.ts +70 -0
- package/src/dex/algebra/algebra-integration.test.ts +316 -16
- package/src/dex/algebra/algebra-pool-v1_1.ts +259 -8
- package/src/dex/algebra/algebra.ts +73 -22
- package/src/dex/algebra/config.ts +1 -0
- package/src/dex/algebra/lib/TickTable.ts +75 -74
- package/src/dex/algebra/types.ts +6 -2
- package/src/dex/algebra/utils.ts +83 -2
- package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +133 -4
- package/src/dex/balancer-v2/balancer-v2.ts +87 -6
- package/src/dex/balancer-v2/config.ts +11 -2
- package/src/dex/balancer-v2/optimizer.ts +49 -62
- package/src/dex/balancer-v2/types.ts +0 -4
- package/src/dex/curve-v1/config.ts +40 -38
- package/src/dex/curve-v1-factory/config.ts +17 -9
- package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +19 -0
- package/src/dex/curve-v1-factory/curve-v1-factory-integration.test.ts +165 -45
- package/src/dex/curve-v1-factory/curve-v1-factory.ts +477 -415
- package/src/dex/curve-v1-factory/curve-v1-pool-manager.ts +15 -2
- package/src/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_rates.ts +2 -1
- package/src/dex/curve-v1-factory/price-handlers/functions/_xp.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_xp_mem.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.ts +71 -13
- package/src/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/constants.ts +11 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D.ts +2 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D_mem.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_dy.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_y.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_y_D.ts +1 -0
- package/src/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.ts +13 -5
- package/src/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.ts +2 -1
- package/src/dex/curve-v1-factory/types.ts +3 -1
- package/src/dex/generic-rfq/example-api.test.ts +1 -1
- package/src/dex/generic-rfq/generic-rfq.ts +12 -4
- package/src/dex/generic-rfq/rate-fetcher.ts +4 -2
- package/src/dex/generic-rfq/types.ts +1 -0
- package/src/dex/hashflow/hashflow-e2e.test.ts +36 -3
- package/src/dex/hashflow/hashflow.ts +2 -1
- package/src/dex/idex.ts +1 -0
- package/src/dex/index.ts +21 -0
- package/src/dex/maverick-v1/config.ts +10 -0
- package/src/dex/maverick-v1/maverick-v1-e2e.test.ts +115 -1
- package/src/dex/maverick-v1/maverick-v1.ts +12 -2
- package/src/dex/pancakeswap-v3/config.ts +19 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3-e2e.test.ts +114 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3-factory.ts +73 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +50 -2
- package/src/dex/quick-perps/config.ts +31 -0
- package/src/dex/quick-perps/fast-price-feed.ts +279 -0
- package/src/dex/quick-perps/pool.ts +407 -0
- package/src/dex/quick-perps/quick-perps-e2e.test.ts +65 -0
- package/src/dex/quick-perps/quick-perps-events.test.ts +100 -0
- package/src/dex/quick-perps/quick-perps-integration.test.ts +153 -0
- package/src/dex/quick-perps/quick-perps.ts +302 -0
- package/src/dex/quick-perps/types.ts +97 -0
- package/src/dex/quick-perps/usdq.ts +83 -0
- package/src/dex/quick-perps/vault-price-feed.ts +322 -0
- package/src/dex/quick-perps/vault-utils.ts +53 -0
- package/src/dex/quick-perps/vault.ts +290 -0
- package/src/dex/solidly/config.ts +58 -2
- package/src/dex/solidly/forks-override/aerodrome.ts +53 -0
- package/src/dex/solidly/forks-override/equalizer.ts +58 -0
- package/src/dex/solidly/forks-override/ramses.ts +253 -0
- package/src/dex/solidly/forks-override/velodromeV2.ts +63 -0
- package/src/dex/solidly/solidly-e2e.test.ts +313 -1
- package/src/dex/solidly/solidly-integration.test.ts +540 -41
- package/src/dex/solidly/solidly.ts +5 -0
- package/src/dex/uniswap-v2/nomiswap-v2.ts +63 -0
- package/src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts +120 -1
- package/src/dex/uniswap-v3/config.ts +174 -0
- package/src/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.ts +156 -0
- package/src/dex/uniswap-v3/forks/ramses-v2/utils.ts +72 -0
- package/src/dex/uniswap-v3/types.ts +14 -1
- package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +1071 -346
- package/src/dex/uniswap-v3/uniswap-v3-factory.ts +73 -0
- package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +787 -14
- package/src/dex/uniswap-v3/uniswap-v3-pool.ts +13 -5
- package/src/dex/uniswap-v3/uniswap-v3.ts +87 -20
- package/src/dex/weth/config.ts +3 -0
- package/src/dex/woo-fi-v2/config.ts +13 -0
- package/src/dex/woo-fi-v2/woo-fi-v2-e2e.test.ts +64 -0
- package/src/dex-helper/dummy-dex-helper.ts +8 -1
- package/src/dex-helper/icache.ts +2 -0
- package/src/lib/api3-feed.ts +175 -0
- package/src/lib/decoders.ts +13 -0
- package/src/stateful-event-subscriber.ts +8 -0
- package/src/types.ts +2 -0
- package/tests/constants-e2e.ts +102 -6
- package/tests/tenderly-simulation.ts +48 -4
- package/tests/utils-e2e.ts +21 -11
|
@@ -42,7 +42,10 @@ export class CurveV1FactoryPoolManager {
|
|
|
42
42
|
// It should bo considered for optimizing
|
|
43
43
|
private coinAddressesToPoolIdentifiers: Record<string, string[]> = {};
|
|
44
44
|
|
|
45
|
-
private allCurveLiquidityApiSlugs: Set<string> = new Set([
|
|
45
|
+
private allCurveLiquidityApiSlugs: Set<string> = new Set([
|
|
46
|
+
'/factory',
|
|
47
|
+
'/factory-crvusd',
|
|
48
|
+
]);
|
|
46
49
|
|
|
47
50
|
private statePollingManager = StatePollingManager;
|
|
48
51
|
private taskScheduler: TaskScheduler;
|
|
@@ -91,7 +94,7 @@ export class CurveV1FactoryPoolManager {
|
|
|
91
94
|
filteredPoolsByLiquidity.sort((a, b) => +a.isMetaPool - +b.isMetaPool),
|
|
92
95
|
);
|
|
93
96
|
|
|
94
|
-
this.statePollingManager.updatePoolsInBatch(
|
|
97
|
+
return this.statePollingManager.updatePoolsInBatch(
|
|
95
98
|
this.logger,
|
|
96
99
|
this.dexHelper,
|
|
97
100
|
pools,
|
|
@@ -102,6 +105,16 @@ export class CurveV1FactoryPoolManager {
|
|
|
102
105
|
);
|
|
103
106
|
}
|
|
104
107
|
|
|
108
|
+
async updateManuallyPollingPools(pools: PoolPollingBase[]) {
|
|
109
|
+
return this.statePollingManager.updatePoolsInBatch(
|
|
110
|
+
this.logger,
|
|
111
|
+
this.dexHelper,
|
|
112
|
+
pools,
|
|
113
|
+
undefined,
|
|
114
|
+
undefined,
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
105
118
|
async initializeIndividualPollingPoolState(
|
|
106
119
|
identifier: string,
|
|
107
120
|
isSrcFeeOnTransferTokenToBeExchanged: boolean,
|
|
@@ -284,6 +284,7 @@ const implementations: Record<ImplementationNames, _calc_withdraw_one_coin> = {
|
|
|
284
284
|
[ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: customArbitrum2CoinBtc,
|
|
285
285
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: customArbitrum2CoinBtc,
|
|
286
286
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: factoryPlain2EthEma2,
|
|
287
|
+
[ImplementationNames.FACTORY_PLAIN_2_CRV_EMA]: customArbitrum2CoinBtc,
|
|
287
288
|
};
|
|
288
289
|
|
|
289
290
|
export default implementations;
|
|
@@ -93,6 +93,7 @@ const implementations: Record<ImplementationNames, _dynamic_fee> = {
|
|
|
93
93
|
[ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: notExist,
|
|
94
94
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: notExist,
|
|
95
95
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: notExist,
|
|
96
|
+
[ImplementationNames.FACTORY_PLAIN_2_CRV_EMA]: notExist,
|
|
96
97
|
};
|
|
97
98
|
|
|
98
99
|
export default implementations;
|
|
@@ -36,7 +36,7 @@ const customPlain3CoinSbtc: _rates = (
|
|
|
36
36
|
let rate = LENDING_PRECISION; // Used with no lending
|
|
37
37
|
if (use_lending[i]) {
|
|
38
38
|
const currentRate = state.exchangeRateCurrent[i];
|
|
39
|
-
if (currentRate
|
|
39
|
+
if (!currentRate) {
|
|
40
40
|
throw new Error(
|
|
41
41
|
`${self.IMPLEMENTATION_NAME}: exchangeRateCurrent contains undefined value that supposed to be used: ${state.exchangeRateCurrent}`,
|
|
42
42
|
);
|
|
@@ -108,6 +108,7 @@ const implementations: Record<ImplementationNames, _rates> = {
|
|
|
108
108
|
[ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: notExist,
|
|
109
109
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: notExist,
|
|
110
110
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: notExist,
|
|
111
|
+
[ImplementationNames.FACTORY_PLAIN_2_CRV_EMA]: notExist,
|
|
111
112
|
};
|
|
112
113
|
|
|
113
114
|
export default implementations;
|
|
@@ -106,6 +106,7 @@ const implementations: Record<ImplementationNames, _xp> = {
|
|
|
106
106
|
[ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: notExist,
|
|
107
107
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: notExist,
|
|
108
108
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: notExist,
|
|
109
|
+
[ImplementationNames.FACTORY_PLAIN_2_CRV_EMA]: notExist,
|
|
109
110
|
};
|
|
110
111
|
|
|
111
112
|
export default implementations;
|
|
@@ -95,6 +95,7 @@ const implementations: Record<ImplementationNames, _xp_mem> = {
|
|
|
95
95
|
[ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: factoryPlain2Basic,
|
|
96
96
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: factoryPlain2Basic,
|
|
97
97
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: factoryPlain2Basic,
|
|
98
|
+
[ImplementationNames.FACTORY_PLAIN_2_CRV_EMA]: factoryPlain2Basic,
|
|
98
99
|
};
|
|
99
100
|
|
|
100
101
|
export default implementations;
|
|
@@ -35,6 +35,35 @@ const customPlain3CoinThree: calc_token_amount = (
|
|
|
35
35
|
return (diff * token_amount) / D0;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
+
const customAvalanche3CoinLending: calc_token_amount = (
|
|
39
|
+
self: IPoolContext,
|
|
40
|
+
state: PoolState,
|
|
41
|
+
amounts: bigint[],
|
|
42
|
+
is_deposit: boolean,
|
|
43
|
+
) => {
|
|
44
|
+
const { N_COINS } = self.constants;
|
|
45
|
+
|
|
46
|
+
const coin_balances = [...state.balances];
|
|
47
|
+
const amp = state.A;
|
|
48
|
+
const D0 = self.get_D_precision(self, coin_balances, amp);
|
|
49
|
+
for (const i of _.range(N_COINS)) {
|
|
50
|
+
if (is_deposit) coin_balances[i] += amounts[i];
|
|
51
|
+
else coin_balances[i] -= amounts[i];
|
|
52
|
+
}
|
|
53
|
+
const D1 = self.get_D_precision(self, coin_balances, amp);
|
|
54
|
+
let diff = 0n;
|
|
55
|
+
if (is_deposit) diff = D1 - D0;
|
|
56
|
+
else diff = D0 - D1;
|
|
57
|
+
|
|
58
|
+
if (state.totalSupply === undefined) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`${self.IMPLEMENTATION_NAME} customAvalanche3CoinLending: totalSupply is not provided`,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (diff * state.totalSupply) / D0;
|
|
65
|
+
};
|
|
66
|
+
|
|
38
67
|
const factoryPlain2Basic: calc_token_amount = (
|
|
39
68
|
self: IPoolContext,
|
|
40
69
|
state: PoolState,
|
|
@@ -67,33 +96,61 @@ const factoryPlain2Basic: calc_token_amount = (
|
|
|
67
96
|
return (diff * token_amount) / D0;
|
|
68
97
|
};
|
|
69
98
|
|
|
70
|
-
const
|
|
99
|
+
const customPlain2CoinCrv: calc_token_amount = (
|
|
71
100
|
self: IPoolContext,
|
|
72
101
|
state: PoolState,
|
|
73
102
|
amounts: bigint[],
|
|
74
103
|
is_deposit: boolean,
|
|
75
104
|
) => {
|
|
76
|
-
const { N_COINS } = self.constants;
|
|
77
|
-
|
|
78
|
-
const coin_balances = [...state.balances];
|
|
105
|
+
const { N_COINS, BI_N_COINS, FEE_DENOMINATOR } = self.constants;
|
|
79
106
|
const amp = state.A;
|
|
80
|
-
const
|
|
107
|
+
const balances = [...state.balances];
|
|
108
|
+
const D0 = self.get_D_mem(self, state, balances, amp);
|
|
81
109
|
for (const i of _.range(N_COINS)) {
|
|
82
|
-
if (is_deposit)
|
|
83
|
-
else
|
|
110
|
+
if (is_deposit) balances[i] += amounts[i];
|
|
111
|
+
else balances[i] -= amounts[i];
|
|
84
112
|
}
|
|
85
|
-
const D1 = self.
|
|
86
|
-
let diff = 0n;
|
|
87
|
-
if (is_deposit) diff = D1 - D0;
|
|
88
|
-
else diff = D0 - D1;
|
|
113
|
+
const D1 = self.get_D_mem(self, state, balances, amp);
|
|
89
114
|
|
|
90
115
|
if (state.totalSupply === undefined) {
|
|
91
116
|
throw new Error(
|
|
92
|
-
`${self.IMPLEMENTATION_NAME}
|
|
117
|
+
`${self.IMPLEMENTATION_NAME} customPlain3CoinThree: totalSupply is not provided`,
|
|
93
118
|
);
|
|
94
119
|
}
|
|
95
120
|
|
|
96
|
-
|
|
121
|
+
const total_supply = state.totalSupply;
|
|
122
|
+
let D2 = D1;
|
|
123
|
+
|
|
124
|
+
if (total_supply > 0n) {
|
|
125
|
+
const base_fee = (state.fee * BI_N_COINS) / (4n * (BI_N_COINS - 1n));
|
|
126
|
+
for (const i of _.range(N_COINS)) {
|
|
127
|
+
const ideal_balance = (D1 * state.balances[i]) / D0;
|
|
128
|
+
let difference = 0n;
|
|
129
|
+
const new_balance = balances[i];
|
|
130
|
+
if (ideal_balance > new_balance) {
|
|
131
|
+
difference = ideal_balance - new_balance;
|
|
132
|
+
} else {
|
|
133
|
+
difference = new_balance - ideal_balance;
|
|
134
|
+
}
|
|
135
|
+
balances[i] -= (base_fee * difference) / FEE_DENOMINATOR;
|
|
136
|
+
}
|
|
137
|
+
const xp = self._xp_mem(
|
|
138
|
+
self,
|
|
139
|
+
[...state.constants.rate_multipliers],
|
|
140
|
+
balances,
|
|
141
|
+
);
|
|
142
|
+
D2 = self.get_D_mem(self, state, xp, amp);
|
|
143
|
+
} else {
|
|
144
|
+
return D1;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
let diff = 0n;
|
|
148
|
+
if (is_deposit) {
|
|
149
|
+
diff = D2 - D0;
|
|
150
|
+
} else {
|
|
151
|
+
diff = D0 - D2;
|
|
152
|
+
}
|
|
153
|
+
return (diff * total_supply) / D0;
|
|
97
154
|
};
|
|
98
155
|
|
|
99
156
|
const notImplemented: calc_token_amount = (
|
|
@@ -165,6 +222,7 @@ const implementations: Record<ImplementationNames, calc_token_amount> = {
|
|
|
165
222
|
[ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: customPlain3CoinThree,
|
|
166
223
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: customPlain3CoinThree,
|
|
167
224
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: customPlain3CoinThree,
|
|
225
|
+
[ImplementationNames.FACTORY_PLAIN_2_CRV_EMA]: customPlain2CoinCrv,
|
|
168
226
|
};
|
|
169
227
|
|
|
170
228
|
export default implementations;
|
|
@@ -82,6 +82,7 @@ export const implementations: Record<
|
|
|
82
82
|
[ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: customPlain3CoinThree,
|
|
83
83
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: customPlain3CoinThree,
|
|
84
84
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: customPlain3CoinThree,
|
|
85
|
+
[ImplementationNames.FACTORY_PLAIN_2_CRV_EMA]: customPlain3CoinThree,
|
|
85
86
|
};
|
|
86
87
|
|
|
87
88
|
export default implementations;
|
|
@@ -573,6 +573,17 @@ const implementationConstants: Record<
|
|
|
573
573
|
isFeeOnTransferSupported: true,
|
|
574
574
|
isLending: false,
|
|
575
575
|
|
|
576
|
+
N_COINS: 2,
|
|
577
|
+
BI_N_COINS: 2n,
|
|
578
|
+
PRECISION: BI_POWS[18],
|
|
579
|
+
FEE_DENOMINATOR: BI_POWS[10],
|
|
580
|
+
A_PRECISION: 100n,
|
|
581
|
+
},
|
|
582
|
+
[ImplementationNames.FACTORY_PLAIN_2_CRV_EMA]: {
|
|
583
|
+
isWrapNative: false,
|
|
584
|
+
isFeeOnTransferSupported: false,
|
|
585
|
+
isLending: false,
|
|
586
|
+
|
|
576
587
|
N_COINS: 2,
|
|
577
588
|
BI_N_COINS: 2n,
|
|
578
589
|
PRECISION: BI_POWS[18],
|
|
@@ -321,6 +321,8 @@ const implementations: Record<ImplementationNames, get_D> = {
|
|
|
321
321
|
makeFuncCacheable(factoryPlain2Basic),
|
|
322
322
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]:
|
|
323
323
|
makeFuncCacheable(factoryPlain2Basic),
|
|
324
|
+
[ImplementationNames.FACTORY_PLAIN_2_CRV_EMA]:
|
|
325
|
+
makeFuncCacheable(factoryPlain2Basic),
|
|
324
326
|
};
|
|
325
327
|
|
|
326
328
|
export default implementations;
|
|
@@ -140,6 +140,7 @@ export const implementations: Record<ImplementationNames, get_D_mem> = {
|
|
|
140
140
|
[ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: factoryPlain2Basic,
|
|
141
141
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: factoryPlain2Basic,
|
|
142
142
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: factoryPlain2EthEma2,
|
|
143
|
+
[ImplementationNames.FACTORY_PLAIN_2_CRV_EMA]: factoryPlain2Basic,
|
|
143
144
|
};
|
|
144
145
|
|
|
145
146
|
export default implementations;
|
|
@@ -112,6 +112,7 @@ const implementations: Record<ImplementationNames, get_D_precisions> = {
|
|
|
112
112
|
[ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: notExist,
|
|
113
113
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: notExist,
|
|
114
114
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: notExist,
|
|
115
|
+
[ImplementationNames.FACTORY_PLAIN_2_CRV_EMA]: notExist,
|
|
115
116
|
};
|
|
116
117
|
|
|
117
118
|
export default implementations;
|
|
@@ -266,6 +266,7 @@ const implementations: Record<ImplementationNames, get_dy> = {
|
|
|
266
266
|
[ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: factoryPlain2Basic,
|
|
267
267
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: factoryPlain2Basic,
|
|
268
268
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: factoryPlain2EthEma2,
|
|
269
|
+
[ImplementationNames.FACTORY_PLAIN_2_CRV_EMA]: factoryPlain2Basic,
|
|
269
270
|
};
|
|
270
271
|
|
|
271
272
|
export default implementations;
|
|
@@ -285,6 +285,7 @@ const implementations: Record<ImplementationNames, get_dy_underlying> = {
|
|
|
285
285
|
[ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: notExist,
|
|
286
286
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: notExist,
|
|
287
287
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: notExist,
|
|
288
|
+
[ImplementationNames.FACTORY_PLAIN_2_CRV_EMA]: notExist,
|
|
288
289
|
};
|
|
289
290
|
|
|
290
291
|
export default implementations;
|
|
@@ -189,6 +189,7 @@ const implementations: Record<ImplementationNames, get_y> = {
|
|
|
189
189
|
[ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: customPlain2CoinFrax,
|
|
190
190
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: customPlain2CoinFrax,
|
|
191
191
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: customPlain2CoinFrax,
|
|
192
|
+
[ImplementationNames.FACTORY_PLAIN_2_CRV_EMA]: customPlain2CoinFrax,
|
|
192
193
|
};
|
|
193
194
|
|
|
194
195
|
export default implementations;
|
|
@@ -175,6 +175,7 @@ const implementations: Record<ImplementationNames, get_y_D> = {
|
|
|
175
175
|
[ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: customPlain2CoinFrax,
|
|
176
176
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: customPlain2CoinFrax,
|
|
177
177
|
[ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: customPlain2CoinFrax,
|
|
178
|
+
[ImplementationNames.FACTORY_PLAIN_2_CRV_EMA]: customPlain2CoinFrax,
|
|
178
179
|
};
|
|
179
180
|
|
|
180
181
|
export default implementations;
|
|
@@ -13,6 +13,7 @@ import { _require } from '../../../utils';
|
|
|
13
13
|
import { Address } from '@paraswap/core';
|
|
14
14
|
import { AbiItem } from 'web3-utils';
|
|
15
15
|
import { NULL_ADDRESS } from '../../../constants';
|
|
16
|
+
import { assert } from 'ts-essentials';
|
|
16
17
|
|
|
17
18
|
type FunctionToCall =
|
|
18
19
|
| 'A'
|
|
@@ -227,16 +228,17 @@ export class CustomBasePoolForFactory extends PoolPollingBase {
|
|
|
227
228
|
|
|
228
229
|
let exchangeRateCurrent: (bigint | undefined)[] | undefined;
|
|
229
230
|
|
|
230
|
-
let lastEndIndex = lastIndex +
|
|
231
|
+
let lastEndIndex = lastIndex + this.poolConstants.COINS.length;
|
|
231
232
|
if (this.useLending) {
|
|
232
233
|
exchangeRateCurrent = new Array(this.useLending.length).fill(undefined);
|
|
234
|
+
let trueUseLendingCount = this.useLending.filter(el => el).length;
|
|
233
235
|
const exchangeRateResults = multiOutputs.slice(
|
|
234
236
|
lastEndIndex,
|
|
235
237
|
// Filter false elements before checking length
|
|
236
|
-
lastEndIndex +
|
|
238
|
+
lastEndIndex + trueUseLendingCount,
|
|
237
239
|
) as bigint[];
|
|
238
240
|
|
|
239
|
-
lastEndIndex +=
|
|
241
|
+
lastEndIndex += trueUseLendingCount;
|
|
240
242
|
// We had array with booleans and I filtered of `false` and sent request.
|
|
241
243
|
// So, now I must map that results to original indices. That is the reason of this complication
|
|
242
244
|
const indicesToFill = this.useLending.reduce<number[]>((acc, curr, i) => {
|
|
@@ -255,9 +257,15 @@ export class CustomBasePoolForFactory extends PoolPollingBase {
|
|
|
255
257
|
},
|
|
256
258
|
'indicesToFill.length === exchangeRateResults.length',
|
|
257
259
|
);
|
|
258
|
-
|
|
259
260
|
indicesToFill.forEach((indexToFill, currentIndex) => {
|
|
260
|
-
|
|
261
|
+
if (exchangeRateCurrent === undefined) {
|
|
262
|
+
throw new Error(
|
|
263
|
+
`${this.poolIdentifier}: exchangeRateCurrent is undefined`,
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
const resultRate = exchangeRateResults[currentIndex];
|
|
267
|
+
assert(resultRate, "resultRate can't be undefined");
|
|
268
|
+
exchangeRateCurrent[indexToFill] = resultRate;
|
|
261
269
|
});
|
|
262
270
|
}
|
|
263
271
|
|
|
@@ -44,6 +44,7 @@ export class FactoryStateHandler extends PoolPollingBase {
|
|
|
44
44
|
readonly poolConstants: PoolConstants,
|
|
45
45
|
readonly poolContextConstants: PoolContextConstants,
|
|
46
46
|
readonly isSrcFeeOnTransferSupported: boolean,
|
|
47
|
+
liquidityApiSlug: string,
|
|
47
48
|
baseStatePoolPolling?: PoolPollingBase,
|
|
48
49
|
customGasCost?: number,
|
|
49
50
|
readonly isStoredRatesSupported: boolean = false,
|
|
@@ -65,7 +66,7 @@ export class FactoryStateHandler extends PoolPollingBase {
|
|
|
65
66
|
poolIdentifier,
|
|
66
67
|
poolConstants,
|
|
67
68
|
address,
|
|
68
|
-
|
|
69
|
+
liquidityApiSlug,
|
|
69
70
|
false,
|
|
70
71
|
baseStatePoolPolling,
|
|
71
72
|
isSrcFeeOnTransferSupported,
|
|
@@ -104,6 +104,7 @@ export enum FactoryImplementationNames {
|
|
|
104
104
|
FACTORY_PLAIN_2_ETH_EMA = 'factory_plain_2_eth_ema',
|
|
105
105
|
FACTORY_PLAIN_2_ETH_EMA2 = 'factory_plain_2_eth_ema2',
|
|
106
106
|
FACTORY_PLAIN_2_OPTIMIZED = 'factory_plain_2_optimized',
|
|
107
|
+
FACTORY_PLAIN_2_CRV_EMA = 'factory_plain_2_crv_ema',
|
|
107
108
|
|
|
108
109
|
FACTORY_PLAIN_3_BALANCES = 'factory_plain_3_balances',
|
|
109
110
|
FACTORY_PLAIN_3_BASIC = 'factory_plain_3_basic',
|
|
@@ -154,6 +155,7 @@ export type FactoryPoolImplementations = {
|
|
|
154
155
|
basePoolAddress?: Address;
|
|
155
156
|
customGasCost?: number;
|
|
156
157
|
isStoreRateSupported?: boolean;
|
|
158
|
+
liquidityApiSlug?: string;
|
|
157
159
|
};
|
|
158
160
|
|
|
159
161
|
export type CustomPoolConfig = {
|
|
@@ -174,7 +176,7 @@ export type CustomPoolConfig = {
|
|
|
174
176
|
};
|
|
175
177
|
|
|
176
178
|
export type DexParams = {
|
|
177
|
-
|
|
179
|
+
factoryAddresses: string[] | null;
|
|
178
180
|
stateUpdatePeriodMs: number;
|
|
179
181
|
factoryPoolImplementations: Record<Address, FactoryPoolImplementations>;
|
|
180
182
|
customPools: Record<string, CustomPoolConfig>;
|
|
@@ -157,7 +157,7 @@ export const startTestServer = (account: ethers.Wallet) => {
|
|
|
157
157
|
new BigNumber(_prices.asks![0][0]),
|
|
158
158
|
);
|
|
159
159
|
} else {
|
|
160
|
-
const reversedPrices = _prices.
|
|
160
|
+
const reversedPrices = _prices.asks!.map(price =>
|
|
161
161
|
reversePrice([new BigNumber(price[0]), new BigNumber(price[1])]),
|
|
162
162
|
);
|
|
163
163
|
value = new BigNumber(payload.makerAmount).times(
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
PreprocessTransactionOptions,
|
|
7
7
|
Config,
|
|
8
8
|
PoolLiquidity,
|
|
9
|
+
Address,
|
|
9
10
|
} from '../../types';
|
|
10
11
|
import { Network, SwapSide } from '../../constants';
|
|
11
12
|
import { IDexHelper } from '../../dex-helper';
|
|
@@ -61,17 +62,19 @@ export class GenericRFQ extends ParaSwapLimitOrders {
|
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
getIdentifier(srcToken: Address, destToken: Address) {
|
|
66
|
+
// Keep only destination token in order to prevent taping into the same market maker liquidity during same swap (double spending)
|
|
67
|
+
return `${this.dexKey}_${destToken}`.toLowerCase();
|
|
68
|
+
}
|
|
69
|
+
|
|
64
70
|
async getPoolIdentifiers(
|
|
65
71
|
srcToken: Token,
|
|
66
72
|
destToken: Token,
|
|
67
73
|
side: SwapSide,
|
|
68
74
|
blockNumber: number,
|
|
69
75
|
): Promise<string[]> {
|
|
70
|
-
const _srcToken = this.dexHelper.config.wrapETH(srcToken);
|
|
71
76
|
const _destToken = this.dexHelper.config.wrapETH(destToken);
|
|
72
|
-
return [
|
|
73
|
-
`${this.dexKey}_${_srcToken.address}_${_destToken.address}`.toLowerCase(),
|
|
74
|
-
];
|
|
77
|
+
return [this.getIdentifier(srcToken.address, _destToken.address)];
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
calcOutsFromAmounts(
|
|
@@ -140,6 +143,10 @@ export class GenericRFQ extends ParaSwapLimitOrders {
|
|
|
140
143
|
_destToken.address,
|
|
141
144
|
);
|
|
142
145
|
|
|
146
|
+
if (!limitPools?.includes(expectedIdentifier)) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
|
|
143
150
|
const rates = await this.rateFetcher.getOrderPrice(
|
|
144
151
|
_srcToken,
|
|
145
152
|
_destToken,
|
|
@@ -203,6 +210,7 @@ export class GenericRFQ extends ParaSwapLimitOrders {
|
|
|
203
210
|
: overOrder(optimalSwapExchange.destAmount, 1),
|
|
204
211
|
side,
|
|
205
212
|
options.txOrigin,
|
|
213
|
+
options.partner,
|
|
206
214
|
);
|
|
207
215
|
|
|
208
216
|
const expiryAsBigInt = BigInt(order.order.expiry);
|
|
@@ -226,7 +226,7 @@ export class RateFetcher {
|
|
|
226
226
|
private handleRatesResponse(resp: RatesResponse) {
|
|
227
227
|
const pairs = this.pairs;
|
|
228
228
|
|
|
229
|
-
if(isEmpty(pairs)) return;
|
|
229
|
+
if (isEmpty(pairs)) return;
|
|
230
230
|
|
|
231
231
|
Object.keys(resp.prices).forEach(pairName => {
|
|
232
232
|
const pair = pairs[pairName];
|
|
@@ -239,7 +239,7 @@ export class RateFetcher {
|
|
|
239
239
|
return;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
if(isEmpty(this.tokens)) return;
|
|
242
|
+
if (isEmpty(this.tokens)) return;
|
|
243
243
|
|
|
244
244
|
const baseToken = this.tokens[pair.base];
|
|
245
245
|
const quoteToken = this.tokens[pair.quote];
|
|
@@ -376,6 +376,7 @@ export class RateFetcher {
|
|
|
376
376
|
srcAmount: string,
|
|
377
377
|
side: SwapSide,
|
|
378
378
|
userAddress: Address,
|
|
379
|
+
partner?: string,
|
|
379
380
|
): Promise<OrderInfo> {
|
|
380
381
|
const srcToken = this.dexHelper.config.wrapETH(_srcToken);
|
|
381
382
|
const destToken = this.dexHelper.config.wrapETH(_destToken);
|
|
@@ -390,6 +391,7 @@ export class RateFetcher {
|
|
|
390
391
|
makerAmount: side === SwapSide.BUY ? srcAmount : undefined,
|
|
391
392
|
takerAmount: side === SwapSide.SELL ? srcAmount : undefined,
|
|
392
393
|
userAddress,
|
|
394
|
+
partner,
|
|
393
395
|
};
|
|
394
396
|
|
|
395
397
|
try {
|
|
@@ -11,6 +11,9 @@ import { Network, ContractMethod, SwapSide } from '../../constants';
|
|
|
11
11
|
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
12
12
|
import { generateConfig } from '../../config';
|
|
13
13
|
|
|
14
|
+
// Give time for rate fetcher to fill the cache
|
|
15
|
+
const sleepMs = 3000;
|
|
16
|
+
|
|
14
17
|
function testForNetwork(
|
|
15
18
|
network: Network,
|
|
16
19
|
dexKey: string,
|
|
@@ -58,6 +61,11 @@ function testForNetwork(
|
|
|
58
61
|
contractMethod,
|
|
59
62
|
network,
|
|
60
63
|
provider,
|
|
64
|
+
undefined,
|
|
65
|
+
undefined,
|
|
66
|
+
undefined,
|
|
67
|
+
undefined,
|
|
68
|
+
sleepMs,
|
|
61
69
|
);
|
|
62
70
|
});
|
|
63
71
|
it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
|
|
@@ -71,6 +79,11 @@ function testForNetwork(
|
|
|
71
79
|
contractMethod,
|
|
72
80
|
network,
|
|
73
81
|
provider,
|
|
82
|
+
undefined,
|
|
83
|
+
undefined,
|
|
84
|
+
undefined,
|
|
85
|
+
undefined,
|
|
86
|
+
sleepMs,
|
|
74
87
|
);
|
|
75
88
|
});
|
|
76
89
|
} else {
|
|
@@ -85,6 +98,11 @@ function testForNetwork(
|
|
|
85
98
|
contractMethod,
|
|
86
99
|
network,
|
|
87
100
|
provider,
|
|
101
|
+
undefined,
|
|
102
|
+
undefined,
|
|
103
|
+
undefined,
|
|
104
|
+
undefined,
|
|
105
|
+
sleepMs,
|
|
88
106
|
);
|
|
89
107
|
});
|
|
90
108
|
it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
|
|
@@ -98,6 +116,11 @@ function testForNetwork(
|
|
|
98
116
|
contractMethod,
|
|
99
117
|
network,
|
|
100
118
|
provider,
|
|
119
|
+
undefined,
|
|
120
|
+
undefined,
|
|
121
|
+
undefined,
|
|
122
|
+
undefined,
|
|
123
|
+
sleepMs,
|
|
101
124
|
);
|
|
102
125
|
});
|
|
103
126
|
it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
|
|
@@ -111,6 +134,11 @@ function testForNetwork(
|
|
|
111
134
|
contractMethod,
|
|
112
135
|
network,
|
|
113
136
|
provider,
|
|
137
|
+
undefined,
|
|
138
|
+
undefined,
|
|
139
|
+
undefined,
|
|
140
|
+
undefined,
|
|
141
|
+
sleepMs,
|
|
114
142
|
);
|
|
115
143
|
});
|
|
116
144
|
it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
|
|
@@ -124,6 +152,11 @@ function testForNetwork(
|
|
|
124
152
|
contractMethod,
|
|
125
153
|
network,
|
|
126
154
|
provider,
|
|
155
|
+
undefined,
|
|
156
|
+
undefined,
|
|
157
|
+
undefined,
|
|
158
|
+
undefined,
|
|
159
|
+
sleepMs,
|
|
127
160
|
);
|
|
128
161
|
});
|
|
129
162
|
}
|
|
@@ -163,9 +196,9 @@ describe('Hashflow E2E', () => {
|
|
|
163
196
|
const tokenASymbol: string = 'USDC';
|
|
164
197
|
const tokenBSymbol: string = 'DAI';
|
|
165
198
|
|
|
166
|
-
const tokenAAmount: string = '
|
|
167
|
-
const tokenBAmount: string = '
|
|
168
|
-
const nativeTokenAmount = '
|
|
199
|
+
const tokenAAmount: string = '1000000000';
|
|
200
|
+
const tokenBAmount: string = '1000000000000000000000';
|
|
201
|
+
const nativeTokenAmount = '100000000000000000000';
|
|
169
202
|
|
|
170
203
|
testForNetwork(
|
|
171
204
|
network,
|
|
@@ -62,6 +62,7 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
|
|
|
62
62
|
readonly isStatePollingDex = true;
|
|
63
63
|
readonly hasConstantPriceLargeAmounts = false;
|
|
64
64
|
readonly needWrapNative = false;
|
|
65
|
+
readonly needsSequentialPreprocessing = true;
|
|
65
66
|
readonly isFeeOnTransferSupported = false;
|
|
66
67
|
private api: HashflowApi;
|
|
67
68
|
private rateFetcher: RateFetcher;
|
|
@@ -737,7 +738,7 @@ export class Hashflow extends SimpleExchange implements IDex<HashflowData> {
|
|
|
737
738
|
);
|
|
738
739
|
await this.setBlacklist(options.txOrigin);
|
|
739
740
|
} else {
|
|
740
|
-
if(e instanceof TooStrictSlippageCheckError) {
|
|
741
|
+
if (e instanceof TooStrictSlippageCheckError) {
|
|
741
742
|
this.logger.warn(
|
|
742
743
|
`${this.dexKey}-${this.network}: Market Maker ${mm} failed to build transaction on side ${side} with too strict slippage. Skipping restriction`,
|
|
743
744
|
);
|
package/src/dex/idex.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { IDexHelper } from '../dex-helper/idex-helper';
|
|
|
20
20
|
|
|
21
21
|
export interface IDexTxBuilder<ExchangeData, DirectParam = null> {
|
|
22
22
|
needWrapNative: boolean;
|
|
23
|
+
needsSequentialPreprocessing?: boolean;
|
|
23
24
|
|
|
24
25
|
// Returns the ETH fee required to swap
|
|
25
26
|
// It is optional for a DEX to implement this
|