@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
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import { Interface } from '@ethersproject/abi';
|
|
3
|
+
import { AsyncOrSync, DeepReadonly } from 'ts-essentials';
|
|
4
|
+
import { PartialEventSubscriber } from '../../composed-event-subscriber';
|
|
5
|
+
import { Lens } from '../../lens';
|
|
6
|
+
import VaultABI from '../../abi/quick-perps/vault.json';
|
|
7
|
+
import { VaultUtils } from './vault-utils';
|
|
8
|
+
import {
|
|
9
|
+
VaultConfig,
|
|
10
|
+
VaultState,
|
|
11
|
+
FastPriceFeedConfig,
|
|
12
|
+
PoolState,
|
|
13
|
+
} from './types';
|
|
14
|
+
import { VaultPriceFeed } from './vault-price-feed';
|
|
15
|
+
import { USDQ } from './usdq';
|
|
16
|
+
import {
|
|
17
|
+
MultiCallInput,
|
|
18
|
+
MultiCallOutput,
|
|
19
|
+
Address,
|
|
20
|
+
Logger,
|
|
21
|
+
Log,
|
|
22
|
+
} from '../../types';
|
|
23
|
+
import { BlockHeader } from 'web3-eth';
|
|
24
|
+
|
|
25
|
+
export class Vault<State> extends PartialEventSubscriber<State, VaultState> {
|
|
26
|
+
static readonly interface: Interface = new Interface(VaultABI);
|
|
27
|
+
|
|
28
|
+
protected vaultUtils: VaultUtils<State>;
|
|
29
|
+
|
|
30
|
+
public tokenDecimals: { [address: string]: number };
|
|
31
|
+
public stableTokens: { [address: string]: boolean };
|
|
32
|
+
protected tokenWeights: { [address: string]: bigint };
|
|
33
|
+
public stableSwapFeeBasisPoints: bigint;
|
|
34
|
+
public swapFeeBasisPoints: bigint;
|
|
35
|
+
public stableTaxBasisPoints: bigint;
|
|
36
|
+
public taxBasisPoints: bigint;
|
|
37
|
+
public hasDynamicFees: bigint;
|
|
38
|
+
protected includeAmmPrice: boolean;
|
|
39
|
+
protected useSwapPricing: boolean;
|
|
40
|
+
protected totalTokenWeights: bigint;
|
|
41
|
+
|
|
42
|
+
constructor(
|
|
43
|
+
public readonly vaultAddress: Address,
|
|
44
|
+
protected tokenAddresses: Address[],
|
|
45
|
+
config: VaultConfig,
|
|
46
|
+
protected vaultPriceFeed: VaultPriceFeed<State>,
|
|
47
|
+
protected usdq: USDQ<State>,
|
|
48
|
+
lens: Lens<DeepReadonly<State>, DeepReadonly<VaultState>>,
|
|
49
|
+
logger: Logger,
|
|
50
|
+
) {
|
|
51
|
+
super([vaultAddress], lens, logger);
|
|
52
|
+
this.vaultUtils = new VaultUtils(this);
|
|
53
|
+
this.tokenDecimals = config.tokenDecimals;
|
|
54
|
+
this.stableTokens = config.stableTokens;
|
|
55
|
+
this.tokenWeights = config.tokenWeights;
|
|
56
|
+
this.stableSwapFeeBasisPoints = config.stableSwapFeeBasisPoints;
|
|
57
|
+
this.swapFeeBasisPoints = config.swapFeeBasisPoints;
|
|
58
|
+
this.stableTaxBasisPoints = config.stableTaxBasisPoints;
|
|
59
|
+
this.taxBasisPoints = config.taxBasisPoints;
|
|
60
|
+
this.hasDynamicFees = config.hasDynamicFees;
|
|
61
|
+
this.includeAmmPrice = config.includeAmmPrice;
|
|
62
|
+
this.useSwapPricing = config.useSwapPricing;
|
|
63
|
+
this.totalTokenWeights = config.totalTokenWeights;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getMinPrice(state: DeepReadonly<State>, _token: Address): bigint {
|
|
67
|
+
return this.vaultPriceFeed.getPrice(
|
|
68
|
+
state,
|
|
69
|
+
_token,
|
|
70
|
+
false,
|
|
71
|
+
this.includeAmmPrice,
|
|
72
|
+
this.useSwapPricing,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
getMaxPrice(state: DeepReadonly<State>, _token: Address): bigint {
|
|
77
|
+
return this.vaultPriceFeed.getPrice(
|
|
78
|
+
state,
|
|
79
|
+
_token,
|
|
80
|
+
true,
|
|
81
|
+
this.includeAmmPrice,
|
|
82
|
+
this.useSwapPricing,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
getFeeBasisPoints(
|
|
87
|
+
state: DeepReadonly<State>,
|
|
88
|
+
_token: Address,
|
|
89
|
+
_usdqDelta: bigint,
|
|
90
|
+
_feeBasisPoints: bigint,
|
|
91
|
+
_taxBasisPoints: bigint,
|
|
92
|
+
_increment: boolean,
|
|
93
|
+
): bigint {
|
|
94
|
+
return this.vaultUtils.getFeeBasisPoints(
|
|
95
|
+
state,
|
|
96
|
+
_token,
|
|
97
|
+
_usdqDelta,
|
|
98
|
+
_feeBasisPoints,
|
|
99
|
+
_taxBasisPoints,
|
|
100
|
+
_increment,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getTargetUsdqAmount(state: DeepReadonly<State>, _token: Address): bigint {
|
|
105
|
+
const supply = this.usdq.getTotalSupply(state);
|
|
106
|
+
if (supply == 0n) {
|
|
107
|
+
return 0n;
|
|
108
|
+
}
|
|
109
|
+
const weight = this.tokenWeights[_token];
|
|
110
|
+
return (weight * supply) / this.totalTokenWeights;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static getConfigMulticallInputs(
|
|
114
|
+
vaultAddress: Address,
|
|
115
|
+
tokenAddresses: Address[],
|
|
116
|
+
): MultiCallInput[] {
|
|
117
|
+
return [
|
|
118
|
+
...tokenAddresses.map(t => ({
|
|
119
|
+
target: vaultAddress,
|
|
120
|
+
callData: Vault.interface.encodeFunctionData('tokenDecimals', [t]),
|
|
121
|
+
})),
|
|
122
|
+
...tokenAddresses.map(t => ({
|
|
123
|
+
target: vaultAddress,
|
|
124
|
+
callData: Vault.interface.encodeFunctionData('stableTokens', [t]),
|
|
125
|
+
})),
|
|
126
|
+
...tokenAddresses.map(t => ({
|
|
127
|
+
target: vaultAddress,
|
|
128
|
+
callData: Vault.interface.encodeFunctionData('tokenWeights', [t]),
|
|
129
|
+
})),
|
|
130
|
+
...[
|
|
131
|
+
'stableSwapFeeBasisPoints',
|
|
132
|
+
'swapFeeBasisPoints',
|
|
133
|
+
'stableTaxBasisPoints',
|
|
134
|
+
'taxBasisPoints',
|
|
135
|
+
'hasDynamicFees',
|
|
136
|
+
'includeAmmPrice',
|
|
137
|
+
'useSwapPricing',
|
|
138
|
+
'totalTokenWeights',
|
|
139
|
+
].map(fn => ({
|
|
140
|
+
target: vaultAddress,
|
|
141
|
+
callData: Vault.interface.encodeFunctionData(fn),
|
|
142
|
+
})),
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static getConfig(
|
|
147
|
+
multicallOutputs: MultiCallOutput[],
|
|
148
|
+
tokenAddresses: Address[],
|
|
149
|
+
): VaultConfig {
|
|
150
|
+
let i = 0;
|
|
151
|
+
return {
|
|
152
|
+
tokenDecimals: tokenAddresses.reduce(
|
|
153
|
+
(acc: { [address: string]: number }, t: Address) => {
|
|
154
|
+
acc[t] = parseInt(
|
|
155
|
+
Vault.interface
|
|
156
|
+
.decodeFunctionResult('tokenDecimals', multicallOutputs[i++])[0]
|
|
157
|
+
.toString(),
|
|
158
|
+
);
|
|
159
|
+
return acc;
|
|
160
|
+
},
|
|
161
|
+
{},
|
|
162
|
+
),
|
|
163
|
+
stableTokens: tokenAddresses.reduce(
|
|
164
|
+
(acc: { [address: string]: boolean }, t: Address) => {
|
|
165
|
+
acc[t] = Vault.interface.decodeFunctionResult(
|
|
166
|
+
'stableTokens',
|
|
167
|
+
multicallOutputs[i++],
|
|
168
|
+
)[0];
|
|
169
|
+
return acc;
|
|
170
|
+
},
|
|
171
|
+
{},
|
|
172
|
+
),
|
|
173
|
+
tokenWeights: tokenAddresses.reduce(
|
|
174
|
+
(acc: { [address: string]: bigint }, t: Address) => {
|
|
175
|
+
acc[t] = BigInt(
|
|
176
|
+
Vault.interface
|
|
177
|
+
.decodeFunctionResult('tokenWeights', multicallOutputs[i++])[0]
|
|
178
|
+
.toString(),
|
|
179
|
+
);
|
|
180
|
+
return acc;
|
|
181
|
+
},
|
|
182
|
+
{},
|
|
183
|
+
),
|
|
184
|
+
stableSwapFeeBasisPoints: BigInt(
|
|
185
|
+
Vault.interface
|
|
186
|
+
.decodeFunctionResult(
|
|
187
|
+
'stableSwapFeeBasisPoints',
|
|
188
|
+
multicallOutputs[i++],
|
|
189
|
+
)[0]
|
|
190
|
+
.toString(),
|
|
191
|
+
),
|
|
192
|
+
swapFeeBasisPoints: BigInt(
|
|
193
|
+
Vault.interface
|
|
194
|
+
.decodeFunctionResult('swapFeeBasisPoints', multicallOutputs[i++])[0]
|
|
195
|
+
.toString(),
|
|
196
|
+
),
|
|
197
|
+
stableTaxBasisPoints: BigInt(
|
|
198
|
+
Vault.interface
|
|
199
|
+
.decodeFunctionResult(
|
|
200
|
+
'stableTaxBasisPoints',
|
|
201
|
+
multicallOutputs[i++],
|
|
202
|
+
)[0]
|
|
203
|
+
.toString(),
|
|
204
|
+
),
|
|
205
|
+
taxBasisPoints: BigInt(
|
|
206
|
+
Vault.interface
|
|
207
|
+
.decodeFunctionResult('taxBasisPoints', multicallOutputs[i++])[0]
|
|
208
|
+
.toString(),
|
|
209
|
+
),
|
|
210
|
+
hasDynamicFees: Vault.interface.decodeFunctionResult(
|
|
211
|
+
'hasDynamicFees',
|
|
212
|
+
multicallOutputs[i++],
|
|
213
|
+
)[0],
|
|
214
|
+
includeAmmPrice: Vault.interface.decodeFunctionResult(
|
|
215
|
+
'includeAmmPrice',
|
|
216
|
+
multicallOutputs[i++],
|
|
217
|
+
)[0],
|
|
218
|
+
useSwapPricing: Vault.interface.decodeFunctionResult(
|
|
219
|
+
'useSwapPricing',
|
|
220
|
+
multicallOutputs[i++],
|
|
221
|
+
)[0],
|
|
222
|
+
totalTokenWeights: BigInt(
|
|
223
|
+
Vault.interface
|
|
224
|
+
.decodeFunctionResult('totalTokenWeights', multicallOutputs[i++])[0]
|
|
225
|
+
.toString(),
|
|
226
|
+
),
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
public getGenerateStateMultiCallInputs(): MultiCallInput[] {
|
|
231
|
+
return this.tokenAddresses.map((t: Address) => ({
|
|
232
|
+
target: this.vaultAddress,
|
|
233
|
+
callData: Vault.interface.encodeFunctionData('usdqAmounts', [t]),
|
|
234
|
+
}));
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
public generateState(
|
|
238
|
+
multicallOutputs: MultiCallOutput[],
|
|
239
|
+
blockNumber?: number | 'latest',
|
|
240
|
+
): DeepReadonly<VaultState> {
|
|
241
|
+
let vaultState: VaultState = {
|
|
242
|
+
usdqAmounts: {},
|
|
243
|
+
};
|
|
244
|
+
this.tokenAddresses.forEach(
|
|
245
|
+
(t: Address, i: number) =>
|
|
246
|
+
(vaultState.usdqAmounts[t] = BigInt(
|
|
247
|
+
Vault.interface
|
|
248
|
+
.decodeFunctionResult('usdqAmounts', multicallOutputs[i])[0]
|
|
249
|
+
.toString(),
|
|
250
|
+
)),
|
|
251
|
+
);
|
|
252
|
+
return vaultState;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
public getUSDQAmount(state: DeepReadonly<State>, token: Address): bigint {
|
|
256
|
+
return this.lens.get()(state).usdqAmounts[token];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
public processLog(
|
|
260
|
+
state: DeepReadonly<VaultState>,
|
|
261
|
+
log: Readonly<Log>,
|
|
262
|
+
blockHeader: Readonly<BlockHeader>,
|
|
263
|
+
): AsyncOrSync<VaultState | null> {
|
|
264
|
+
try {
|
|
265
|
+
const parsed = Vault.interface.parseLog(log);
|
|
266
|
+
const _state: VaultState = _.cloneDeep(state);
|
|
267
|
+
switch (parsed.name) {
|
|
268
|
+
case 'IncreaseUsdqAmount': {
|
|
269
|
+
const tokenAddress = parsed.args.token.toLowerCase();
|
|
270
|
+
const amount = BigInt(parsed.args.amount.toString());
|
|
271
|
+
if (tokenAddress in state.usdqAmounts)
|
|
272
|
+
_state.usdqAmounts[tokenAddress] += amount;
|
|
273
|
+
return _state;
|
|
274
|
+
}
|
|
275
|
+
case 'DecreaseUsdqAmount': {
|
|
276
|
+
const tokenAddress = parsed.args.token.toLowerCase();
|
|
277
|
+
const amount = BigInt(parsed.args.amount.toString());
|
|
278
|
+
if (tokenAddress in state.usdqAmounts)
|
|
279
|
+
_state.usdqAmounts[tokenAddress] -= amount;
|
|
280
|
+
return _state;
|
|
281
|
+
}
|
|
282
|
+
default:
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
} catch (e) {
|
|
286
|
+
this.logger.error('Failed to parse log', e);
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
@@ -72,6 +72,28 @@ export const SolidlyConfig: DexConfigMap<DexParams> = {
|
|
|
72
72
|
feeCode: 2,
|
|
73
73
|
},
|
|
74
74
|
},
|
|
75
|
+
VelodromeV2: {
|
|
76
|
+
[Network.OPTIMISM]: {
|
|
77
|
+
// There is no subgraph for VelodromeV2
|
|
78
|
+
factoryAddress: '0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a',
|
|
79
|
+
router: '0xa2f581b012E0f2dcCDe86fCbfb529f4aC5dD4983',
|
|
80
|
+
initCode:
|
|
81
|
+
'0x1a8f01f7eab324003d9388f229ea17991eee9c9d14586f429799f3656790eba0',
|
|
82
|
+
poolGasCost: 180 * 1000,
|
|
83
|
+
feeCode: 0,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
Aerodrome: {
|
|
87
|
+
[Network.BASE]: {
|
|
88
|
+
// There is no subgraph for Aerodrome
|
|
89
|
+
factoryAddress: '0x420DD381b31aEf6683db6B902084cB0FFECe40Da',
|
|
90
|
+
router: '0xDCf4EE5B700e2a5Fec458e06B763A4a3E3004494',
|
|
91
|
+
initCode:
|
|
92
|
+
'0x1a8f01f7eab324003d9388f229ea17991eee9c9d14586f429799f3656790eba0',
|
|
93
|
+
poolGasCost: 180 * 1000,
|
|
94
|
+
feeCode: 0,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
75
97
|
Cone: {
|
|
76
98
|
[Network.BSC]: {
|
|
77
99
|
subgraphURL: 'https://api.thegraph.com/subgraphs/name/cone-exchange/cone',
|
|
@@ -125,6 +147,37 @@ export const SolidlyConfig: DexConfigMap<DexParams> = {
|
|
|
125
147
|
feeCode: 0,
|
|
126
148
|
},
|
|
127
149
|
},
|
|
150
|
+
Ramses: {
|
|
151
|
+
[Network.ARBITRUM]: {
|
|
152
|
+
subgraphURL:
|
|
153
|
+
'https://api.thegraph.com/subgraphs/name/ramsesexchange/api-subgraph',
|
|
154
|
+
factoryAddress: '0xAAA20D08e59F6561f242b08513D36266C5A29415',
|
|
155
|
+
router: '0xb2634B3CBc1E401AB3C2743DB44d459C5c9aA662',
|
|
156
|
+
initCode:
|
|
157
|
+
'0x1565b129f2d1790f12d45301b9b084335626f0c92410bc43130763b69971135d',
|
|
158
|
+
poolGasCost: 180 * 1000,
|
|
159
|
+
feeCode: 0,
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
Equalizer: {
|
|
163
|
+
[Network.FANTOM]: {
|
|
164
|
+
factoryAddress: '0xc6366EFD0AF1d09171fe0EBF32c7943BB310832a',
|
|
165
|
+
router: '0x93d2611EB8b85bE4FDEa9D94Ce9913D90072eC0f',
|
|
166
|
+
initCode:
|
|
167
|
+
'0x02ada2a0163cd4f7e0f0c9805f5230716a95b174140e4c84c14883de216cc6a3',
|
|
168
|
+
feeCode: 0,
|
|
169
|
+
poolGasCost: 180 * 1000,
|
|
170
|
+
},
|
|
171
|
+
[Network.BASE]: {
|
|
172
|
+
factoryAddress: '0xed8db60acc29e14bc867a497d94ca6e3ceb5ec04',
|
|
173
|
+
router: '0xDCf4EE5B700e2a5Fec458e06B763A4a3E3004494',
|
|
174
|
+
initCode:
|
|
175
|
+
'0x7ba31a081e879b8e7f06d4e8bf5ee26b5c2680669c5701f4cdbdcde51727b275',
|
|
176
|
+
feeCode: 0,
|
|
177
|
+
feeFactor: 1e18,
|
|
178
|
+
poolGasCost: 180 * 1000,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
128
181
|
};
|
|
129
182
|
|
|
130
183
|
export const Adapters: Record<number, AdapterMappings> = {
|
|
@@ -132,7 +185,7 @@ export const Adapters: Record<number, AdapterMappings> = {
|
|
|
132
185
|
[SwapSide.SELL]: [{ name: 'PolygonAdapter02', index: 3 }], // dystopia
|
|
133
186
|
},
|
|
134
187
|
[Network.FANTOM]: {
|
|
135
|
-
[SwapSide.SELL]: [{ name: 'FantomAdapter01', index: 10 }], // solidly
|
|
188
|
+
[SwapSide.SELL]: [{ name: 'FantomAdapter01', index: 10 }], // solidly, spiritSwapV2, equalizer
|
|
136
189
|
},
|
|
137
190
|
[Network.OPTIMISM]: {
|
|
138
191
|
[SwapSide.SELL]: [{ name: 'OptimismAdapter01', index: 8 }], // velodrome
|
|
@@ -147,6 +200,9 @@ export const Adapters: Record<number, AdapterMappings> = {
|
|
|
147
200
|
[SwapSide.SELL]: [{ name: 'AvalancheAdapter02', index: 3 }], // solisnek
|
|
148
201
|
},
|
|
149
202
|
[Network.ARBITRUM]: {
|
|
150
|
-
[SwapSide.SELL]: [{ name: 'ArbitrumAdapter02', index: 1 }], // chronos
|
|
203
|
+
[SwapSide.SELL]: [{ name: 'ArbitrumAdapter02', index: 1 }], // chronos, ramses
|
|
204
|
+
},
|
|
205
|
+
[Network.BASE]: {
|
|
206
|
+
[SwapSide.SELL]: [{ name: 'BaseAdapter01', index: 3 }], // aerodrome, equalizer
|
|
151
207
|
},
|
|
152
208
|
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { VelodromeV2 } from './velodromeV2';
|
|
2
|
+
import { Network, NULL_ADDRESS } from '../../../constants';
|
|
3
|
+
import { getDexKeysWithNetwork } from '../../../utils';
|
|
4
|
+
import _ from 'lodash';
|
|
5
|
+
import { SolidlyConfig } from '../config';
|
|
6
|
+
import { Token } from '../../../types';
|
|
7
|
+
import { IDexHelper } from '../../../dex-helper';
|
|
8
|
+
import AerodromeFactoryABI from '../../../abi/aerodrome/aerodrome-pool-factory.json';
|
|
9
|
+
|
|
10
|
+
export class Aerodrome extends VelodromeV2 {
|
|
11
|
+
public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
|
|
12
|
+
getDexKeysWithNetwork(_.pick(SolidlyConfig, ['Aerodrome']));
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
protected network: Network,
|
|
16
|
+
dexKey: string,
|
|
17
|
+
protected dexHelper: IDexHelper,
|
|
18
|
+
) {
|
|
19
|
+
super(network, dexKey, dexHelper);
|
|
20
|
+
|
|
21
|
+
this.factory = new dexHelper.web3Provider.eth.Contract(
|
|
22
|
+
AerodromeFactoryABI as any,
|
|
23
|
+
SolidlyConfig[dexKey][network].factoryAddress,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async findSolidlyPair(from: Token, to: Token, stable: boolean) {
|
|
28
|
+
if (from.address.toLowerCase() === to.address.toLowerCase()) return null;
|
|
29
|
+
const [token0, token1] =
|
|
30
|
+
from.address.toLowerCase() < to.address.toLowerCase()
|
|
31
|
+
? [from, to]
|
|
32
|
+
: [to, from];
|
|
33
|
+
|
|
34
|
+
const typePostfix = this.poolPostfix(stable);
|
|
35
|
+
const key = `${token0.address.toLowerCase()}-${token1.address.toLowerCase()}-${typePostfix}`;
|
|
36
|
+
let pair = this.pairs[key];
|
|
37
|
+
if (pair) return pair;
|
|
38
|
+
|
|
39
|
+
let exchange = await this.factory.methods
|
|
40
|
+
// Solidly has additional boolean parameter "StablePool"
|
|
41
|
+
// At first we look for uniswap-like volatile pool
|
|
42
|
+
.getPool(token0.address, token1.address, stable)
|
|
43
|
+
.call();
|
|
44
|
+
|
|
45
|
+
if (exchange === NULL_ADDRESS) {
|
|
46
|
+
pair = { token0, token1, stable };
|
|
47
|
+
} else {
|
|
48
|
+
pair = { token0, token1, exchange, stable };
|
|
49
|
+
}
|
|
50
|
+
this.pairs[key] = pair;
|
|
51
|
+
return pair;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Solidly } from '../solidly';
|
|
2
|
+
import { SolidlyPair } from '../types';
|
|
3
|
+
import { Network } from '../../../constants';
|
|
4
|
+
import { IDexHelper } from '../../../dex-helper';
|
|
5
|
+
import { Interface } from '@ethersproject/abi';
|
|
6
|
+
import { getDexKeysWithNetwork } from '../../../utils';
|
|
7
|
+
import { SolidlyConfig } from '../config';
|
|
8
|
+
import _ from 'lodash';
|
|
9
|
+
|
|
10
|
+
const EqualizerFactoryABI = [
|
|
11
|
+
{
|
|
12
|
+
inputs: [{ internalType: 'address', name: '_pair', type: 'address' }],
|
|
13
|
+
name: 'getRealFee',
|
|
14
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
15
|
+
stateMutability: 'view',
|
|
16
|
+
type: 'function',
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const equalizerFactoryIface = new Interface(EqualizerFactoryABI);
|
|
21
|
+
|
|
22
|
+
export class Equalizer extends Solidly {
|
|
23
|
+
public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
|
|
24
|
+
getDexKeysWithNetwork(_.pick(SolidlyConfig, ['Equalizer']));
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
protected network: Network,
|
|
28
|
+
dexKey: string,
|
|
29
|
+
protected dexHelper: IDexHelper,
|
|
30
|
+
) {
|
|
31
|
+
super(
|
|
32
|
+
network,
|
|
33
|
+
dexKey,
|
|
34
|
+
dexHelper,
|
|
35
|
+
true, // dynamic fees
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
protected getFeesMultiCallData(pair: SolidlyPair) {
|
|
40
|
+
const callEntry = {
|
|
41
|
+
target: this.factoryAddress,
|
|
42
|
+
callData: equalizerFactoryIface.encodeFunctionData('getRealFee', [
|
|
43
|
+
pair.exchange,
|
|
44
|
+
]),
|
|
45
|
+
};
|
|
46
|
+
const callDecoder = (values: any[]) =>
|
|
47
|
+
parseInt(
|
|
48
|
+
equalizerFactoryIface
|
|
49
|
+
.decodeFunctionResult('getRealFee', values)[0]
|
|
50
|
+
.toString(),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
callEntry,
|
|
55
|
+
callDecoder,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|