@paraswap/dex-lib 2.50.3 → 2.50.4-angle-staked
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/abi/Redstone.json +739 -0
- package/build/abi/angle/stagToken.json +963 -0
- package/build/{dex/lighter-v1/abi/erc20.json → abi/angle-transmuter/MorphoOracle.json} +97 -126
- package/build/abi/angle-transmuter/MorphoVault.json +2506 -0
- package/build/abi/angle-transmuter/Pyth.json +1534 -0
- package/build/abi/angle-transmuter/Transmuter.json +1711 -0
- package/build/abi/pharaoh/PharaohPool.abi.json +1582 -0
- package/build/abi/smardex/smardex-factory.json +185 -0
- package/build/abi/smardex/smardex-pool.json +578 -0
- package/build/abi/smardex/smardex-router.json +648 -0
- package/build/abi/trader-joe-v2_1/FactoryABI.json +1208 -0
- package/build/abi/trader-joe-v2_1/PairABI.json +1493 -0
- package/build/abi/trader-joe-v2_1/RouterABI.json +1489 -0
- package/build/abi/trader-joe-v2_1/StateMulticall.json +193 -0
- package/build/abi/{integral/relayer.json → wombat/pool.json} +587 -446
- package/build/config.js +4 -2
- package/build/config.js.map +1 -1
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.d.ts +55 -0
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.js +183 -0
- package/build/dex/angle-staked-stable/angle-staked-stable-pool.js.map +1 -0
- package/build/dex/angle-staked-stable/angle-staked-stable.d.ts +50 -0
- package/build/dex/angle-staked-stable/angle-staked-stable.js +228 -0
- package/build/dex/angle-staked-stable/angle-staked-stable.js.map +1 -0
- package/build/dex/{woo-fi → angle-staked-stable}/config.d.ts +1 -1
- package/build/dex/angle-staked-stable/config.js +139 -0
- package/build/dex/angle-staked-stable/config.js.map +1 -0
- package/build/dex/angle-staked-stable/types.d.ts +15 -0
- package/build/dex/angle-staked-stable/types.js.map +1 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.d.ts +61 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.js +415 -0
- package/build/dex/angle-transmuter/angle-transmuter-pool.js.map +1 -0
- package/build/dex/{lighter-v1/lighter-v1.d.ts → angle-transmuter/angle-transmuter.d.ts} +31 -17
- package/build/dex/angle-transmuter/angle-transmuter.js +262 -0
- package/build/dex/angle-transmuter/angle-transmuter.js.map +1 -0
- package/build/dex/angle-transmuter/backedOracle.d.ts +19 -0
- package/build/dex/angle-transmuter/backedOracle.js +56 -0
- package/build/dex/angle-transmuter/backedOracle.js.map +1 -0
- package/build/dex/{ramses-v2 → angle-transmuter}/config.d.ts +1 -1
- package/build/dex/angle-transmuter/config.js +30 -0
- package/build/dex/angle-transmuter/config.js.map +1 -0
- package/build/dex/angle-transmuter/constants.d.ts +77 -0
- package/build/dex/angle-transmuter/constants.js +94 -0
- package/build/dex/angle-transmuter/constants.js.map +1 -0
- package/build/dex/{integral/integral-pool.d.ts → angle-transmuter/morphoOracle.d.ts} +15 -12
- package/build/dex/angle-transmuter/morphoOracle.js +179 -0
- package/build/dex/angle-transmuter/morphoOracle.js.map +1 -0
- package/build/dex/angle-transmuter/morphoVault.d.ts +19 -0
- package/build/dex/angle-transmuter/morphoVault.js +78 -0
- package/build/dex/angle-transmuter/morphoVault.js.map +1 -0
- package/build/dex/angle-transmuter/pyth.d.ts +19 -0
- package/build/dex/angle-transmuter/pyth.js +70 -0
- package/build/dex/angle-transmuter/pyth.js.map +1 -0
- package/build/dex/angle-transmuter/redstone.d.ts +20 -0
- package/build/dex/angle-transmuter/redstone.js +73 -0
- package/build/dex/angle-transmuter/redstone.js.map +1 -0
- package/build/dex/angle-transmuter/transmuter.d.ts +52 -0
- package/build/dex/angle-transmuter/transmuter.js +374 -0
- package/build/dex/angle-transmuter/transmuter.js.map +1 -0
- package/build/dex/angle-transmuter/types.d.ts +188 -0
- package/build/dex/angle-transmuter/types.js +33 -0
- package/build/dex/angle-transmuter/types.js.map +1 -0
- package/build/dex/angle-transmuter/utils.d.ts +9 -0
- package/build/dex/angle-transmuter/utils.js +252 -0
- package/build/dex/angle-transmuter/utils.js.map +1 -0
- package/build/dex/curve-v1-factory/config.js +7 -7
- package/build/dex/curve-v1-factory/config.js.map +1 -1
- package/build/dex/curve-v1-factory/constants.d.ts +0 -1
- package/build/dex/curve-v1-factory/constants.js +1 -2
- package/build/dex/curve-v1-factory/constants.js.map +1 -1
- package/build/dex/index.js +2 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/smardex/subgraph-queries.d.ts +1 -0
- package/build/dex/smardex/subgraph-queries.js +17 -0
- package/build/dex/smardex/subgraph-queries.js.map +1 -0
- package/build/dex/smardex/usd-reserves.d.ts +23 -0
- package/build/dex/smardex/usd-reserves.js +86 -0
- package/build/dex/smardex/usd-reserves.js.map +1 -0
- package/build/dex/{integral → trader-joe-v2-1-2}/config.d.ts +1 -1
- package/build/dex/trader-joe-v2-1-2/config.js +47 -0
- package/build/dex/trader-joe-v2-1-2/config.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/constants.d.ts +20 -0
- package/build/dex/trader-joe-v2-1-2/constants.js +22 -0
- package/build/dex/trader-joe-v2-1-2/constants.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/math/index.d.ts +37 -0
- package/build/dex/trader-joe-v2-1-2/math/index.js +291 -0
- package/build/dex/trader-joe-v2-1-2/math/index.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.d.ts +60 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js +248 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.d.ts +53 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js +307 -0
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js.map +1 -0
- package/build/dex/trader-joe-v2-1-2/types.d.ts +82 -0
- package/build/dex/trader-joe-v2-1-2/types.js +9 -0
- package/build/dex/trader-joe-v2-1-2/types.js.map +1 -0
- package/build/dex/{lighter-v1 → trader-joe-v2_1}/config.d.ts +1 -1
- package/build/dex/trader-joe-v2_1/config.js +47 -0
- package/build/dex/trader-joe-v2_1/config.js.map +1 -0
- package/build/dex/trader-joe-v2_1/constants.d.ts +20 -0
- package/build/dex/trader-joe-v2_1/constants.js +22 -0
- package/build/dex/trader-joe-v2_1/constants.js.map +1 -0
- package/build/dex/trader-joe-v2_1/math/index.d.ts +37 -0
- package/build/dex/trader-joe-v2_1/math/index.js +291 -0
- package/build/dex/trader-joe-v2_1/math/index.js.map +1 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.d.ts +0 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js +384 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js.map +1 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.d.ts +60 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js +247 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js.map +1 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.d.ts +53 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js +307 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js.map +1 -0
- package/build/dex/trader-joe-v2_1/types.d.ts +82 -0
- package/build/dex/trader-joe-v2_1/types.js +9 -0
- package/build/dex/trader-joe-v2_1/types.js.map +1 -0
- package/build/dex/wombat/wombat-pool-poller.d.ts +22 -0
- package/build/dex/wombat/wombat-pool-poller.js +164 -0
- package/build/dex/wombat/wombat-pool-poller.js.map +1 -0
- package/build/dex/woo-fi-v2/config.js +4 -4
- package/build/dex-helper/Cache.d.ts +31 -0
- package/build/dex-helper/Cache.js +106 -0
- package/build/dex-helper/Cache.js.map +1 -0
- package/build/dex-helper/RedisBatcher.d.ts +20 -0
- package/build/dex-helper/RedisBatcher.js +75 -0
- package/build/dex-helper/RedisBatcher.js.map +1 -0
- package/build/dex-helper/RedisWrapper.d.ts +37 -0
- package/build/dex-helper/RedisWrapper.js +165 -0
- package/build/dex-helper/RedisWrapper.js.map +1 -0
- package/package.json +1 -1
- package/src/abi/angle/stagToken.json +963 -0
- package/src/config.ts +4 -2
- package/src/dex/angle-staked-stable/angle-staked-stable-e2e.test.ts +146 -0
- package/src/dex/angle-staked-stable/angle-staked-stable-events.test.ts +95 -0
- package/src/dex/angle-staked-stable/angle-staked-stable-integration.test.ts +474 -0
- package/src/dex/angle-staked-stable/angle-staked-stable-pool.ts +297 -0
- package/src/dex/angle-staked-stable/angle-staked-stable.ts +314 -0
- package/src/dex/angle-staked-stable/config.ts +139 -0
- package/src/dex/angle-staked-stable/types.ts +16 -0
- package/src/dex/curve-v1-factory/config.ts +8 -8
- package/src/dex/curve-v1-factory/constants.ts +0 -2
- package/src/dex/index.ts +2 -0
- package/src/dex/woo-fi-v2/config.ts +4 -4
- package/tests/constants-e2e.ts +112 -1
- package/.idea/aws.xml +0 -17
- package/.idea/codeStyles/Project.xml +0 -19
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/paraswap-dex-lib.iml +0 -9
- package/.idea/prettier.xml +0 -7
- package/.idea/vcs.xml +0 -6
- package/build/abi/AugustusV6.abi.json +0 -395
- package/build/abi/algebra/AlgebraPool.abi.json +0 -727
- package/build/abi/curve-v1/StableSwapFRXETH.json +0 -889
- package/build/abi/curve-v1/StableSwapWBETH.json +0 -1223
- package/build/abi/sushiswap-v3/QuoterV2.json +0 -267
- package/build/abi/sushiswap-v3/RouterProcessor3.json +0 -289
- package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
- package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3QuoterV2.abi.json +0 -285
- package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3Router.abi.json +0 -583
- package/build/abi/wBETH.json +0 -1527
- package/build/abi/woo-fi/WooFeeManager.abi.json +0 -318
- package/build/abi/woo-fi/WooPP.abi.json +0 -548
- package/build/abi/woo-fi/Wooracle.abi.json +0 -260
- package/build/dex/aave-v3/tokens/arbitrum.json +0 -50
- package/build/dex/aave-v3/tokens/avalanche.json +0 -74
- package/build/dex/aave-v3/tokens/fantom.json +0 -62
- package/build/dex/aave-v3/tokens/optimism.json +0 -50
- package/build/dex/aave-v3/tokens/polygon.json +0 -116
- package/build/dex/algebra/algebra-pool.d.ts +0 -114
- package/build/dex/algebra/algebra-pool.js +0 -448
- package/build/dex/algebra/algebra-pool.js.map +0 -1
- package/build/dex/balancer-v2/Gyro3Pool.d.ts +0 -43
- package/build/dex/balancer-v2/Gyro3Pool.js +0 -160
- package/build/dex/balancer-v2/Gyro3Pool.js.map +0 -1
- package/build/dex/balancer-v2/LinearMath.d.ts +0 -88
- package/build/dex/balancer-v2/LinearMath.js +0 -285
- package/build/dex/balancer-v2/LinearMath.js.map +0 -1
- package/build/dex/balancer-v2/LinearPool.d.ts +0 -81
- package/build/dex/balancer-v2/LinearPool.js +0 -444
- package/build/dex/balancer-v2/LinearPool.js.map +0 -1
- package/build/dex/balancer-v2/PhantomStablePool.d.ts +0 -90
- package/build/dex/balancer-v2/PhantomStablePool.js +0 -418
- package/build/dex/balancer-v2/PhantomStablePool.js.map +0 -1
- package/build/dex/balancer-v2/StableMath.d.ts +0 -9
- package/build/dex/balancer-v2/StableMath.js +0 -272
- package/build/dex/balancer-v2/StableMath.js.map +0 -1
- package/build/dex/balancer-v2/balancer-v2-pool.d.ts +0 -140
- package/build/dex/balancer-v2/balancer-v2-pool.js +0 -647
- package/build/dex/balancer-v2/balancer-v2-pool.js.map +0 -1
- package/build/dex/curve-v1/pools/frxETHpool.d.ts +0 -7
- package/build/dex/curve-v1/pools/frxETHpool.js +0 -27
- package/build/dex/curve-v1/pools/frxETHpool.js.map +0 -1
- package/build/dex/curve-v1/pools/wbETHpool.d.ts +0 -29
- package/build/dex/curve-v1/pools/wbETHpool.js +0 -408
- package/build/dex/curve-v1/pools/wbETHpool.js.map +0 -1
- package/build/dex/integral/config.js +0 -18
- package/build/dex/integral/config.js.map +0 -1
- package/build/dex/integral/integral-pool.js +0 -67
- package/build/dex/integral/integral-pool.js.map +0 -1
- package/build/dex/integral/integral.d.ts +0 -48
- package/build/dex/integral/integral.js +0 -402
- package/build/dex/integral/integral.js.map +0 -1
- package/build/dex/integral/types.d.ts +0 -25
- package/build/dex/integral/types.js +0 -9
- package/build/dex/integral/types.js.map +0 -1
- package/build/dex/lighter-v1/abi/factory.json +0 -291
- package/build/dex/lighter-v1/abi/order_book.json +0 -594
- package/build/dex/lighter-v1/abi/order_book_helper.json +0 -176
- package/build/dex/lighter-v1/abi/router.json +0 -488
- package/build/dex/lighter-v1/config.js +0 -17
- package/build/dex/lighter-v1/config.js.map +0 -1
- package/build/dex/lighter-v1/constants.d.ts +0 -2
- package/build/dex/lighter-v1/constants.js +0 -13
- package/build/dex/lighter-v1/constants.js.map +0 -1
- package/build/dex/lighter-v1/lighter-v1-pool.d.ts +0 -57
- package/build/dex/lighter-v1/lighter-v1-pool.js +0 -310
- package/build/dex/lighter-v1/lighter-v1-pool.js.map +0 -1
- package/build/dex/lighter-v1/lighter-v1.js +0 -331
- package/build/dex/lighter-v1/lighter-v1.js.map +0 -1
- package/build/dex/lighter-v1/types.d.ts +0 -40
- package/build/dex/lighter-v1/types.js.map +0 -1
- package/build/dex/pancakeswap-v3/types.d.ts +0 -14
- package/build/dex/pancakeswap-v3/types.js +0 -3
- package/build/dex/pancakeswap-v3/types.js.map +0 -1
- package/build/dex/quickswap/camelot-v3.d.ts +0 -6
- package/build/dex/quickswap/camelot-v3.js +0 -19
- package/build/dex/quickswap/camelot-v3.js.map +0 -1
- package/build/dex/quickswap/zyberswap-v3.d.ts +0 -6
- package/build/dex/quickswap/zyberswap-v3.js +0 -19
- package/build/dex/quickswap/zyberswap-v3.js.map +0 -1
- package/build/dex/quickswap-v3.d.ts +0 -21
- package/build/dex/quickswap-v3.js +0 -40
- package/build/dex/quickswap-v3.js.map +0 -1
- package/build/dex/ramses-v2/config.js +0 -28
- package/build/dex/ramses-v2/config.js.map +0 -1
- package/build/dex/ramses-v2/constants.d.ts +0 -28
- package/build/dex/ramses-v2/constants.js +0 -35
- package/build/dex/ramses-v2/constants.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/BitMath.d.ts +0 -4
- package/build/dex/ramses-v2/contract-math/BitMath.js +0 -93
- package/build/dex/ramses-v2/contract-math/BitMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/FixedPoint128.d.ts +0 -3
- package/build/dex/ramses-v2/contract-math/FixedPoint128.js +0 -8
- package/build/dex/ramses-v2/contract-math/FixedPoint128.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/FixedPoint96.d.ts +0 -4
- package/build/dex/ramses-v2/contract-math/FixedPoint96.js +0 -9
- package/build/dex/ramses-v2/contract-math/FixedPoint96.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/FullMath.d.ts +0 -4
- package/build/dex/ramses-v2/contract-math/FullMath.js +0 -19
- package/build/dex/ramses-v2/contract-math/FullMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/LiquidityMath.d.ts +0 -3
- package/build/dex/ramses-v2/contract-math/LiquidityMath.js +0 -22
- package/build/dex/ramses-v2/contract-math/LiquidityMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/Oracle.d.ts +0 -10
- package/build/dex/ramses-v2/contract-math/Oracle.js +0 -133
- package/build/dex/ramses-v2/contract-math/Oracle.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/SqrtPriceMath.d.ts +0 -10
- package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js +0 -91
- package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/SwapMath.d.ts +0 -8
- package/build/dex/ramses-v2/contract-math/SwapMath.js +0 -70
- package/build/dex/ramses-v2/contract-math/SwapMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/Tick.d.ts +0 -7
- package/build/dex/ramses-v2/contract-math/Tick.js +0 -45
- package/build/dex/ramses-v2/contract-math/Tick.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/TickBitMap.d.ts +0 -8
- package/build/dex/ramses-v2/contract-math/TickBitMap.js +0 -87
- package/build/dex/ramses-v2/contract-math/TickBitMap.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/TickMath.d.ts +0 -8
- package/build/dex/ramses-v2/contract-math/TickMath.js +0 -162
- package/build/dex/ramses-v2/contract-math/TickMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/UnsafeMath.d.ts +0 -3
- package/build/dex/ramses-v2/contract-math/UnsafeMath.js +0 -10
- package/build/dex/ramses-v2/contract-math/UnsafeMath.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/uniswap-v3-math.d.ts +0 -18
- package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js +0 -392
- package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js.map +0 -1
- package/build/dex/ramses-v2/contract-math/utils.d.ts +0 -3
- package/build/dex/ramses-v2/contract-math/utils.js +0 -16
- package/build/dex/ramses-v2/contract-math/utils.js.map +0 -1
- package/build/dex/ramses-v2/ramses-v2-pool.d.ts +0 -42
- package/build/dex/ramses-v2/ramses-v2-pool.js +0 -307
- package/build/dex/ramses-v2/ramses-v2-pool.js.map +0 -1
- package/build/dex/ramses-v2/ramses-v2.d.ts +0 -61
- package/build/dex/ramses-v2/ramses-v2.js +0 -690
- package/build/dex/ramses-v2/ramses-v2.js.map +0 -1
- package/build/dex/ramses-v2/types.d.ts +0 -154
- package/build/dex/ramses-v2/types.js +0 -9
- package/build/dex/ramses-v2/types.js.map +0 -1
- package/build/dex/ramses-v2/utils.d.ts +0 -6
- package/build/dex/ramses-v2/utils.js +0 -71
- package/build/dex/ramses-v2/utils.js.map +0 -1
- package/build/dex/solidly/forks-override/fvm.d.ts +0 -20
- package/build/dex/solidly/forks-override/fvm.js +0 -42
- package/build/dex/solidly/forks-override/fvm.js.map +0 -1
- package/build/dex/sushiswap-v3/config.d.ts +0 -4
- package/build/dex/sushiswap-v3/config.js +0 -132
- package/build/dex/sushiswap-v3/config.js.map +0 -1
- package/build/dex/sushiswap-v3/constants.d.ts +0 -4
- package/build/dex/sushiswap-v3/constants.js +0 -32
- package/build/dex/sushiswap-v3/constants.js.map +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3-original.d.ts +0 -56
- package/build/dex/sushiswap-v3/sushiswap-v3-original.js +0 -598
- package/build/dex/sushiswap-v3/sushiswap-v3-original.js.map +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.d.ts +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.js +0 -6
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.js.map +0 -1
- package/build/dex/sushiswap-v3/sushiswap-v3.d.ts +0 -21
- package/build/dex/sushiswap-v3/sushiswap-v3.js +0 -58
- package/build/dex/sushiswap-v3/sushiswap-v3.js.map +0 -1
- package/build/dex/sushiswap-v3/token.d.ts +0 -6
- package/build/dex/sushiswap-v3/token.js +0 -23
- package/build/dex/sushiswap-v3/token.js.map +0 -1
- package/build/dex/sushiswap-v3/types.d.ts +0 -15
- package/build/dex/sushiswap-v3/types.js +0 -18
- package/build/dex/sushiswap-v3/types.js.map +0 -1
- package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.d.ts +0 -12
- package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js +0 -23
- package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js.map +0 -1
- package/build/dex/woo-fi/config.js +0 -141
- package/build/dex/woo-fi/config.js.map +0 -1
- package/build/dex/woo-fi/constants.d.ts +0 -5
- package/build/dex/woo-fi/constants.js +0 -20
- package/build/dex/woo-fi/constants.js.map +0 -1
- package/build/dex/woo-fi/types.d.ts +0 -48
- package/build/dex/woo-fi/types.js +0 -3
- package/build/dex/woo-fi/types.js.map +0 -1
- package/build/dex/woo-fi/woo-fi-decimal-math.d.ts +0 -14
- package/build/dex/woo-fi/woo-fi-decimal-math.js +0 -42
- package/build/dex/woo-fi/woo-fi-decimal-math.js.map +0 -1
- package/build/dex/woo-fi/woo-fi-math.d.ts +0 -31
- package/build/dex/woo-fi/woo-fi-math.js +0 -300
- package/build/dex/woo-fi/woo-fi-math.js.map +0 -1
- package/build/dex/woo-fi/woo-fi.d.ts +0 -65
- package/build/dex/woo-fi/woo-fi.js +0 -480
- package/build/dex/woo-fi/woo-fi.js.map +0 -1
- package/build/executor/Executor01BytecodeBuilder.d.ts +0 -77
- package/build/executor/Executor01BytecodeBuilder.js +0 -359
- package/build/executor/Executor01BytecodeBuilder.js.map +0 -1
- package/build/executor/Executor02BytecodeBuilder.d.ts +0 -12
- package/build/executor/Executor02BytecodeBuilder.js +0 -14
- package/build/executor/Executor02BytecodeBuilder.js.map +0 -1
- package/build/executor/ExecutorDetector.d.ts +0 -28
- package/build/executor/ExecutorDetector.js +0 -89
- package/build/executor/ExecutorDetector.js.map +0 -1
- package/build/executor/IExecutorBytecodeBuilder.d.ts +0 -6
- package/build/executor/IExecutorBytecodeBuilder.js +0 -3
- package/build/executor/IExecutorBytecodeBuilder.js.map +0 -1
- package/build/generic-swap-transaction-builder.d.ts +0 -39
- package/build/generic-swap-transaction-builder.js +0 -156
- package/build/generic-swap-transaction-builder.js.map +0 -1
- /package/build/dex/{lighter-v1 → angle-staked-stable}/types.js +0 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import type { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import type { BlockHeader, Log, Logger } from '../../types';
|
|
4
|
+
import {
|
|
5
|
+
bigIntify,
|
|
6
|
+
catchParseLogError,
|
|
7
|
+
currentBigIntTimestampInS,
|
|
8
|
+
} from '../../utils';
|
|
9
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
10
|
+
import type { IDexHelper } from '../../dex-helper/idex-helper';
|
|
11
|
+
import type { DexParams, PoolState } from './types';
|
|
12
|
+
import StakedStableABI from '../../abi/angle/stagToken.json';
|
|
13
|
+
import ERC20ABI from '../../abi/erc20.json';
|
|
14
|
+
|
|
15
|
+
export class AngleStakedStableEventPool extends StatefulEventSubscriber<PoolState> {
|
|
16
|
+
handlers: {
|
|
17
|
+
[event: string]: (
|
|
18
|
+
event: any,
|
|
19
|
+
state: DeepReadonly<PoolState>,
|
|
20
|
+
log: Readonly<Log>,
|
|
21
|
+
blockHeader: Readonly<BlockHeader>,
|
|
22
|
+
) => DeepReadonly<PoolState> | null;
|
|
23
|
+
} = {};
|
|
24
|
+
|
|
25
|
+
static angleStakedStableIface = new Interface(StakedStableABI);
|
|
26
|
+
static erc20Iface = new Interface(ERC20ABI);
|
|
27
|
+
|
|
28
|
+
logDecoder: (log: Log) => any;
|
|
29
|
+
|
|
30
|
+
addressesSubscribed: string[];
|
|
31
|
+
|
|
32
|
+
BASE_27 = BigInt(1e27);
|
|
33
|
+
HALF_BASE_27 = BigInt(1e27 / 2);
|
|
34
|
+
ZERO = BigInt(0);
|
|
35
|
+
|
|
36
|
+
constructor(
|
|
37
|
+
readonly parentName: string,
|
|
38
|
+
protected network: number,
|
|
39
|
+
protected dexHelper: IDexHelper,
|
|
40
|
+
public stakeToken: string,
|
|
41
|
+
public agToken: string,
|
|
42
|
+
logger: Logger,
|
|
43
|
+
) {
|
|
44
|
+
super(parentName, 'Staked_Stable', dexHelper, logger);
|
|
45
|
+
|
|
46
|
+
this.logDecoder = (log: Log) =>
|
|
47
|
+
AngleStakedStableEventPool.angleStakedStableIface.parseLog(log);
|
|
48
|
+
this.addressesSubscribed = [stakeToken];
|
|
49
|
+
|
|
50
|
+
// Add handlers
|
|
51
|
+
this.handlers.Accrued = this.handleAccrued.bind(this);
|
|
52
|
+
this.handlers.Deposit = this.handleDeposit.bind(this);
|
|
53
|
+
this.handlers.Withdraw = this.handleWithdraw.bind(this);
|
|
54
|
+
this.handlers.ToggledPause = this.handleToggledPause.bind(this);
|
|
55
|
+
this.handlers.RateUpdated = this.handleRateUpdated.bind(this);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The function is called every time any of the subscribed
|
|
60
|
+
* addresses release log. The function accepts the current
|
|
61
|
+
* state, updates the state according to the log, and returns
|
|
62
|
+
* the updated state.
|
|
63
|
+
* @param state - Current state of event subscriber
|
|
64
|
+
* @param log - Log released by one of the subscribed addresses
|
|
65
|
+
* @returns Updates state of the event subscriber after the log
|
|
66
|
+
*/
|
|
67
|
+
protected processLog(
|
|
68
|
+
state: DeepReadonly<PoolState>,
|
|
69
|
+
log: Readonly<Log>,
|
|
70
|
+
blockHeader: Readonly<BlockHeader>,
|
|
71
|
+
): DeepReadonly<PoolState> | null {
|
|
72
|
+
try {
|
|
73
|
+
const event = this.logDecoder(log);
|
|
74
|
+
if (event.name in this.handlers) {
|
|
75
|
+
return this.handlers[event.name](event, state, log, blockHeader);
|
|
76
|
+
}
|
|
77
|
+
} catch (e) {
|
|
78
|
+
catchParseLogError(e, this.logger);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The function generates state using on-chain calls. This
|
|
86
|
+
* function is called to regenerate state if the event based
|
|
87
|
+
* system fails to fetch events and the local state is no
|
|
88
|
+
* more correct.
|
|
89
|
+
* @param blockNumber - Blocknumber for which the state should
|
|
90
|
+
* should be generated
|
|
91
|
+
* @returns state of the event subscriber at blocknumber
|
|
92
|
+
*/
|
|
93
|
+
async generateState(blockNumber: number): Promise<DeepReadonly<PoolState>> {
|
|
94
|
+
const poolState = {
|
|
95
|
+
totalAssets: 0n,
|
|
96
|
+
totalSupply: 0n,
|
|
97
|
+
lastUpdate: 0n,
|
|
98
|
+
paused: false,
|
|
99
|
+
rate: 0n,
|
|
100
|
+
} as PoolState;
|
|
101
|
+
|
|
102
|
+
const multicall = [
|
|
103
|
+
{
|
|
104
|
+
target: this.agToken,
|
|
105
|
+
callData: AngleStakedStableEventPool.erc20Iface.encodeFunctionData(
|
|
106
|
+
'balanceOf',
|
|
107
|
+
[this.stakeToken],
|
|
108
|
+
),
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
target: this.stakeToken,
|
|
112
|
+
callData:
|
|
113
|
+
AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
114
|
+
'totalSupply',
|
|
115
|
+
),
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
target: this.stakeToken,
|
|
119
|
+
callData:
|
|
120
|
+
AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
121
|
+
'lastUpdate',
|
|
122
|
+
),
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
target: this.stakeToken,
|
|
126
|
+
callData:
|
|
127
|
+
AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
128
|
+
'paused',
|
|
129
|
+
),
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
target: this.stakeToken,
|
|
133
|
+
callData:
|
|
134
|
+
AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
135
|
+
'rate',
|
|
136
|
+
),
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
// on chain call
|
|
141
|
+
const returnData = (
|
|
142
|
+
await this.dexHelper.multiContract.methods
|
|
143
|
+
.aggregate(multicall)
|
|
144
|
+
.call({}, blockNumber)
|
|
145
|
+
).returnData;
|
|
146
|
+
|
|
147
|
+
// Decode
|
|
148
|
+
poolState.totalAssets = bigIntify(
|
|
149
|
+
AngleStakedStableEventPool.erc20Iface.decodeFunctionResult(
|
|
150
|
+
'balanceOf',
|
|
151
|
+
returnData[0],
|
|
152
|
+
)[0],
|
|
153
|
+
);
|
|
154
|
+
poolState.totalSupply = bigIntify(
|
|
155
|
+
AngleStakedStableEventPool.angleStakedStableIface.decodeFunctionResult(
|
|
156
|
+
'totalSupply',
|
|
157
|
+
returnData[1],
|
|
158
|
+
)[0],
|
|
159
|
+
);
|
|
160
|
+
poolState.lastUpdate = bigIntify(
|
|
161
|
+
AngleStakedStableEventPool.angleStakedStableIface.decodeFunctionResult(
|
|
162
|
+
'lastUpdate',
|
|
163
|
+
returnData[2],
|
|
164
|
+
)[0],
|
|
165
|
+
);
|
|
166
|
+
poolState.paused =
|
|
167
|
+
AngleStakedStableEventPool.angleStakedStableIface.decodeFunctionResult(
|
|
168
|
+
'paused',
|
|
169
|
+
returnData[3],
|
|
170
|
+
)[0] as boolean;
|
|
171
|
+
|
|
172
|
+
poolState.rate = bigIntify(
|
|
173
|
+
AngleStakedStableEventPool.angleStakedStableIface.decodeFunctionResult(
|
|
174
|
+
'rate',
|
|
175
|
+
returnData[4],
|
|
176
|
+
)[0],
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
return poolState;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
getRateDeposit(amount: bigint, state: PoolState): bigint {
|
|
183
|
+
const newTotalAssets = this._accrue(state);
|
|
184
|
+
return amount === 0n || state.totalSupply === 0n
|
|
185
|
+
? amount
|
|
186
|
+
: (amount * state.totalSupply) / newTotalAssets;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
getRateMint(shares: bigint, state: PoolState): bigint {
|
|
190
|
+
const newTotalAssets = this._accrue(state);
|
|
191
|
+
const roundUp =
|
|
192
|
+
(shares * newTotalAssets) % state.totalSupply > 0n ? 1n : 0n;
|
|
193
|
+
return state.totalSupply === 0n
|
|
194
|
+
? shares
|
|
195
|
+
: (shares * newTotalAssets) / state.totalSupply + roundUp;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
getRateRedeem(shares: bigint, state: PoolState): bigint {
|
|
199
|
+
const newTotalAssets = this._accrue(state);
|
|
200
|
+
return state.totalSupply === 0n
|
|
201
|
+
? shares
|
|
202
|
+
: (shares * newTotalAssets) / state.totalSupply;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
getRateWithdraw(amount: bigint, state: PoolState): bigint {
|
|
206
|
+
const newTotalAssets = this._accrue(state);
|
|
207
|
+
const roundUp =
|
|
208
|
+
(amount * state.totalSupply) % newTotalAssets > 0n ? 1n : 0n;
|
|
209
|
+
return amount === 0n || state.totalSupply === 0n
|
|
210
|
+
? amount
|
|
211
|
+
: (amount * state.totalSupply) / newTotalAssets + roundUp;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
_accrue(state: PoolState): bigint {
|
|
215
|
+
const newTotalAssets = this._computeUpdatedAssets(
|
|
216
|
+
state.totalAssets,
|
|
217
|
+
state.rate,
|
|
218
|
+
currentBigIntTimestampInS() - state.lastUpdate,
|
|
219
|
+
);
|
|
220
|
+
return newTotalAssets;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
_computeUpdatedAssets(amount: bigint, rate: bigint, exp: bigint): bigint {
|
|
224
|
+
if (exp === 0n || rate === 0n) return amount;
|
|
225
|
+
const expMinusOne = exp - 1n;
|
|
226
|
+
const expMinusTwo = exp > 2n ? exp - 2n : 0n;
|
|
227
|
+
const basePowerTwo = (rate * rate + this.HALF_BASE_27) / this.BASE_27;
|
|
228
|
+
const basePowerThree =
|
|
229
|
+
(basePowerTwo * rate + this.HALF_BASE_27) / this.BASE_27;
|
|
230
|
+
const secondTerm = (exp * expMinusOne * basePowerTwo) / 2n;
|
|
231
|
+
const thirdTerm = (exp * expMinusOne * expMinusTwo * basePowerThree) / 6n;
|
|
232
|
+
return (
|
|
233
|
+
(amount * (this.BASE_27 + rate * exp + secondTerm + thirdTerm)) /
|
|
234
|
+
this.BASE_27
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
handleAccrued(
|
|
239
|
+
event: any,
|
|
240
|
+
state: PoolState,
|
|
241
|
+
log: Readonly<Log>,
|
|
242
|
+
blockHeader: BlockHeader,
|
|
243
|
+
): DeepReadonly<PoolState> | null {
|
|
244
|
+
const interest = bigIntify(event.args.interest);
|
|
245
|
+
state.totalAssets += interest;
|
|
246
|
+
state.lastUpdate = bigIntify(blockHeader.timestamp);
|
|
247
|
+
return state;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
handleRateUpdated(
|
|
251
|
+
event: any,
|
|
252
|
+
state: PoolState,
|
|
253
|
+
log: Readonly<Log>,
|
|
254
|
+
blockHeader: BlockHeader,
|
|
255
|
+
): DeepReadonly<PoolState> | null {
|
|
256
|
+
state.rate = bigIntify(event.args.newRate);
|
|
257
|
+
return state;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
handleDeposit(
|
|
261
|
+
event: any,
|
|
262
|
+
state: PoolState,
|
|
263
|
+
log: Readonly<Log>,
|
|
264
|
+
blockHeader: BlockHeader,
|
|
265
|
+
): DeepReadonly<PoolState> | null {
|
|
266
|
+
const assets = bigIntify(event.args.assets);
|
|
267
|
+
const shares = bigIntify(event.args.shares);
|
|
268
|
+
state.totalAssets += assets;
|
|
269
|
+
state.totalSupply += shares;
|
|
270
|
+
state.lastUpdate = bigIntify(blockHeader.timestamp);
|
|
271
|
+
return state;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
handleWithdraw(
|
|
275
|
+
event: any,
|
|
276
|
+
state: PoolState,
|
|
277
|
+
log: Readonly<Log>,
|
|
278
|
+
blockHeader: BlockHeader,
|
|
279
|
+
): DeepReadonly<PoolState> | null {
|
|
280
|
+
const assets = bigIntify(event.args.assets);
|
|
281
|
+
const shares = bigIntify(event.args.shares);
|
|
282
|
+
state.totalAssets -= assets;
|
|
283
|
+
state.totalSupply -= shares;
|
|
284
|
+
state.lastUpdate = bigIntify(blockHeader.timestamp);
|
|
285
|
+
return state;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
handleToggledPause(
|
|
289
|
+
event: any,
|
|
290
|
+
state: PoolState,
|
|
291
|
+
log: Readonly<Log>,
|
|
292
|
+
): DeepReadonly<PoolState> | null {
|
|
293
|
+
const pauseStatus: boolean = event.args.pauseStatus;
|
|
294
|
+
state.paused = pauseStatus;
|
|
295
|
+
return state;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import type { AsyncOrSync } from 'ts-essentials';
|
|
3
|
+
import type {
|
|
4
|
+
Token,
|
|
5
|
+
Address,
|
|
6
|
+
ExchangePrices,
|
|
7
|
+
PoolPrices,
|
|
8
|
+
AdapterExchangeParam,
|
|
9
|
+
SimpleExchangeParam,
|
|
10
|
+
PoolLiquidity,
|
|
11
|
+
Logger,
|
|
12
|
+
} from '../../types';
|
|
13
|
+
import { SwapSide, type Network } from '../../constants';
|
|
14
|
+
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
|
|
15
|
+
import { getDexKeysWithNetwork } from '../../utils';
|
|
16
|
+
import type { IDex } from '../../dex/idex';
|
|
17
|
+
import type { IDexHelper } from '../../dex-helper/idex-helper';
|
|
18
|
+
import type { AngleStakedStableData, DexParams } from './types';
|
|
19
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
20
|
+
import { AngleStakedStableConfig, Adapters } from './config';
|
|
21
|
+
import { AngleStakedStableEventPool } from './angle-staked-stable-pool';
|
|
22
|
+
import StakedStableABI from '../../abi/angle/stagToken.json';
|
|
23
|
+
|
|
24
|
+
const AngleStakedGasCost = 0;
|
|
25
|
+
|
|
26
|
+
export class AngleStakedStable
|
|
27
|
+
extends SimpleExchange
|
|
28
|
+
implements IDex<AngleStakedStableData>
|
|
29
|
+
{
|
|
30
|
+
static readonly wstETHIface = new Interface(StakedStableABI);
|
|
31
|
+
protected config: DexParams;
|
|
32
|
+
|
|
33
|
+
readonly hasConstantPriceLargeAmounts = false;
|
|
34
|
+
readonly needWrapNative = true;
|
|
35
|
+
|
|
36
|
+
readonly isFeeOnTransferSupported = false;
|
|
37
|
+
|
|
38
|
+
public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
|
|
39
|
+
getDexKeysWithNetwork(AngleStakedStableConfig);
|
|
40
|
+
|
|
41
|
+
logger: Logger;
|
|
42
|
+
|
|
43
|
+
protected eventPools: { [key: string]: AngleStakedStableEventPool } = {};
|
|
44
|
+
protected isPaused: { [key: string]: boolean } = {};
|
|
45
|
+
|
|
46
|
+
constructor(
|
|
47
|
+
readonly network: Network,
|
|
48
|
+
readonly dexKey: string,
|
|
49
|
+
readonly dexHelper: IDexHelper,
|
|
50
|
+
protected adapters = Adapters[network] || {},
|
|
51
|
+
) {
|
|
52
|
+
super(dexHelper, dexKey);
|
|
53
|
+
const config = AngleStakedStableConfig[dexKey][network];
|
|
54
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
55
|
+
this.config = {
|
|
56
|
+
stakeToken: config.stakeToken.toLowerCase(),
|
|
57
|
+
agToken: config.agToken.toLowerCase(),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async initializePricing(blockNumber: number) {
|
|
62
|
+
this.eventPools[this.config.stakeToken] = new AngleStakedStableEventPool(
|
|
63
|
+
`${this.dexKey}_${this.config.stakeToken!.toLowerCase()}`,
|
|
64
|
+
this.network,
|
|
65
|
+
this.dexHelper,
|
|
66
|
+
this.config.stakeToken,
|
|
67
|
+
this.config.agToken,
|
|
68
|
+
this.logger,
|
|
69
|
+
);
|
|
70
|
+
await this.eventPools[this.config.stakeToken].initialize(blockNumber);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
getAdapters(side: SwapSide): { name: string; index: number }[] | null {
|
|
74
|
+
return this.adapters[side] ? this.adapters[side] : null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async getPoolIdentifiers(
|
|
78
|
+
srcToken: Token,
|
|
79
|
+
destToken: Token,
|
|
80
|
+
side: SwapSide,
|
|
81
|
+
blockNumber: number,
|
|
82
|
+
): Promise<string[]> {
|
|
83
|
+
const knownInfo = this._knownAddress(srcToken, destToken);
|
|
84
|
+
if (!knownInfo.known) return [];
|
|
85
|
+
return [`${this.dexKey}_${knownInfo.stakeToken!.toLowerCase()}`];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async getPricesVolume(
|
|
89
|
+
srcToken: Token,
|
|
90
|
+
destToken: Token,
|
|
91
|
+
amounts: bigint[],
|
|
92
|
+
side: SwapSide,
|
|
93
|
+
blockNumber: number,
|
|
94
|
+
limitPools?: string[],
|
|
95
|
+
): Promise<null | ExchangePrices<AngleStakedStableData>> {
|
|
96
|
+
const srcTokenAddress = srcToken.address.toLowerCase();
|
|
97
|
+
const destTokenAddress = destToken.address.toLowerCase();
|
|
98
|
+
const knownInfo = this._knownAddress(srcToken, destToken);
|
|
99
|
+
if (!knownInfo.known) return null;
|
|
100
|
+
|
|
101
|
+
const agToken = knownInfo.agToken!;
|
|
102
|
+
const stakeToken = knownInfo.stakeToken!;
|
|
103
|
+
const eventPool = this.eventPools[stakeToken];
|
|
104
|
+
const exchange = `${this.dexKey}`;
|
|
105
|
+
const state = eventPool?.getState(blockNumber);
|
|
106
|
+
if (this.eventPools === null || state === undefined || state === null)
|
|
107
|
+
return null;
|
|
108
|
+
if (srcTokenAddress === agToken && side === SwapSide.SELL)
|
|
109
|
+
return [
|
|
110
|
+
{
|
|
111
|
+
prices: amounts.map(amount =>
|
|
112
|
+
eventPool.getRateDeposit(amount, state),
|
|
113
|
+
),
|
|
114
|
+
unit: eventPool.getRateDeposit(1n * BigInt(10 ** 18), state),
|
|
115
|
+
gasCost: AngleStakedGasCost,
|
|
116
|
+
exchange: exchange,
|
|
117
|
+
data: { exchange: `${stakeToken}` },
|
|
118
|
+
poolAddresses: [`${stakeToken}`],
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
if (destTokenAddress === agToken && side === SwapSide.SELL)
|
|
122
|
+
return [
|
|
123
|
+
{
|
|
124
|
+
prices: amounts.map(share => eventPool.getRateRedeem(share, state)),
|
|
125
|
+
unit: eventPool.getRateRedeem(1n * BigInt(10 ** 18), state),
|
|
126
|
+
gasCost: AngleStakedGasCost,
|
|
127
|
+
exchange: exchange,
|
|
128
|
+
data: { exchange: `${stakeToken}` },
|
|
129
|
+
poolAddresses: [`${stakeToken}_${agToken}`],
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
if (srcTokenAddress === agToken && side === SwapSide.BUY)
|
|
133
|
+
return [
|
|
134
|
+
{
|
|
135
|
+
prices: amounts.map(share => eventPool.getRateMint(share, state)),
|
|
136
|
+
unit: eventPool.getRateMint(1n * BigInt(10 ** 18), state),
|
|
137
|
+
gasCost: AngleStakedGasCost,
|
|
138
|
+
exchange: exchange,
|
|
139
|
+
data: { exchange: `${stakeToken}` },
|
|
140
|
+
poolAddresses: [`${stakeToken}_${agToken}`],
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
return [
|
|
144
|
+
{
|
|
145
|
+
prices: amounts.map(amount => eventPool.getRateWithdraw(amount, state)),
|
|
146
|
+
unit: eventPool.getRateWithdraw(1n * BigInt(10 ** 18), state),
|
|
147
|
+
gasCost: AngleStakedGasCost,
|
|
148
|
+
exchange: exchange,
|
|
149
|
+
data: { exchange: `${stakeToken}` },
|
|
150
|
+
poolAddresses: [`${stakeToken}_${agToken}`],
|
|
151
|
+
},
|
|
152
|
+
];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
156
|
+
getCalldataGasCost(
|
|
157
|
+
poolPrices: PoolPrices<AngleStakedStableData>,
|
|
158
|
+
): number | number[] {
|
|
159
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
getAdapterParam(
|
|
163
|
+
srcToken: string,
|
|
164
|
+
destToken: string,
|
|
165
|
+
srcAmount: string,
|
|
166
|
+
destAmount: string,
|
|
167
|
+
data: AngleStakedStableData,
|
|
168
|
+
side: SwapSide,
|
|
169
|
+
): AdapterExchangeParam {
|
|
170
|
+
const { exchange } = data;
|
|
171
|
+
|
|
172
|
+
const payload = this.abiCoder.encodeParameter(
|
|
173
|
+
{
|
|
174
|
+
ParentStruct: {
|
|
175
|
+
toStaked: 'bool',
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
toStaked: srcToken.toLowerCase() === this.config.agToken,
|
|
180
|
+
},
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
targetExchange: exchange,
|
|
185
|
+
payload,
|
|
186
|
+
networkFee: '0',
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Encode call data used by simpleSwap like routers
|
|
191
|
+
// Used for simpleSwap & simpleBuy
|
|
192
|
+
// Hint: this.buildSimpleParamWithoutWETHConversion
|
|
193
|
+
// could be useful
|
|
194
|
+
async getSimpleParam(
|
|
195
|
+
srcToken: string,
|
|
196
|
+
destToken: string,
|
|
197
|
+
srcAmount: string,
|
|
198
|
+
destAmount: string,
|
|
199
|
+
data: AngleStakedStableData,
|
|
200
|
+
side: SwapSide,
|
|
201
|
+
): Promise<SimpleExchangeParam> {
|
|
202
|
+
const { exchange } = data;
|
|
203
|
+
|
|
204
|
+
// Encode here the transaction arguments
|
|
205
|
+
const swapData =
|
|
206
|
+
srcToken.toLowerCase() === this.config.agToken
|
|
207
|
+
? AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
208
|
+
side === SwapSide.SELL ? 'deposit' : 'mint',
|
|
209
|
+
[
|
|
210
|
+
side === SwapSide.SELL ? srcAmount : destAmount,
|
|
211
|
+
this.augustusAddress,
|
|
212
|
+
],
|
|
213
|
+
)
|
|
214
|
+
: AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
215
|
+
side === SwapSide.SELL ? 'redeem' : 'withdraw',
|
|
216
|
+
[
|
|
217
|
+
side === SwapSide.SELL ? srcAmount : destAmount,
|
|
218
|
+
this.augustusAddress,
|
|
219
|
+
this.augustusAddress,
|
|
220
|
+
],
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
return this.buildSimpleParamWithoutWETHConversion(
|
|
224
|
+
srcToken,
|
|
225
|
+
srcAmount,
|
|
226
|
+
destToken,
|
|
227
|
+
destAmount,
|
|
228
|
+
swapData,
|
|
229
|
+
exchange,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// This is called once before getTopPoolsForToken is
|
|
234
|
+
// called for multiple tokens. This can be helpful to
|
|
235
|
+
// update common state required for calculating
|
|
236
|
+
// getTopPoolsForToken. It is optional for a DEX
|
|
237
|
+
// to implement this
|
|
238
|
+
async updatePoolState(): Promise<void> {
|
|
239
|
+
const tokenBalanceMultiCall = [
|
|
240
|
+
{
|
|
241
|
+
target: this.config.stakeToken,
|
|
242
|
+
callData:
|
|
243
|
+
AngleStakedStableEventPool.angleStakedStableIface.encodeFunctionData(
|
|
244
|
+
'paused',
|
|
245
|
+
),
|
|
246
|
+
},
|
|
247
|
+
];
|
|
248
|
+
const returnData = (
|
|
249
|
+
await this.dexHelper.multiContract.methods
|
|
250
|
+
.aggregate(tokenBalanceMultiCall)
|
|
251
|
+
.call()
|
|
252
|
+
).returnData;
|
|
253
|
+
|
|
254
|
+
this.isPaused[this.config.stakeToken] =
|
|
255
|
+
AngleStakedStableEventPool.angleStakedStableIface.decodeFunctionResult(
|
|
256
|
+
'paused',
|
|
257
|
+
returnData[0],
|
|
258
|
+
)[0] as boolean;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Returns list of top pools based on liquidity. Max
|
|
262
|
+
// limit number pools should be returned.
|
|
263
|
+
async getTopPoolsForToken(
|
|
264
|
+
tokenAddress: Address,
|
|
265
|
+
limit: number,
|
|
266
|
+
): Promise<PoolLiquidity[]> {
|
|
267
|
+
if (
|
|
268
|
+
this.isPaused[this.config.stakeToken] ||
|
|
269
|
+
(tokenAddress.toLowerCase() !== this.config.agToken &&
|
|
270
|
+
tokenAddress.toLowerCase() !== this.config.stakeToken)
|
|
271
|
+
) {
|
|
272
|
+
return [];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return [
|
|
276
|
+
{
|
|
277
|
+
exchange: `${this.dexKey}_${this.config.stakeToken!.toLowerCase()}`,
|
|
278
|
+
address: this.config.stakeToken,
|
|
279
|
+
connectorTokens: [
|
|
280
|
+
tokenAddress.toLowerCase() === this.config.agToken
|
|
281
|
+
? ({ address: this.config.stakeToken, decimals: 18 } as Token)
|
|
282
|
+
: ({ address: this.config.agToken, decimals: 18 } as Token),
|
|
283
|
+
],
|
|
284
|
+
// liquidity is infinite as to have been able to mint stakeToken, you must have deposited agToken
|
|
285
|
+
liquidityUSD: 1e12,
|
|
286
|
+
},
|
|
287
|
+
];
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// This is optional function in case if your implementation has acquired any resources
|
|
291
|
+
// you need to release for graceful shutdown. For example, it may be any interval timer
|
|
292
|
+
releaseResources(): AsyncOrSync<void> {}
|
|
293
|
+
|
|
294
|
+
_knownAddress(
|
|
295
|
+
srcToken: Token,
|
|
296
|
+
destToken: Token,
|
|
297
|
+
): { known: boolean; agToken: string | null; stakeToken: string | null } {
|
|
298
|
+
const srcTokenAddress = srcToken.address.toLowerCase();
|
|
299
|
+
const destTokenAddress = destToken.address.toLowerCase();
|
|
300
|
+
if (
|
|
301
|
+
(srcTokenAddress === this.config.agToken &&
|
|
302
|
+
destTokenAddress === this.config.stakeToken) ||
|
|
303
|
+
(srcTokenAddress === this.config.stakeToken &&
|
|
304
|
+
destTokenAddress === this.config.agToken)
|
|
305
|
+
) {
|
|
306
|
+
return {
|
|
307
|
+
known: true,
|
|
308
|
+
agToken: this.config.agToken,
|
|
309
|
+
stakeToken: this.config.stakeToken,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
return { known: false, agToken: null, stakeToken: null };
|
|
313
|
+
}
|
|
314
|
+
}
|