@paraswap/dex-lib 3.3.0 → 3.3.1-return-amount-pos.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/.idea/aws.xml +17 -0
- package/.idea/codeStyles/Project.xml +19 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/paraswap-dex-lib.iml +9 -0
- package/.idea/prettier.xml +7 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +12 -0
- package/build/abi/AugustusV6.abi.json +395 -0
- package/build/abi/algebra/AlgebraPool.abi.json +727 -0
- package/build/abi/curve-v1/StableSwapFRXETH.json +889 -0
- package/build/abi/curve-v1/StableSwapWBETH.json +1223 -0
- package/build/abi/{wombat/pool.json → integral/relayer.json} +446 -587
- package/build/abi/sushiswap-v3/QuoterV2.json +267 -0
- package/build/abi/sushiswap-v3/RouterProcessor3.json +289 -0
- package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +193 -0
- package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3QuoterV2.abi.json +285 -0
- package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3Router.abi.json +583 -0
- package/build/abi/wBETH.json +1527 -0
- package/build/abi/woo-fi/WooFeeManager.abi.json +318 -0
- package/build/abi/woo-fi/WooPP.abi.json +548 -0
- package/build/abi/woo-fi/Wooracle.abi.json +260 -0
- package/build/dex/aave-v1/aave-v1.js +1 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/aave-v2/aave-v2.js +1 -0
- package/build/dex/aave-v2/aave-v2.js.map +1 -1
- package/build/dex/aave-v3/aave-v3.js +1 -0
- package/build/dex/aave-v3/aave-v3.js.map +1 -1
- package/build/dex/aave-v3/tokens/arbitrum.json +50 -0
- package/build/dex/aave-v3/tokens/avalanche.json +74 -0
- package/build/dex/aave-v3/tokens/fantom.json +62 -0
- package/build/dex/aave-v3/tokens/optimism.json +50 -0
- package/build/dex/aave-v3/tokens/polygon.json +116 -0
- package/build/dex/algebra/algebra-pool.d.ts +114 -0
- package/build/dex/algebra/algebra-pool.js +448 -0
- package/build/dex/algebra/algebra-pool.js.map +1 -0
- package/build/dex/algebra/algebra.js +4 -0
- package/build/dex/algebra/algebra.js.map +1 -1
- package/build/dex/angle-staked-stable/angle-staked-stable.d.ts +1 -1
- package/build/dex/angle-staked-stable/angle-staked-stable.js +1 -4
- package/build/dex/angle-staked-stable/angle-staked-stable.js.map +1 -1
- package/build/dex/bProtocol/bProtocol.js +5 -0
- package/build/dex/bProtocol/bProtocol.js.map +1 -1
- package/build/dex/balancer-v1/balancer-v1.js +4 -0
- package/build/dex/balancer-v1/balancer-v1.js.map +1 -1
- package/build/dex/balancer-v2/Gyro3Pool.d.ts +43 -0
- package/build/dex/balancer-v2/Gyro3Pool.js +160 -0
- package/build/dex/balancer-v2/Gyro3Pool.js.map +1 -0
- package/build/dex/balancer-v2/LinearMath.d.ts +88 -0
- package/build/dex/balancer-v2/LinearMath.js +285 -0
- package/build/dex/balancer-v2/LinearMath.js.map +1 -0
- package/build/dex/balancer-v2/LinearPool.d.ts +81 -0
- package/build/dex/balancer-v2/LinearPool.js +444 -0
- package/build/dex/balancer-v2/LinearPool.js.map +1 -0
- package/build/dex/balancer-v2/PhantomStablePool.d.ts +90 -0
- package/build/dex/balancer-v2/PhantomStablePool.js +418 -0
- package/build/dex/balancer-v2/PhantomStablePool.js.map +1 -0
- package/build/dex/balancer-v2/StableMath.d.ts +9 -0
- package/build/dex/balancer-v2/StableMath.js +272 -0
- package/build/dex/balancer-v2/StableMath.js.map +1 -0
- package/build/dex/balancer-v2/balancer-v2-pool.d.ts +140 -0
- package/build/dex/balancer-v2/balancer-v2-pool.js +647 -0
- package/build/dex/balancer-v2/balancer-v2-pool.js.map +1 -0
- package/build/dex/balancer-v2/balancer-v2.js +1 -0
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/bancor/bancor.js +4 -0
- package/build/dex/bancor/bancor.js.map +1 -1
- package/build/dex/camelot/camelot.js +1 -0
- package/build/dex/camelot/camelot.js.map +1 -1
- package/build/dex/compound/compound.js +1 -0
- package/build/dex/compound/compound.js.map +1 -1
- package/build/dex/curve-v1/curve-v1.js +1 -0
- package/build/dex/curve-v1/curve-v1.js.map +1 -1
- package/build/dex/curve-v1/pools/frxETHpool.d.ts +7 -0
- package/build/dex/curve-v1/pools/frxETHpool.js +27 -0
- package/build/dex/curve-v1/pools/frxETHpool.js.map +1 -0
- package/build/dex/curve-v1/pools/wbETHpool.d.ts +29 -0
- package/build/dex/curve-v1/pools/wbETHpool.js +408 -0
- package/build/dex/curve-v1/pools/wbETHpool.js.map +1 -0
- package/build/dex/curve-v1-factory/curve-v1-factory.js +1 -0
- package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
- package/build/dex/curve-v2/curve-v2.js +1 -0
- package/build/dex/curve-v2/curve-v2.js.map +1 -1
- package/build/dex/dexalot/dexalot.js +1 -0
- package/build/dex/dexalot/dexalot.js.map +1 -1
- package/build/dex/dodo-v1/dodo-v1.js +4 -0
- package/build/dex/dodo-v1/dodo-v1.js.map +1 -1
- package/build/dex/dodo-v2.js +4 -0
- package/build/dex/dodo-v2.js.map +1 -1
- package/build/dex/etherfi.js +2 -0
- package/build/dex/etherfi.js.map +1 -1
- package/build/dex/generic-rfq/generic-rfq.js +1 -0
- package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
- package/build/dex/gmx/gmx.js +4 -0
- package/build/dex/gmx/gmx.js.map +1 -1
- package/build/dex/hashflow/hashflow.js +1 -0
- package/build/dex/hashflow/hashflow.js.map +1 -1
- package/build/dex/idex.d.ts +1 -1
- package/build/dex/{trader-joe-v2-1-2 → integral}/config.d.ts +1 -1
- package/build/dex/integral/config.js +18 -0
- package/build/dex/integral/config.js.map +1 -0
- package/build/dex/{angle-transmuter/morphoOracle.d.ts → integral/integral-pool.d.ts} +12 -15
- package/build/dex/integral/integral-pool.js +67 -0
- package/build/dex/integral/integral-pool.js.map +1 -0
- package/build/dex/integral/integral.d.ts +48 -0
- package/build/dex/integral/integral.js +402 -0
- package/build/dex/integral/integral.js.map +1 -0
- package/build/dex/integral/types.d.ts +25 -0
- package/build/dex/integral/types.js +9 -0
- package/build/dex/integral/types.js.map +1 -0
- package/build/dex/jarvis-v6/jarvis-v6.js +1 -0
- package/build/dex/jarvis-v6/jarvis-v6.js.map +1 -1
- package/build/dex/jarvis.js +8 -0
- package/build/dex/jarvis.js.map +1 -1
- package/build/dex/kyberdmm/kyberdmm.js +4 -0
- package/build/dex/kyberdmm/kyberdmm.js.map +1 -1
- package/build/dex/lido/lido.js +5 -0
- package/build/dex/lido/lido.js.map +1 -1
- package/build/{abi/angle-transmuter/MorphoOracle.json → dex/lighter-v1/abi/erc20.json} +126 -97
- package/build/dex/lighter-v1/abi/factory.json +291 -0
- package/build/dex/lighter-v1/abi/order_book.json +594 -0
- package/build/dex/lighter-v1/abi/order_book_helper.json +176 -0
- package/build/dex/lighter-v1/abi/router.json +488 -0
- package/build/dex/{trader-joe-v2_1 → lighter-v1}/config.d.ts +1 -1
- package/build/dex/lighter-v1/config.js +17 -0
- package/build/dex/lighter-v1/config.js.map +1 -0
- package/build/dex/lighter-v1/constants.d.ts +2 -0
- package/build/dex/lighter-v1/constants.js +13 -0
- package/build/dex/lighter-v1/constants.js.map +1 -0
- package/build/dex/lighter-v1/lighter-v1-pool.d.ts +57 -0
- package/build/dex/lighter-v1/lighter-v1-pool.js +310 -0
- package/build/dex/lighter-v1/lighter-v1-pool.js.map +1 -0
- package/build/dex/{angle-transmuter/angle-transmuter.d.ts → lighter-v1/lighter-v1.d.ts} +17 -31
- package/build/dex/lighter-v1/lighter-v1.js +331 -0
- package/build/dex/lighter-v1/lighter-v1.js.map +1 -0
- package/build/dex/lighter-v1/types.d.ts +40 -0
- package/build/dex/lighter-v1/types.js +3 -0
- package/build/dex/lighter-v1/types.js.map +1 -0
- package/build/dex/maker-psm/maker-psm.js +1 -0
- package/build/dex/maker-psm/maker-psm.js.map +1 -1
- package/build/dex/maverick-v1/maverick-v1.js +4 -0
- package/build/dex/maverick-v1/maverick-v1.js.map +1 -1
- package/build/dex/nerve/nerve.js +4 -0
- package/build/dex/nerve/nerve.js.map +1 -1
- package/build/dex/onebit/onebit.js +5 -0
- package/build/dex/onebit/onebit.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js +4 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js.map +1 -1
- package/build/dex/pancakeswap-v3/types.d.ts +14 -0
- package/build/dex/pancakeswap-v3/types.js +3 -0
- package/build/dex/pancakeswap-v3/types.js.map +1 -0
- package/build/dex/paraswap-limit-orders/paraswap-limit-orders.js +1 -0
- package/build/dex/paraswap-limit-orders/paraswap-limit-orders.js.map +1 -1
- package/build/dex/platypus/platypus.js +17 -3
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/polygon-migrator/polygon-migrator.js +1 -0
- package/build/dex/polygon-migrator/polygon-migrator.js.map +1 -1
- package/build/dex/quick-perps/quick-perps.js +7 -1
- package/build/dex/quick-perps/quick-perps.js.map +1 -1
- package/build/dex/quickswap/camelot-v3.d.ts +6 -0
- package/build/dex/quickswap/camelot-v3.js +19 -0
- package/build/dex/quickswap/camelot-v3.js.map +1 -0
- package/build/dex/quickswap/zyberswap-v3.d.ts +6 -0
- package/build/dex/quickswap/zyberswap-v3.js +19 -0
- package/build/dex/quickswap/zyberswap-v3.js.map +1 -0
- package/build/dex/quickswap-v3.d.ts +21 -0
- package/build/dex/quickswap-v3.js +40 -0
- package/build/dex/quickswap-v3.js.map +1 -0
- package/build/dex/{angle-transmuter → ramses-v2}/config.d.ts +1 -1
- package/build/dex/ramses-v2/config.js +28 -0
- package/build/dex/ramses-v2/config.js.map +1 -0
- package/build/dex/ramses-v2/constants.d.ts +28 -0
- package/build/dex/ramses-v2/constants.js +35 -0
- package/build/dex/ramses-v2/constants.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/BitMath.d.ts +4 -0
- package/build/dex/ramses-v2/contract-math/BitMath.js +93 -0
- package/build/dex/ramses-v2/contract-math/BitMath.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/FixedPoint128.d.ts +3 -0
- package/build/dex/ramses-v2/contract-math/FixedPoint128.js +8 -0
- package/build/dex/ramses-v2/contract-math/FixedPoint128.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/FixedPoint96.d.ts +4 -0
- package/build/dex/ramses-v2/contract-math/FixedPoint96.js +9 -0
- package/build/dex/ramses-v2/contract-math/FixedPoint96.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/FullMath.d.ts +4 -0
- package/build/dex/ramses-v2/contract-math/FullMath.js +19 -0
- package/build/dex/ramses-v2/contract-math/FullMath.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/LiquidityMath.d.ts +3 -0
- package/build/dex/ramses-v2/contract-math/LiquidityMath.js +22 -0
- package/build/dex/ramses-v2/contract-math/LiquidityMath.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/Oracle.d.ts +10 -0
- package/build/dex/ramses-v2/contract-math/Oracle.js +133 -0
- package/build/dex/ramses-v2/contract-math/Oracle.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/SqrtPriceMath.d.ts +10 -0
- package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js +91 -0
- package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/SwapMath.d.ts +8 -0
- package/build/dex/ramses-v2/contract-math/SwapMath.js +70 -0
- package/build/dex/ramses-v2/contract-math/SwapMath.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/Tick.d.ts +7 -0
- package/build/dex/ramses-v2/contract-math/Tick.js +45 -0
- package/build/dex/ramses-v2/contract-math/Tick.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/TickBitMap.d.ts +8 -0
- package/build/dex/ramses-v2/contract-math/TickBitMap.js +87 -0
- package/build/dex/ramses-v2/contract-math/TickBitMap.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/TickMath.d.ts +8 -0
- package/build/dex/ramses-v2/contract-math/TickMath.js +162 -0
- package/build/dex/ramses-v2/contract-math/TickMath.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/UnsafeMath.d.ts +3 -0
- package/build/dex/ramses-v2/contract-math/UnsafeMath.js +10 -0
- package/build/dex/ramses-v2/contract-math/UnsafeMath.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/uniswap-v3-math.d.ts +18 -0
- package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js +392 -0
- package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/utils.d.ts +3 -0
- package/build/dex/ramses-v2/contract-math/utils.js +16 -0
- package/build/dex/ramses-v2/contract-math/utils.js.map +1 -0
- package/build/dex/ramses-v2/ramses-v2-pool.d.ts +42 -0
- package/build/dex/ramses-v2/ramses-v2-pool.js +307 -0
- package/build/dex/ramses-v2/ramses-v2-pool.js.map +1 -0
- package/build/dex/ramses-v2/ramses-v2.d.ts +61 -0
- package/build/dex/ramses-v2/ramses-v2.js +690 -0
- package/build/dex/ramses-v2/ramses-v2.js.map +1 -0
- package/build/dex/ramses-v2/types.d.ts +154 -0
- package/build/dex/ramses-v2/types.js +9 -0
- package/build/dex/ramses-v2/types.js.map +1 -0
- package/build/dex/ramses-v2/utils.d.ts +6 -0
- package/build/dex/ramses-v2/utils.js +71 -0
- package/build/dex/ramses-v2/utils.js.map +1 -0
- package/build/dex/smoothy/smoothy.js +1 -0
- package/build/dex/smoothy/smoothy.js.map +1 -1
- package/build/dex/solidly/forks-override/fvm.d.ts +20 -0
- package/build/dex/solidly/forks-override/fvm.js +42 -0
- package/build/dex/solidly/forks-override/fvm.js.map +1 -0
- package/build/dex/solidly/solidly.js +1 -0
- package/build/dex/solidly/solidly.js.map +1 -1
- package/build/dex/solidly-v3/solidly-v3.js +1 -0
- package/build/dex/solidly-v3/solidly-v3.js.map +1 -1
- package/build/dex/spark/spark.js +6 -0
- package/build/dex/spark/spark.js.map +1 -1
- package/build/dex/stable-pool/stable-pool.js +4 -0
- package/build/dex/stable-pool/stable-pool.js.map +1 -1
- package/build/dex/sushiswap-v3/config.d.ts +4 -0
- package/build/dex/sushiswap-v3/config.js +132 -0
- package/build/dex/sushiswap-v3/config.js.map +1 -0
- package/build/dex/sushiswap-v3/constants.d.ts +4 -0
- package/build/dex/sushiswap-v3/constants.js +32 -0
- package/build/dex/sushiswap-v3/constants.js.map +1 -0
- package/build/dex/sushiswap-v3/sushiswap-v3-original.d.ts +56 -0
- package/build/dex/sushiswap-v3/sushiswap-v3-original.js +598 -0
- package/build/dex/sushiswap-v3/sushiswap-v3-original.js.map +1 -0
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.d.ts +1 -0
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.js +6 -0
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.js.map +1 -0
- package/build/dex/sushiswap-v3/sushiswap-v3.d.ts +21 -0
- package/build/dex/sushiswap-v3/sushiswap-v3.js +58 -0
- package/build/dex/sushiswap-v3/sushiswap-v3.js.map +1 -0
- package/build/dex/sushiswap-v3/token.d.ts +6 -0
- package/build/dex/sushiswap-v3/token.js +23 -0
- package/build/dex/sushiswap-v3/token.js.map +1 -0
- package/build/dex/sushiswap-v3/types.d.ts +15 -0
- package/build/dex/sushiswap-v3/types.js +18 -0
- package/build/dex/sushiswap-v3/types.js.map +1 -0
- package/build/dex/swaap-v1/swaap-v1.js +4 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/swaap-v2/swaap-v2.js +1 -0
- package/build/dex/swaap-v2/swaap-v2.js.map +1 -1
- package/build/dex/swell/swell.js +1 -0
- package/build/dex/swell/swell.js.map +1 -1
- package/build/dex/synthetix/synthetix.js +6 -0
- package/build/dex/synthetix/synthetix.js.map +1 -1
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1.js +4 -0
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1.js.map +1 -1
- package/build/dex/uniswap-v2/uniswap-v2.js +1 -0
- package/build/dex/uniswap-v2/uniswap-v2.js.map +1 -1
- package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.d.ts +12 -0
- package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js +23 -0
- package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js.map +1 -0
- package/build/dex/uniswap-v3/uniswap-v3.js +4 -0
- package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
- package/build/dex/uniswap-v3.js +4 -0
- package/build/dex/uniswap-v3.js.map +1 -1
- package/build/dex/weth/weth.js +1 -0
- package/build/dex/weth/weth.js.map +1 -1
- package/build/dex/wombat/wombat.js +4 -0
- package/build/dex/wombat/wombat.js.map +1 -1
- package/build/dex/woo-fi/config.d.ts +4 -0
- package/build/dex/woo-fi/config.js +141 -0
- package/build/dex/woo-fi/config.js.map +1 -0
- package/build/dex/woo-fi/constants.d.ts +5 -0
- package/build/dex/woo-fi/constants.js +20 -0
- package/build/dex/woo-fi/constants.js.map +1 -0
- package/build/dex/woo-fi/types.d.ts +48 -0
- package/build/dex/woo-fi/types.js +3 -0
- package/build/dex/woo-fi/types.js.map +1 -0
- package/build/dex/woo-fi/woo-fi-decimal-math.d.ts +14 -0
- package/build/dex/woo-fi/woo-fi-decimal-math.js +42 -0
- package/build/dex/woo-fi/woo-fi-decimal-math.js.map +1 -0
- package/build/dex/woo-fi/woo-fi-math.d.ts +31 -0
- package/build/dex/woo-fi/woo-fi-math.js +300 -0
- package/build/dex/woo-fi/woo-fi-math.js.map +1 -0
- package/build/dex/woo-fi/woo-fi.d.ts +65 -0
- package/build/dex/woo-fi/woo-fi.js +480 -0
- package/build/dex/woo-fi/woo-fi.js.map +1 -0
- package/build/dex/woo-fi-v2/woo-fi-v2.js +4 -0
- package/build/dex/woo-fi-v2/woo-fi-v2.js.map +1 -1
- package/build/dex/wsteth/wsteth.js +8 -1
- package/build/dex/wsteth/wsteth.js.map +1 -1
- package/build/dex/zerox/index.js +1 -0
- package/build/dex/zerox/index.js.map +1 -1
- package/build/executor/Executor01BytecodeBuilder.js +4 -1
- package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor02BytecodeBuilder.js +5 -1
- package/build/executor/Executor02BytecodeBuilder.js.map +1 -1
- package/build/executor/ExecutorBytecodeBuilder.d.ts +1 -1
- package/build/executor/ExecutorBytecodeBuilder.js +5 -4
- package/build/executor/ExecutorBytecodeBuilder.js.map +1 -1
- package/build/executor/ExecutorDetector.d.ts +1 -1
- package/build/executor/ExecutorDetector.js.map +1 -1
- package/build/executor/IExecutorBytecodeBuilder.d.ts +6 -0
- package/build/executor/IExecutorBytecodeBuilder.js +3 -0
- package/build/executor/IExecutorBytecodeBuilder.js.map +1 -0
- package/build/executor/constants.d.ts +3 -1
- package/build/executor/constants.js +4 -2
- package/build/executor/constants.js.map +1 -1
- package/build/executor/utils.d.ts +2 -0
- package/build/executor/utils.js +30 -0
- package/build/executor/utils.js.map +1 -0
- package/build/router/simpleswap.js +6 -3
- package/build/router/simpleswap.js.map +1 -1
- package/build/types.d.ts +1 -0
- package/dex-template/__DexName__-e2e.test.ts.template +2 -9
- package/dex-template/__DexName__.ts.template +2 -29
- package/funding.json +5 -0
- package/package.json +1 -1
- package/src/dex/aave-v1/aave-v1.ts +1 -0
- package/src/dex/aave-v2/aave-v2.ts +1 -0
- package/src/dex/aave-v3/aave-v3.ts +1 -0
- package/src/dex/algebra/algebra.ts +9 -0
- package/src/dex/angle-staked-stable/angle-staked-stable.ts +2 -5
- package/src/dex/bProtocol/bProtocol.ts +8 -0
- package/src/dex/balancer-v1/balancer-v1.ts +9 -0
- package/src/dex/balancer-v2/balancer-v2.ts +3 -2
- package/src/dex/bancor/bancor.ts +8 -0
- package/src/dex/camelot/camelot.ts +1 -0
- package/src/dex/compound/compound.ts +1 -0
- package/src/dex/curve-v1/curve-v1.ts +1 -0
- package/src/dex/curve-v1-factory/curve-v1-factory.ts +1 -0
- package/src/dex/curve-v2/curve-v2.ts +1 -0
- package/src/dex/dexalot/dexalot.ts +1 -0
- package/src/dex/dodo-v1/dodo-v1.ts +9 -0
- package/src/dex/dodo-v2.ts +9 -0
- package/src/dex/etherfi.ts +2 -0
- package/src/dex/generic-rfq/generic-rfq.ts +1 -0
- package/src/dex/gmx/gmx.ts +8 -0
- package/src/dex/hashflow/hashflow.ts +1 -0
- package/src/dex/idex.ts +5 -3
- package/src/dex/jarvis-v6/jarvis-v6.ts +1 -0
- package/src/dex/jarvis.ts +14 -0
- package/src/dex/kyberdmm/kyberdmm.ts +9 -0
- package/src/dex/lido/lido.ts +8 -0
- package/src/dex/maker-psm/maker-psm.ts +1 -0
- package/src/dex/maverick-v1/maverick-v1.ts +9 -0
- package/src/dex/nerve/nerve.ts +8 -0
- package/src/dex/onebit/onebit.ts +8 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +9 -0
- package/src/dex/paraswap-limit-orders/paraswap-limit-orders.ts +1 -0
- package/src/dex/platypus/platypus.ts +20 -3
- package/src/dex/polygon-migrator/polygon-migrator.ts +1 -0
- package/src/dex/quick-perps/quick-perps.ts +11 -1
- package/src/dex/smoothy/smoothy.ts +1 -0
- package/src/dex/solidly/solidly.ts +1 -0
- package/src/dex/solidly-v3/solidly-v3.ts +1 -1
- package/src/dex/spark/spark.ts +10 -0
- package/src/dex/stable-pool/stable-pool.ts +8 -0
- package/src/dex/swaap-v1/swaap-v1.ts +9 -0
- package/src/dex/swaap-v2/swaap-v2.ts +1 -0
- package/src/dex/swell/swell.ts +1 -0
- package/src/dex/synthetix/synthetix.ts +11 -0
- package/src/dex/trader-joe-v2.1/trader-joe-v2.1.ts +9 -0
- package/src/dex/uniswap-v2/uniswap-v2.ts +1 -0
- package/src/dex/uniswap-v3/uniswap-v3.ts +9 -0
- package/src/dex/uniswap-v3.ts +9 -0
- package/src/dex/weth/weth.ts +1 -0
- package/src/dex/wombat/wombat.ts +9 -0
- package/src/dex/woo-fi-v2/woo-fi-v2.ts +5 -0
- package/src/dex/wsteth/wsteth.ts +13 -4
- package/src/dex/zerox/index.ts +1 -0
- package/src/executor/Executor01BytecodeBuilder.ts +8 -1
- package/src/executor/Executor02BytecodeBuilder.ts +13 -0
- package/src/executor/ExecutorBytecodeBuilder.ts +6 -1
- package/src/executor/ExecutorDetector.ts +3 -2
- package/src/executor/constants.ts +4 -1
- package/src/executor/executor01-bytecode-builder-e2e.test.ts +39 -0
- package/src/executor/utils.ts +44 -0
- package/src/router/simpleswap.ts +7 -3
- package/src/types.ts +1 -0
- package/tests/constants-e2e.ts +6 -1
- package/build/abi/Redstone.json +0 -739
- package/build/abi/angle-transmuter/MorphoVault.json +0 -2506
- package/build/abi/angle-transmuter/Pyth.json +0 -1534
- package/build/abi/angle-transmuter/Transmuter.json +0 -1711
- package/build/abi/idle-dao/idle-cdo-factory.json +0 -38
- package/build/abi/idle-dao/idle-cdo.json +0 -1245
- package/build/abi/pharaoh/PharaohPool.abi.json +0 -1582
- package/build/abi/smardex/smardex-factory.json +0 -185
- package/build/abi/smardex/smardex-pool.json +0 -578
- package/build/abi/smardex/smardex-router.json +0 -648
- package/build/abi/trader-joe-v2_1/FactoryABI.json +0 -1208
- package/build/abi/trader-joe-v2_1/PairABI.json +0 -1493
- package/build/abi/trader-joe-v2_1/RouterABI.json +0 -1489
- package/build/abi/trader-joe-v2_1/StateMulticall.json +0 -193
- package/build/dex/angle-transmuter/angle-transmuter-pool.d.ts +0 -61
- package/build/dex/angle-transmuter/angle-transmuter-pool.js +0 -415
- package/build/dex/angle-transmuter/angle-transmuter-pool.js.map +0 -1
- package/build/dex/angle-transmuter/angle-transmuter.js +0 -262
- package/build/dex/angle-transmuter/angle-transmuter.js.map +0 -1
- package/build/dex/angle-transmuter/backedOracle.d.ts +0 -19
- package/build/dex/angle-transmuter/backedOracle.js +0 -56
- package/build/dex/angle-transmuter/backedOracle.js.map +0 -1
- package/build/dex/angle-transmuter/config.js +0 -30
- package/build/dex/angle-transmuter/config.js.map +0 -1
- package/build/dex/angle-transmuter/constants.d.ts +0 -77
- package/build/dex/angle-transmuter/constants.js +0 -94
- package/build/dex/angle-transmuter/constants.js.map +0 -1
- package/build/dex/angle-transmuter/morphoOracle.js +0 -179
- package/build/dex/angle-transmuter/morphoOracle.js.map +0 -1
- package/build/dex/angle-transmuter/morphoVault.d.ts +0 -19
- package/build/dex/angle-transmuter/morphoVault.js +0 -78
- package/build/dex/angle-transmuter/morphoVault.js.map +0 -1
- package/build/dex/angle-transmuter/pyth.d.ts +0 -19
- package/build/dex/angle-transmuter/pyth.js +0 -70
- package/build/dex/angle-transmuter/pyth.js.map +0 -1
- package/build/dex/angle-transmuter/redstone.d.ts +0 -20
- package/build/dex/angle-transmuter/redstone.js +0 -73
- package/build/dex/angle-transmuter/redstone.js.map +0 -1
- package/build/dex/angle-transmuter/transmuter.d.ts +0 -52
- package/build/dex/angle-transmuter/transmuter.js +0 -374
- package/build/dex/angle-transmuter/transmuter.js.map +0 -1
- package/build/dex/angle-transmuter/types.d.ts +0 -188
- package/build/dex/angle-transmuter/types.js +0 -33
- package/build/dex/angle-transmuter/types.js.map +0 -1
- package/build/dex/angle-transmuter/utils.d.ts +0 -9
- package/build/dex/angle-transmuter/utils.js +0 -252
- package/build/dex/angle-transmuter/utils.js.map +0 -1
- package/build/dex/idle-dao/config.d.ts +0 -6
- package/build/dex/idle-dao/config.js +0 -29
- package/build/dex/idle-dao/config.js.map +0 -1
- package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
- package/build/dex/idle-dao/idle-dao-pool.js +0 -176
- package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
- package/build/dex/idle-dao/idle-dao.d.ts +0 -52
- package/build/dex/idle-dao/idle-dao.js +0 -310
- package/build/dex/idle-dao/idle-dao.js.map +0 -1
- package/build/dex/idle-dao/tokens.d.ts +0 -16
- package/build/dex/idle-dao/tokens.js +0 -87
- package/build/dex/idle-dao/tokens.js.map +0 -1
- package/build/dex/idle-dao/types.d.ts +0 -37
- package/build/dex/idle-dao/types.js +0 -11
- package/build/dex/idle-dao/types.js.map +0 -1
- package/build/dex/idle-dao/utils.d.ts +0 -8
- package/build/dex/idle-dao/utils.js +0 -145
- package/build/dex/idle-dao/utils.js.map +0 -1
- package/build/dex/smardex/subgraph-queries.d.ts +0 -1
- package/build/dex/smardex/subgraph-queries.js +0 -17
- package/build/dex/smardex/subgraph-queries.js.map +0 -1
- package/build/dex/smardex/usd-reserves.d.ts +0 -23
- package/build/dex/smardex/usd-reserves.js +0 -86
- package/build/dex/smardex/usd-reserves.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/config.js +0 -47
- package/build/dex/trader-joe-v2-1-2/config.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/constants.d.ts +0 -20
- package/build/dex/trader-joe-v2-1-2/constants.js +0 -22
- package/build/dex/trader-joe-v2-1-2/constants.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/math/index.d.ts +0 -37
- package/build/dex/trader-joe-v2-1-2/math/index.js +0 -291
- package/build/dex/trader-joe-v2-1-2/math/index.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.d.ts +0 -60
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js +0 -248
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.d.ts +0 -53
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js +0 -307
- package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js.map +0 -1
- package/build/dex/trader-joe-v2-1-2/types.d.ts +0 -82
- package/build/dex/trader-joe-v2-1-2/types.js +0 -9
- package/build/dex/trader-joe-v2-1-2/types.js.map +0 -1
- package/build/dex/trader-joe-v2_1/config.js +0 -47
- package/build/dex/trader-joe-v2_1/config.js.map +0 -1
- package/build/dex/trader-joe-v2_1/constants.d.ts +0 -20
- package/build/dex/trader-joe-v2_1/constants.js +0 -22
- package/build/dex/trader-joe-v2_1/constants.js.map +0 -1
- package/build/dex/trader-joe-v2_1/math/index.d.ts +0 -37
- package/build/dex/trader-joe-v2_1/math/index.js +0 -291
- package/build/dex/trader-joe-v2_1/math/index.js.map +0 -1
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.d.ts +0 -0
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js +0 -384
- package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js.map +0 -1
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.d.ts +0 -60
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js +0 -247
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js.map +0 -1
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.d.ts +0 -53
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js +0 -307
- package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js.map +0 -1
- package/build/dex/trader-joe-v2_1/types.d.ts +0 -82
- package/build/dex/trader-joe-v2_1/types.js +0 -9
- package/build/dex/trader-joe-v2_1/types.js.map +0 -1
- package/build/dex/wombat/wombat-pool-poller.d.ts +0 -22
- package/build/dex/wombat/wombat-pool-poller.js +0 -164
- package/build/dex/wombat/wombat-pool-poller.js.map +0 -1
- package/build/dex-helper/Cache.d.ts +0 -31
- package/build/dex-helper/Cache.js +0 -106
- package/build/dex-helper/Cache.js.map +0 -1
- package/build/dex-helper/RedisBatcher.d.ts +0 -20
- package/build/dex-helper/RedisBatcher.js +0 -75
- package/build/dex-helper/RedisBatcher.js.map +0 -1
- package/build/dex-helper/RedisWrapper.d.ts +0 -37
- package/build/dex-helper/RedisWrapper.js +0 -165
- package/build/dex-helper/RedisWrapper.js.map +0 -1
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"inputs": [
|
|
4
|
-
{
|
|
5
|
-
"internalType": "address",
|
|
6
|
-
"name": "factoryAddress",
|
|
7
|
-
"type": "address"
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"internalType": "contract IERC20",
|
|
11
|
-
"name": "tokenIn",
|
|
12
|
-
"type": "address"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"internalType": "contract IERC20",
|
|
16
|
-
"name": "tokenOut",
|
|
17
|
-
"type": "address"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"internalType": "uint24",
|
|
21
|
-
"name": "binStep",
|
|
22
|
-
"type": "uint24"
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
"name": "getFullState",
|
|
26
|
-
"outputs": [
|
|
27
|
-
{
|
|
28
|
-
"components": [
|
|
29
|
-
{
|
|
30
|
-
"internalType": "contract ILBPair",
|
|
31
|
-
"name": "pair",
|
|
32
|
-
"type": "address"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"components": [
|
|
36
|
-
{
|
|
37
|
-
"internalType": "uint24",
|
|
38
|
-
"name": "id",
|
|
39
|
-
"type": "uint24"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"internalType": "uint128",
|
|
43
|
-
"name": "reserveX",
|
|
44
|
-
"type": "uint128"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"internalType": "uint128",
|
|
48
|
-
"name": "reserveY",
|
|
49
|
-
"type": "uint128"
|
|
50
|
-
}
|
|
51
|
-
],
|
|
52
|
-
"internalType": "struct ITraderJoeV21StateMulticall.Bin[]",
|
|
53
|
-
"name": "bins",
|
|
54
|
-
"type": "tuple[]"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"internalType": "address",
|
|
58
|
-
"name": "tokenX",
|
|
59
|
-
"type": "address"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"internalType": "address",
|
|
63
|
-
"name": "tokenY",
|
|
64
|
-
"type": "address"
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
"internalType": "address",
|
|
68
|
-
"name": "pairAddress",
|
|
69
|
-
"type": "address"
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"internalType": "uint256",
|
|
73
|
-
"name": "blockTimestamp",
|
|
74
|
-
"type": "uint256"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
"components": [
|
|
78
|
-
{
|
|
79
|
-
"internalType": "uint128",
|
|
80
|
-
"name": "reserveX",
|
|
81
|
-
"type": "uint128"
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"internalType": "uint128",
|
|
85
|
-
"name": "reserveY",
|
|
86
|
-
"type": "uint128"
|
|
87
|
-
}
|
|
88
|
-
],
|
|
89
|
-
"internalType": "struct ITraderJoeV21StateMulticall.Reserves",
|
|
90
|
-
"name": "reserves",
|
|
91
|
-
"type": "tuple"
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
"internalType": "uint24",
|
|
95
|
-
"name": "activeId",
|
|
96
|
-
"type": "uint24"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"components": [
|
|
100
|
-
{
|
|
101
|
-
"internalType": "uint128",
|
|
102
|
-
"name": "protocolFeeX",
|
|
103
|
-
"type": "uint128"
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
"internalType": "uint128",
|
|
107
|
-
"name": "protocolFeeY",
|
|
108
|
-
"type": "uint128"
|
|
109
|
-
}
|
|
110
|
-
],
|
|
111
|
-
"internalType": "struct ITraderJoeV21StateMulticall.ProtocolFees",
|
|
112
|
-
"name": "protocolFees",
|
|
113
|
-
"type": "tuple"
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
"components": [
|
|
117
|
-
{
|
|
118
|
-
"internalType": "uint16",
|
|
119
|
-
"name": "baseFactor",
|
|
120
|
-
"type": "uint16"
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
"internalType": "uint16",
|
|
124
|
-
"name": "filterPeriod",
|
|
125
|
-
"type": "uint16"
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
"internalType": "uint16",
|
|
129
|
-
"name": "decayPeriod",
|
|
130
|
-
"type": "uint16"
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"internalType": "uint16",
|
|
134
|
-
"name": "reductionFactor",
|
|
135
|
-
"type": "uint16"
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
"internalType": "uint24",
|
|
139
|
-
"name": "variableFeeControl",
|
|
140
|
-
"type": "uint24"
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
"internalType": "uint16",
|
|
144
|
-
"name": "protocolShare",
|
|
145
|
-
"type": "uint16"
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
"internalType": "uint24",
|
|
149
|
-
"name": "maxVolatilityAccumulator",
|
|
150
|
-
"type": "uint24"
|
|
151
|
-
}
|
|
152
|
-
],
|
|
153
|
-
"internalType": "struct ITraderJoeV21StateMulticall.StaticFeeParameters",
|
|
154
|
-
"name": "staticFeeParameters",
|
|
155
|
-
"type": "tuple"
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
"components": [
|
|
159
|
-
{
|
|
160
|
-
"internalType": "uint24",
|
|
161
|
-
"name": "volatilityAccumulator",
|
|
162
|
-
"type": "uint24"
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
"internalType": "uint24",
|
|
166
|
-
"name": "volatilityReference",
|
|
167
|
-
"type": "uint24"
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
"internalType": "uint24",
|
|
171
|
-
"name": "idReference",
|
|
172
|
-
"type": "uint24"
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
"internalType": "uint40",
|
|
176
|
-
"name": "timeOfLastUpdate",
|
|
177
|
-
"type": "uint40"
|
|
178
|
-
}
|
|
179
|
-
],
|
|
180
|
-
"internalType": "struct ITraderJoeV21StateMulticall.VariableFeeParameters",
|
|
181
|
-
"name": "variableFeeParameters",
|
|
182
|
-
"type": "tuple"
|
|
183
|
-
}
|
|
184
|
-
],
|
|
185
|
-
"internalType": "struct ITraderJoeV21StateMulticall.StateResult",
|
|
186
|
-
"name": "state",
|
|
187
|
-
"type": "tuple"
|
|
188
|
-
}
|
|
189
|
-
],
|
|
190
|
-
"stateMutability": "view",
|
|
191
|
-
"type": "function"
|
|
192
|
-
}
|
|
193
|
-
]
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Interface } from '@ethersproject/abi';
|
|
2
|
-
import { Address, Logger } from '../../types';
|
|
3
|
-
import { ComposedEventSubscriber } from '../../composed-event-subscriber';
|
|
4
|
-
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
5
|
-
import { ChainlinkConfig, MorphoConfig, OracleFeed, OracleQuoteType, OracleReadType, PoolConfig, PoolState, PythConfig, TransmuterParams } from './types';
|
|
6
|
-
import { Contract } from 'web3-eth-contract';
|
|
7
|
-
import { SwapSide } from '../../constants';
|
|
8
|
-
export declare class AngleTransmuterEventPool extends ComposedEventSubscriber<PoolState> {
|
|
9
|
-
readonly parentName: string;
|
|
10
|
-
protected network: number;
|
|
11
|
-
protected dexHelper: IDexHelper;
|
|
12
|
-
transmuter: Contract;
|
|
13
|
-
static angleTransmuterIface: Interface;
|
|
14
|
-
readonly config: PoolConfig;
|
|
15
|
-
constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, config: PoolConfig);
|
|
16
|
-
getStateOrGenerate(blockNumber: number): Promise<Readonly<PoolState>>;
|
|
17
|
-
getAmountOut(_tokenIn: Address, _tokenOut: Address, side: SwapSide, _amounts: number[], blockNumber: number): Promise<number[] | null>;
|
|
18
|
-
static getCollateralsList(transmuterAddress: Address, blockNumber: number | 'latest', multiContract: Contract): Promise<string[]>;
|
|
19
|
-
static _fillMap(chainlinkMap: ChainlinkConfig, backedMap: ChainlinkConfig, redstoneMap: ChainlinkConfig, pythIds: PythConfig, morphoMap: MorphoConfig, oracleFeed: OracleFeed, blockNumber: number | 'latest', multiContract: Contract): Promise<{
|
|
20
|
-
chainlinkMap: ChainlinkConfig;
|
|
21
|
-
backedMap: ChainlinkConfig;
|
|
22
|
-
redstoneMap: ChainlinkConfig;
|
|
23
|
-
pythIds: PythConfig;
|
|
24
|
-
morphoMap: MorphoConfig;
|
|
25
|
-
}>;
|
|
26
|
-
static generateStateChainlinkLike(feed: string, chainlinkMap: ChainlinkConfig, backedMap: ChainlinkConfig, redstoneMap: ChainlinkConfig, blockNumber: number | 'latest', multiContract: Contract): Promise<{
|
|
27
|
-
chainlinkMap: ChainlinkConfig;
|
|
28
|
-
backedMap: ChainlinkConfig;
|
|
29
|
-
redstoneMap: ChainlinkConfig;
|
|
30
|
-
}>;
|
|
31
|
-
static getOraclesConfig(transmuterAddress: Address, pythAddress: Address, collaterals: Address[], blockNumber: number | 'latest', multiContract: Contract): Promise<{
|
|
32
|
-
chainlink: ChainlinkConfig;
|
|
33
|
-
backed: ChainlinkConfig;
|
|
34
|
-
redstone: ChainlinkConfig;
|
|
35
|
-
pyth: PythConfig;
|
|
36
|
-
morpho: MorphoConfig;
|
|
37
|
-
}>;
|
|
38
|
-
static getConfig(dexParams: TransmuterParams, blockNumber: number | 'latest', multiContract: Contract): Promise<PoolConfig>;
|
|
39
|
-
_readMint(config: PoolConfig, state: PoolState, collateral: Address, blockNumber: number): number;
|
|
40
|
-
_getBurnOracle(config: PoolConfig, state: PoolState, collateral: Address, blockNumber: number): {
|
|
41
|
-
oracleValue: number;
|
|
42
|
-
minRatio: number;
|
|
43
|
-
};
|
|
44
|
-
_readBurn(config: PoolConfig, state: PoolState, collateral: Address, blockNumber: number): {
|
|
45
|
-
oracleValue: number;
|
|
46
|
-
ratio: number;
|
|
47
|
-
};
|
|
48
|
-
_readSpotAndTarget(config: PoolConfig, state: PoolState, collateral: Address, blockNumber: number): {
|
|
49
|
-
spot: number;
|
|
50
|
-
target: number;
|
|
51
|
-
userDeviation: number;
|
|
52
|
-
burnRatioDeviation: number;
|
|
53
|
-
};
|
|
54
|
-
_quoteAmount(quoteType: OracleQuoteType, baseValue: number): number;
|
|
55
|
-
_read(config: PoolConfig, state: PoolState, oracleType: OracleReadType, feed: OracleFeed, baseValue: number): number;
|
|
56
|
-
_readChainlink(config: PoolConfig, state: PoolState, id: string, isMultiplied: number, price: number): {
|
|
57
|
-
price: number;
|
|
58
|
-
decimals: number;
|
|
59
|
-
};
|
|
60
|
-
_readMorphoFeedChainlink(config: PoolConfig, state: PoolState, id: string): bigint;
|
|
61
|
-
}
|
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AngleTransmuterEventPool = void 0;
|
|
7
|
-
const abi_1 = require("@ethersproject/abi");
|
|
8
|
-
const lens_1 = require("../../lens");
|
|
9
|
-
const composed_event_subscriber_1 = require("../../composed-event-subscriber");
|
|
10
|
-
const chainlink_1 = require("../../lib/chainlink");
|
|
11
|
-
const types_1 = require("./types");
|
|
12
|
-
const Transmuter_json_1 = __importDefault(require("../../abi/angle-transmuter/Transmuter.json"));
|
|
13
|
-
const transmuter_1 = require("./transmuter");
|
|
14
|
-
const pyth_1 = require("./pyth");
|
|
15
|
-
const utils_1 = require("./utils");
|
|
16
|
-
const redstone_1 = require("./redstone");
|
|
17
|
-
const utils_2 = require("ethers/lib/utils");
|
|
18
|
-
const backedOracle_1 = require("./backedOracle");
|
|
19
|
-
const constants_1 = require("../../constants");
|
|
20
|
-
const ethers_1 = require("ethers");
|
|
21
|
-
const constants_2 = require("./constants");
|
|
22
|
-
const morphoOracle_1 = require("./morphoOracle");
|
|
23
|
-
const utils_3 = require("../../utils");
|
|
24
|
-
const morphoVault_1 = require("./morphoVault");
|
|
25
|
-
class AngleTransmuterEventPool extends composed_event_subscriber_1.ComposedEventSubscriber {
|
|
26
|
-
constructor(parentName, network, dexHelper, logger, config) {
|
|
27
|
-
const chainlinkMap = Object.entries(config.oracles.chainlink).reduce((acc, [key, value]) => {
|
|
28
|
-
acc[key] = new chainlink_1.ChainLinkSubscriber(value.proxy, value.aggregator, (0, lens_1.lens)().oracles.chainlink[key], dexHelper.getLogger(`${key} ChainLink for ${parentName}-${network}`));
|
|
29
|
-
return acc;
|
|
30
|
-
}, {});
|
|
31
|
-
const backedMap = Object.entries(config.oracles.backed).reduce((acc, [key, value]) => {
|
|
32
|
-
acc[key] = new backedOracle_1.BackedSubscriber(value.proxy, value.aggregator, (0, lens_1.lens)().oracles.chainlink[key], dexHelper.getLogger(`${key} ChainLink for ${parentName}-${network}`));
|
|
33
|
-
return acc;
|
|
34
|
-
}, {});
|
|
35
|
-
const redstoneMap = Object.entries(config.oracles.redstone).reduce((acc, [key, value]) => {
|
|
36
|
-
acc[key] = new redstone_1.RedstoneSubscriber(value.proxy, value.aggregator, (0, lens_1.lens)().oracles.chainlink[key], dexHelper.getLogger(`${key} ChainLink for ${parentName}-${network}`));
|
|
37
|
-
return acc;
|
|
38
|
-
}, {});
|
|
39
|
-
const morphoMap = Object.entries(config.oracles.morpho).reduce((acc, [key, value]) => {
|
|
40
|
-
if (value.baseVault && value.baseVault !== ethers_1.ethers.constants.AddressZero)
|
|
41
|
-
acc[value.baseVault] = new morphoVault_1.MorphoVaultSubscriber(value.baseVault, (0, lens_1.lens)().oracles.morphoVault[value.baseVault], dexHelper.getLogger(`${key}:${value.baseVault} Morpho Vault for ${parentName}-${network}`));
|
|
42
|
-
if (value.quoteVault &&
|
|
43
|
-
value.quoteVault !== ethers_1.ethers.constants.AddressZero)
|
|
44
|
-
acc[value.quoteVault] = new morphoVault_1.MorphoVaultSubscriber(value.quoteVault, (0, lens_1.lens)().oracles.morphoVault[value.quoteVault], dexHelper.getLogger(`${key}:${value.quoteVault} Morpho Vault for ${parentName}-${network}`));
|
|
45
|
-
return acc;
|
|
46
|
-
}, {});
|
|
47
|
-
const pythListener = new pyth_1.PythSubscriber(config.oracles.pyth.proxy, config.oracles.pyth.ids, (0, lens_1.lens)().oracles.pyth, dexHelper.getLogger(`Pyth for ${parentName}-${network}`));
|
|
48
|
-
const transmuterListener = new transmuter_1.TransmuterSubscriber(config.stablecoin.address, config.transmuter, config.collaterals, (0, lens_1.lens)().transmuter, dexHelper.getLogger(`${parentName}-${network} Transmuter`));
|
|
49
|
-
super(parentName, 'Transmuter', dexHelper.getLogger(`${parentName}-${network}`), dexHelper, [
|
|
50
|
-
...Object.values(chainlinkMap),
|
|
51
|
-
...Object.values(backedMap),
|
|
52
|
-
...Object.values(redstoneMap),
|
|
53
|
-
...Object.values(morphoMap),
|
|
54
|
-
transmuterListener,
|
|
55
|
-
pythListener,
|
|
56
|
-
], {
|
|
57
|
-
stablecoin: config.stablecoin,
|
|
58
|
-
transmuter: {},
|
|
59
|
-
oracles: { chainlink: {}, pyth: {}, morphoVault: {} },
|
|
60
|
-
});
|
|
61
|
-
this.parentName = parentName;
|
|
62
|
-
this.network = network;
|
|
63
|
-
this.dexHelper = dexHelper;
|
|
64
|
-
this.transmuter = new this.dexHelper.web3Provider.eth.Contract(Transmuter_json_1.default, config.transmuter);
|
|
65
|
-
this.config = config;
|
|
66
|
-
}
|
|
67
|
-
async getStateOrGenerate(blockNumber) {
|
|
68
|
-
const evenState = this.getState(blockNumber);
|
|
69
|
-
if (evenState)
|
|
70
|
-
return evenState;
|
|
71
|
-
const onChainState = await this.generateState(blockNumber);
|
|
72
|
-
this.setState(onChainState, blockNumber);
|
|
73
|
-
return onChainState;
|
|
74
|
-
}
|
|
75
|
-
// Reference to the original implementation
|
|
76
|
-
// https://github.com/AngleProtocol/angle-transmuter/blob/6e1f2eb1f961d6c3b1cdaefe068d967c33c41936/contracts/transmuter/facets/Swapper.sol#L177
|
|
77
|
-
async getAmountOut(_tokenIn, _tokenOut, side, _amounts, blockNumber) {
|
|
78
|
-
const state = await this.getStateOrGenerate(blockNumber);
|
|
79
|
-
const isMint = _tokenOut === state.stablecoin.address;
|
|
80
|
-
let oracleValue;
|
|
81
|
-
let minRatio = 0;
|
|
82
|
-
let collateral = _tokenIn;
|
|
83
|
-
if (isMint)
|
|
84
|
-
oracleValue = await this._readMint(this.config, state, _tokenIn, blockNumber);
|
|
85
|
-
else {
|
|
86
|
-
collateral = _tokenOut;
|
|
87
|
-
({ oracleValue, minRatio } = await this._getBurnOracle(this.config, state, _tokenOut, blockNumber));
|
|
88
|
-
}
|
|
89
|
-
const collatStablecoinIssued = state.transmuter.collaterals[collateral].stablecoinsIssued;
|
|
90
|
-
const otherStablecoinIssued = state.transmuter.totalStablecoinIssued - collatStablecoinIssued;
|
|
91
|
-
const fees = state.transmuter.collaterals[collateral].fees;
|
|
92
|
-
return _amounts.map(_amount => {
|
|
93
|
-
if (isMint && side === constants_1.SwapSide.SELL)
|
|
94
|
-
return (0, utils_1._quoteMintExactInput)(oracleValue, _amount, fees, collatStablecoinIssued, otherStablecoinIssued);
|
|
95
|
-
if (isMint && side === constants_1.SwapSide.BUY)
|
|
96
|
-
return (0, utils_1._quoteMintExactOutput)(oracleValue, _amount, fees, collatStablecoinIssued, otherStablecoinIssued);
|
|
97
|
-
if (!isMint && side === constants_1.SwapSide.SELL)
|
|
98
|
-
return (0, utils_1._quoteBurnExactInput)(oracleValue, minRatio, _amount, fees, collatStablecoinIssued, otherStablecoinIssued);
|
|
99
|
-
return (0, utils_1._quoteBurnExactOutput)(oracleValue, minRatio, _amount, fees, collatStablecoinIssued, otherStablecoinIssued);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
static async getCollateralsList(transmuterAddress, blockNumber, multiContract) {
|
|
103
|
-
const tokensResult = (await multiContract.methods
|
|
104
|
-
.aggregate([
|
|
105
|
-
{
|
|
106
|
-
target: transmuterAddress,
|
|
107
|
-
callData: transmuter_1.TransmuterSubscriber.interface.encodeFunctionData('getCollateralList'),
|
|
108
|
-
},
|
|
109
|
-
])
|
|
110
|
-
.call({}, blockNumber)).returnData;
|
|
111
|
-
const tokens = transmuter_1.TransmuterSubscriber.interface.decodeFunctionResult('getCollateralList', tokensResult[0])[0];
|
|
112
|
-
// .map((t: any) => t.toLowerCase());
|
|
113
|
-
return tokens;
|
|
114
|
-
}
|
|
115
|
-
static async _fillMap(chainlinkMap, backedMap, redstoneMap, pythIds, morphoMap, oracleFeed, blockNumber, multiContract) {
|
|
116
|
-
if (oracleFeed.isChainlink) {
|
|
117
|
-
await Promise.all(oracleFeed.chainlink.circuitChainlink.map(async (feed) => {
|
|
118
|
-
({ chainlinkMap, backedMap, redstoneMap } =
|
|
119
|
-
await AngleTransmuterEventPool.generateStateChainlinkLike(feed, chainlinkMap, backedMap, redstoneMap, blockNumber, multiContract));
|
|
120
|
-
}));
|
|
121
|
-
}
|
|
122
|
-
else if (oracleFeed.isPyth) {
|
|
123
|
-
pythIds.ids = pythIds.ids.concat(oracleFeed.pyth.feedIds);
|
|
124
|
-
}
|
|
125
|
-
else if (oracleFeed.isMorpho) {
|
|
126
|
-
const morphoOracleResult = (await multiContract.methods
|
|
127
|
-
.aggregate(morphoOracle_1.MorphoOracleEventPool.getGenerateInfoMultiCallInput(oracleFeed.morpho.oracle))
|
|
128
|
-
.call({}, blockNumber)).returnData;
|
|
129
|
-
const morphoOracleInfo = morphoOracle_1.MorphoOracleEventPool.generateInfo(morphoOracleResult);
|
|
130
|
-
if (morphoOracleInfo.baseFeed1 !== ethers_1.ethers.constants.AddressZero)
|
|
131
|
-
({ chainlinkMap, backedMap, redstoneMap } =
|
|
132
|
-
await AngleTransmuterEventPool.generateStateChainlinkLike(morphoOracleInfo.baseFeed1, chainlinkMap, backedMap, redstoneMap, blockNumber, multiContract));
|
|
133
|
-
if (morphoOracleInfo.baseFeed2 !== ethers_1.ethers.constants.AddressZero)
|
|
134
|
-
({ chainlinkMap, backedMap, redstoneMap } =
|
|
135
|
-
await AngleTransmuterEventPool.generateStateChainlinkLike(morphoOracleInfo.baseFeed2, chainlinkMap, backedMap, redstoneMap, blockNumber, multiContract));
|
|
136
|
-
if (morphoOracleInfo.quoteFeed1 !== ethers_1.ethers.constants.AddressZero)
|
|
137
|
-
({ chainlinkMap, backedMap, redstoneMap } =
|
|
138
|
-
await AngleTransmuterEventPool.generateStateChainlinkLike(morphoOracleInfo.quoteFeed1, chainlinkMap, backedMap, redstoneMap, blockNumber, multiContract));
|
|
139
|
-
if (morphoOracleInfo.quoteFeed2 !== ethers_1.ethers.constants.AddressZero)
|
|
140
|
-
({ chainlinkMap, backedMap, redstoneMap } =
|
|
141
|
-
await AngleTransmuterEventPool.generateStateChainlinkLike(morphoOracleInfo.quoteFeed2, chainlinkMap, backedMap, redstoneMap, blockNumber, multiContract));
|
|
142
|
-
morphoMap[oracleFeed.morpho.oracle] = morphoOracleInfo;
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
throw new Error('Unknown oracle feed');
|
|
146
|
-
}
|
|
147
|
-
return { chainlinkMap, backedMap, redstoneMap, pythIds, morphoMap };
|
|
148
|
-
}
|
|
149
|
-
static async generateStateChainlinkLike(feed, chainlinkMap, backedMap, redstoneMap, blockNumber, multiContract) {
|
|
150
|
-
let aggreagator;
|
|
151
|
-
let decimals;
|
|
152
|
-
// it can be Chainlink or Redstone feed
|
|
153
|
-
// if the call getReadAggregatorMultiCallInput fail with a Chainlink instance
|
|
154
|
-
// then it is a Redstone one
|
|
155
|
-
try {
|
|
156
|
-
// Chainlink
|
|
157
|
-
const proxyResult = (await multiContract.methods
|
|
158
|
-
.aggregate([
|
|
159
|
-
chainlink_1.ChainLinkSubscriber.getReadAggregatorMultiCallInput(feed),
|
|
160
|
-
chainlink_1.ChainLinkSubscriber.getReadDecimal(feed),
|
|
161
|
-
])
|
|
162
|
-
.call({}, blockNumber)).returnData;
|
|
163
|
-
aggreagator = chainlink_1.ChainLinkSubscriber.readAggregator(proxyResult[0]);
|
|
164
|
-
decimals = Number(chainlink_1.ChainLinkSubscriber.readDecimals(proxyResult[1]));
|
|
165
|
-
chainlinkMap[feed] = {
|
|
166
|
-
proxy: feed,
|
|
167
|
-
aggregator: aggreagator,
|
|
168
|
-
decimals: decimals,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
catch {
|
|
172
|
-
try {
|
|
173
|
-
// Redstone
|
|
174
|
-
const proxyResult = (await multiContract.methods
|
|
175
|
-
.aggregate([
|
|
176
|
-
redstone_1.RedstoneSubscriber.getReadAggregatorMultiCallInput(feed),
|
|
177
|
-
redstone_1.RedstoneSubscriber.getReadDecimal(feed),
|
|
178
|
-
])
|
|
179
|
-
.call({}, blockNumber)).returnData;
|
|
180
|
-
aggreagator = redstone_1.RedstoneSubscriber.readAggregator(proxyResult[0]);
|
|
181
|
-
decimals = Number(redstone_1.RedstoneSubscriber.readDecimals(proxyResult[1]));
|
|
182
|
-
redstoneMap[feed] = {
|
|
183
|
-
proxy: feed,
|
|
184
|
-
aggregator: aggreagator,
|
|
185
|
-
decimals: decimals,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
catch {
|
|
189
|
-
// Backed
|
|
190
|
-
const proxyResult = (await multiContract.methods
|
|
191
|
-
.aggregate([chainlink_1.ChainLinkSubscriber.getReadDecimal(feed)])
|
|
192
|
-
.call({}, blockNumber)).returnData;
|
|
193
|
-
decimals = Number(chainlink_1.ChainLinkSubscriber.readDecimals(proxyResult[0]));
|
|
194
|
-
backedMap[feed] = {
|
|
195
|
-
proxy: feed,
|
|
196
|
-
aggregator: feed,
|
|
197
|
-
decimals: decimals,
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return { chainlinkMap, backedMap, redstoneMap };
|
|
202
|
-
}
|
|
203
|
-
static async getOraclesConfig(transmuterAddress, pythAddress, collaterals, blockNumber, multiContract) {
|
|
204
|
-
const getOracleConfigData = collaterals.map(collat => {
|
|
205
|
-
return {
|
|
206
|
-
callData: transmuter_1.TransmuterSubscriber.interface.encodeFunctionData('getOracle', [collat]),
|
|
207
|
-
target: transmuterAddress,
|
|
208
|
-
};
|
|
209
|
-
});
|
|
210
|
-
const oracleConfigResult = (await multiContract.methods
|
|
211
|
-
.aggregate(getOracleConfigData)
|
|
212
|
-
.call({}, blockNumber)).returnData;
|
|
213
|
-
const oracleConfigs = oracleConfigResult.map((p) => transmuter_1.TransmuterSubscriber.interface.decodeFunctionResult('getOracle', p));
|
|
214
|
-
let chainlinkMap = {};
|
|
215
|
-
let backedMap = {};
|
|
216
|
-
let redstoneMap = {};
|
|
217
|
-
let pythIds = { proxy: pythAddress, ids: [] };
|
|
218
|
-
let morphoMap = {};
|
|
219
|
-
await Promise.all(oracleConfigs.map(async (oracleConfigDecoded) => {
|
|
220
|
-
if (oracleConfigDecoded.oracleType !== types_1.OracleReadType.EXTERNAL) {
|
|
221
|
-
// add all the feed oracles used to their respective channels
|
|
222
|
-
if (oracleConfigDecoded.oracleType === types_1.OracleReadType.CHAINLINK_FEEDS ||
|
|
223
|
-
oracleConfigDecoded.oracleType === types_1.OracleReadType.PYTH ||
|
|
224
|
-
oracleConfigDecoded.oracleType === types_1.OracleReadType.MORPHO_ORACLE) {
|
|
225
|
-
const oracleFeed = transmuter_1.TransmuterSubscriber._decodeOracleFeed(oracleConfigDecoded.oracleType, oracleConfigDecoded.oracleData);
|
|
226
|
-
({ chainlinkMap, backedMap, redstoneMap, pythIds, morphoMap } =
|
|
227
|
-
await AngleTransmuterEventPool._fillMap(chainlinkMap, backedMap, redstoneMap, pythIds, morphoMap, oracleFeed, blockNumber, multiContract));
|
|
228
|
-
}
|
|
229
|
-
if (oracleConfigDecoded.targetType === types_1.OracleReadType.CHAINLINK_FEEDS ||
|
|
230
|
-
oracleConfigDecoded.targetType === types_1.OracleReadType.PYTH ||
|
|
231
|
-
oracleConfigDecoded.targetType === types_1.OracleReadType.MORPHO_ORACLE) {
|
|
232
|
-
const oracleFeed = transmuter_1.TransmuterSubscriber._decodeOracleFeed(oracleConfigDecoded.targetType, oracleConfigDecoded.targetData);
|
|
233
|
-
({ chainlinkMap, backedMap, redstoneMap, pythIds, morphoMap } =
|
|
234
|
-
await AngleTransmuterEventPool._fillMap(chainlinkMap, backedMap, redstoneMap, pythIds, morphoMap, oracleFeed, blockNumber, multiContract));
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}));
|
|
238
|
-
return {
|
|
239
|
-
chainlink: chainlinkMap,
|
|
240
|
-
backed: backedMap,
|
|
241
|
-
redstone: redstoneMap,
|
|
242
|
-
pyth: pythIds,
|
|
243
|
-
morpho: morphoMap,
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
static async getConfig(dexParams, blockNumber, multiContract) {
|
|
247
|
-
const collaterals = await AngleTransmuterEventPool.getCollateralsList(dexParams.transmuter, blockNumber, multiContract);
|
|
248
|
-
// get all oracles feed
|
|
249
|
-
const oracles = await AngleTransmuterEventPool.getOraclesConfig(dexParams.transmuter, dexParams.pyth, collaterals, blockNumber, multiContract);
|
|
250
|
-
return {
|
|
251
|
-
stablecoin: dexParams.stablecoin,
|
|
252
|
-
transmuter: dexParams.transmuter,
|
|
253
|
-
collaterals: collaterals,
|
|
254
|
-
oracles: oracles,
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
258
|
-
UTILS
|
|
259
|
-
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
|
|
260
|
-
_readMint(config, state, collateral, blockNumber) {
|
|
261
|
-
const configOracle = state.transmuter.collaterals[collateral].config;
|
|
262
|
-
if (configOracle.oracleType === types_1.OracleReadType.EXTERNAL) {
|
|
263
|
-
return 1;
|
|
264
|
-
}
|
|
265
|
-
let target;
|
|
266
|
-
let spot;
|
|
267
|
-
({ spot, target } = this._readSpotAndTarget(config, state, collateral, blockNumber));
|
|
268
|
-
if (target < spot)
|
|
269
|
-
spot = target;
|
|
270
|
-
return spot;
|
|
271
|
-
}
|
|
272
|
-
_getBurnOracle(config, state, collateral, blockNumber) {
|
|
273
|
-
return config.collaterals.reduce((acc, comparedCollat, j) => {
|
|
274
|
-
let ratio;
|
|
275
|
-
if (comparedCollat.toLowerCase() === collateral.toLowerCase()) {
|
|
276
|
-
let oracleValue;
|
|
277
|
-
({ oracleValue, ratio } = this._readBurn(config, state, comparedCollat, blockNumber));
|
|
278
|
-
acc.oracleValue = oracleValue;
|
|
279
|
-
}
|
|
280
|
-
else
|
|
281
|
-
({ ratio } = this._readBurn(config, state, comparedCollat, blockNumber));
|
|
282
|
-
if (ratio < acc.minRatio)
|
|
283
|
-
acc.minRatio = ratio;
|
|
284
|
-
return acc;
|
|
285
|
-
}, { oracleValue: 0, minRatio: 1 });
|
|
286
|
-
}
|
|
287
|
-
_readBurn(config, state, collateral, blockNumber) {
|
|
288
|
-
const configOracle = state.transmuter.collaterals[collateral].config;
|
|
289
|
-
if (configOracle.oracleType === types_1.OracleReadType.EXTERNAL) {
|
|
290
|
-
return { oracleValue: 1, ratio: 1 };
|
|
291
|
-
}
|
|
292
|
-
let spot;
|
|
293
|
-
let target;
|
|
294
|
-
let burnRatioDeviation;
|
|
295
|
-
({ spot, target, burnRatioDeviation } = this._readSpotAndTarget(config, state, collateral, blockNumber));
|
|
296
|
-
let ratio = 1;
|
|
297
|
-
if (spot < target * (1 - burnRatioDeviation))
|
|
298
|
-
ratio = spot / target;
|
|
299
|
-
else if (spot < target)
|
|
300
|
-
spot = target;
|
|
301
|
-
return { oracleValue: spot, ratio };
|
|
302
|
-
}
|
|
303
|
-
_readSpotAndTarget(config, state, collateral, blockNumber) {
|
|
304
|
-
const configOracle = state.transmuter.collaterals[collateral].config;
|
|
305
|
-
let userDeviation = 0;
|
|
306
|
-
let burnRatioDeviation = 0;
|
|
307
|
-
if (constants_2.BLOCK_UPGRADE_ORACLE <= blockNumber) {
|
|
308
|
-
const hyperparameters = (0, utils_1.filterDictionaryOnly)(ethers_1.ethers.utils.defaultAbiCoder.decode(['uint128 userDeviation', 'uint128 burnRatioDeviation'], configOracle.hyperparameters));
|
|
309
|
-
userDeviation = Number.parseFloat((0, utils_2.formatEther)(hyperparameters.userDeviation.toString()));
|
|
310
|
-
burnRatioDeviation = Number.parseFloat((0, utils_2.formatEther)(hyperparameters.burnRatioDeviation.toString()));
|
|
311
|
-
}
|
|
312
|
-
const targetPrice = this._read(config, state, configOracle.targetType, configOracle.targetFeed, 1);
|
|
313
|
-
let oracleValue = this._read(config, state, configOracle.oracleType, configOracle.oracleFeed, targetPrice);
|
|
314
|
-
if (targetPrice * (1 - userDeviation) < oracleValue &&
|
|
315
|
-
oracleValue < targetPrice * (1 + userDeviation))
|
|
316
|
-
oracleValue = targetPrice;
|
|
317
|
-
return {
|
|
318
|
-
spot: oracleValue,
|
|
319
|
-
target: targetPrice,
|
|
320
|
-
userDeviation,
|
|
321
|
-
burnRatioDeviation,
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
_quoteAmount(quoteType, baseValue) {
|
|
325
|
-
if (quoteType === types_1.OracleQuoteType.UNIT)
|
|
326
|
-
return 1;
|
|
327
|
-
return baseValue;
|
|
328
|
-
}
|
|
329
|
-
_read(config, state, oracleType, feed, baseValue) {
|
|
330
|
-
let price = 1;
|
|
331
|
-
if (oracleType === types_1.OracleReadType.CHAINLINK_FEEDS) {
|
|
332
|
-
price = this._quoteAmount(feed.chainlink.quoteType, baseValue);
|
|
333
|
-
for (let i = 0; i < feed.chainlink.circuitChainlink.length; i++) {
|
|
334
|
-
({ price } = this._readChainlink(config, state, feed.chainlink.circuitChainlink[i], feed.chainlink.circuitChainIsMultiplied[i], price));
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
else if (oracleType === types_1.OracleReadType.PYTH) {
|
|
338
|
-
price = this._quoteAmount(feed.pyth.quoteType, baseValue);
|
|
339
|
-
for (let i = 0; i < feed.pyth.feedIds.length; i++) {
|
|
340
|
-
const id = feed.pyth.feedIds[i];
|
|
341
|
-
const rate = state.oracles.pyth[id].answer;
|
|
342
|
-
if (feed.pyth.isMultiplied[i] === 1)
|
|
343
|
-
price *= rate;
|
|
344
|
-
else
|
|
345
|
-
price /= rate;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
else if (oracleType === types_1.OracleReadType.STABLE) {
|
|
349
|
-
price = 1;
|
|
350
|
-
}
|
|
351
|
-
else if (oracleType === types_1.OracleReadType.NO_ORACLE) {
|
|
352
|
-
price = baseValue;
|
|
353
|
-
}
|
|
354
|
-
else if (oracleType == types_1.OracleReadType.MAX) {
|
|
355
|
-
price = feed.maxValue;
|
|
356
|
-
}
|
|
357
|
-
else if (oracleType == types_1.OracleReadType.MORPHO_ORACLE) {
|
|
358
|
-
const morphoOracleConfig = config.oracles.morpho[feed.morpho.oracle];
|
|
359
|
-
const baseVaultPrice = morphoOracleConfig.baseVault !== ethers_1.ethers.constants.AddressZero
|
|
360
|
-
? (morphoOracleConfig.baseVaultConversion *
|
|
361
|
-
state.oracles.morphoVault[morphoOracleConfig.baseVault]
|
|
362
|
-
.totalAssets) /
|
|
363
|
-
state.oracles.morphoVault[morphoOracleConfig.baseVault].totalSupply
|
|
364
|
-
: 1n;
|
|
365
|
-
const quoteVaultPrice = morphoOracleConfig.quoteVault !== ethers_1.ethers.constants.AddressZero
|
|
366
|
-
? (morphoOracleConfig.quoteVaultConversion *
|
|
367
|
-
state.oracles.morphoVault[morphoOracleConfig.quoteVault]
|
|
368
|
-
.totalAssets) /
|
|
369
|
-
state.oracles.morphoVault[morphoOracleConfig.quoteVault].totalSupply
|
|
370
|
-
: 1n;
|
|
371
|
-
const baseFeed1Price = morphoOracleConfig.baseFeed1 !== ethers_1.ethers.constants.AddressZero
|
|
372
|
-
? this._readMorphoFeedChainlink(config, state, morphoOracleConfig.baseFeed1)
|
|
373
|
-
: 1n;
|
|
374
|
-
const baseFeed2Price = morphoOracleConfig.baseFeed2 !== ethers_1.ethers.constants.AddressZero
|
|
375
|
-
? this._readMorphoFeedChainlink(config, state, morphoOracleConfig.baseFeed2)
|
|
376
|
-
: 1n;
|
|
377
|
-
const quoteFeed1Price = morphoOracleConfig.quoteFeed1 !== ethers_1.ethers.constants.AddressZero
|
|
378
|
-
? this._readMorphoFeedChainlink(config, state, morphoOracleConfig.quoteFeed1)
|
|
379
|
-
: 1n;
|
|
380
|
-
const quoteFeed2Price = morphoOracleConfig.quoteFeed2 !== ethers_1.ethers.constants.AddressZero
|
|
381
|
-
? this._readMorphoFeedChainlink(config, state, morphoOracleConfig.quoteFeed2)
|
|
382
|
-
: 1n;
|
|
383
|
-
price = Number.parseFloat((0, utils_2.formatUnits)((morphoOracleConfig.scaleFactor *
|
|
384
|
-
baseVaultPrice *
|
|
385
|
-
baseFeed1Price *
|
|
386
|
-
baseFeed2Price) /
|
|
387
|
-
quoteVaultPrice /
|
|
388
|
-
quoteFeed1Price /
|
|
389
|
-
quoteFeed2Price, 36));
|
|
390
|
-
}
|
|
391
|
-
return price;
|
|
392
|
-
}
|
|
393
|
-
_readChainlink(config, state, id, isMultiplied, price) {
|
|
394
|
-
let decimals;
|
|
395
|
-
if (Object.keys(config.oracles.chainlink).includes(id))
|
|
396
|
-
decimals = config.oracles.chainlink[id].decimals;
|
|
397
|
-
else if (Object.keys(config.oracles.redstone).includes(id))
|
|
398
|
-
decimals = config.oracles.redstone[id].decimals;
|
|
399
|
-
else
|
|
400
|
-
decimals = config.oracles.backed[id].decimals;
|
|
401
|
-
const rate = Number.parseFloat((0, utils_2.formatUnits)(state.oracles.chainlink[id].answer.toString(), decimals));
|
|
402
|
-
if (isMultiplied === 1)
|
|
403
|
-
price *= rate;
|
|
404
|
-
else
|
|
405
|
-
price /= rate;
|
|
406
|
-
return { price, decimals };
|
|
407
|
-
}
|
|
408
|
-
_readMorphoFeedChainlink(config, state, id) {
|
|
409
|
-
const { price, decimals } = this._readChainlink(config, state, id, 1, 1);
|
|
410
|
-
return (0, utils_3.bigIntify)((0, utils_2.parseUnits)(price.toString(), decimals));
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
exports.AngleTransmuterEventPool = AngleTransmuterEventPool;
|
|
414
|
-
AngleTransmuterEventPool.angleTransmuterIface = new abi_1.Interface(Transmuter_json_1.default);
|
|
415
|
-
//# sourceMappingURL=angle-transmuter-pool.js.map
|