@paraswap/dex-lib 3.8.2 → 3.8.3
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/.vscode/launch.json +13 -0
- package/.vscode/settings.json +3 -0
- package/build/abi/AaveV1_lending_pool.json +27 -0
- package/build/abi/Uncompressor.json +250 -0
- package/build/abi/integral/factory.json +333 -0
- package/build/abi/integral/oracle.json +501 -0
- package/build/abi/integral/pool.json +1041 -0
- package/build/abi/integral/relayer.json +1536 -0
- package/build/abi/oswap/oswap.abi.json +452 -0
- package/build/abi/platypus/asset.json +490 -0
- package/build/abi/platypus/avax-pool.json +820 -0
- package/build/abi/platypus/oracle.json +119 -0
- package/build/abi/platypus/pool.json +677 -0
- package/build/abi/smardex/all/smardex-router.json +648 -0
- package/build/abi/smardex/layer-1/smardex-factory.json +242 -0
- package/build/abi/smardex/layer-1/smardex-pool.json +506 -0
- package/build/abi/smardex/layer-2/smardex-factory.json +185 -0
- package/build/abi/smardex/layer-2/smardex-pool.json +578 -0
- package/build/abi/swaap-v1/pool.json +1346 -0
- package/build/dex/aave-v1/aave-v1.d.ts +33 -0
- package/build/dex/aave-v1/aave-v1.js +158 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -0
- package/build/dex/aave-v1/config.d.ts +11 -0
- package/build/dex/aave-v1/config.js +20 -0
- package/build/dex/aave-v1/config.js.map +1 -0
- package/build/dex/aave-v1/tokens-mainnet.json +134 -0
- package/build/dex/aave-v1/tokens.d.ts +3 -0
- package/build/dex/aave-v1/tokens.js +50 -0
- package/build/dex/aave-v1/tokens.js.map +1 -0
- package/build/dex/aave-v1/types.d.ts +12 -0
- package/build/dex/aave-v1/types.js +3 -0
- package/build/dex/aave-v1/types.js.map +1 -0
- package/build/dex/aave-v3/aave-v3.js +2 -1
- package/build/dex/aave-v3/aave-v3.js.map +1 -1
- package/build/dex/aave-v3-stata/aave-v3-stata.js +1 -0
- package/build/dex/aave-v3-stata/aave-v3-stata.js.map +1 -1
- package/build/dex/angle-staked-stable/angle-staked-stable.js +4 -1
- package/build/dex/angle-staked-stable/angle-staked-stable.js.map +1 -1
- package/build/dex/bProtocol.d.ts +18 -0
- package/build/dex/bProtocol.js +39 -0
- package/build/dex/bProtocol.js.map +1 -0
- package/build/dex/bancor.d.ts +26 -0
- package/build/dex/bancor.js +58 -0
- package/build/dex/bancor.js.map +1 -0
- package/build/dex/compound/compound.js +2 -1
- package/build/dex/compound/compound.js.map +1 -1
- package/build/dex/compound.d.ts +18 -0
- package/build/dex/compound.js +46 -0
- package/build/dex/compound.js.map +1 -0
- package/build/dex/curve-v2.d.ts +58 -0
- package/build/dex/curve-v2.js +180 -0
- package/build/dex/curve-v2.js.map +1 -0
- package/build/dex/dodo-v1.d.ts +33 -0
- package/build/dex/dodo-v1.js +63 -0
- package/build/dex/dodo-v1.js.map +1 -0
- package/build/dex/etherfi/etherfi.d.ts +26 -0
- package/build/dex/etherfi/etherfi.js +96 -0
- package/build/dex/etherfi/etherfi.js.map +1 -0
- package/build/dex/etherfi.js +4 -1
- package/build/dex/etherfi.js.map +1 -1
- package/build/dex/idle-dao/idle-dao.js +1 -0
- package/build/dex/idle-dao/idle-dao.js.map +1 -1
- package/build/dex/integral/config.d.ts +4 -0
- package/build/dex/integral/config.js +20 -0
- package/build/dex/integral/config.js.map +1 -0
- package/build/dex/integral/context.d.ts +33 -0
- package/build/dex/integral/context.js +98 -0
- package/build/dex/integral/context.js.map +1 -0
- package/build/dex/integral/helpers.d.ts +17 -0
- package/build/dex/integral/helpers.js +157 -0
- package/build/dex/integral/helpers.js.map +1 -0
- package/build/dex/integral/integral-factory.d.ts +21 -0
- package/build/dex/integral/integral-factory.js +92 -0
- package/build/dex/integral/integral-factory.js.map +1 -0
- package/build/dex/integral/integral-pool.d.ts +46 -0
- package/build/dex/integral/integral-pool.js +143 -0
- package/build/dex/integral/integral-pool.js.map +1 -0
- package/build/dex/integral/integral-pricing.d.ts +18 -0
- package/build/dex/integral/integral-pricing.js +114 -0
- package/build/dex/integral/integral-pricing.js.map +1 -0
- package/build/dex/integral/integral-relayer.d.ts +39 -0
- package/build/dex/integral/integral-relayer.js +189 -0
- package/build/dex/integral/integral-relayer.js.map +1 -0
- package/build/dex/integral/integral-token.d.ts +22 -0
- package/build/dex/integral/integral-token.js +55 -0
- package/build/dex/integral/integral-token.js.map +1 -0
- package/build/dex/integral/integral.d.ts +41 -0
- package/build/dex/integral/integral.js +382 -0
- package/build/dex/integral/integral.js.map +1 -0
- package/build/dex/integral/types.d.ts +84 -0
- package/build/dex/integral/types.js +9 -0
- package/build/dex/integral/types.js.map +1 -0
- package/build/dex/integral/utils.d.ts +6 -0
- package/build/dex/integral/utils.js +23 -0
- package/build/dex/integral/utils.js.map +1 -0
- package/build/dex/lido.d.ts +19 -0
- package/build/dex/lido.js +42 -0
- package/build/dex/lido.js.map +1 -0
- package/build/dex/mStable.js +1 -1
- package/build/dex/mStable.js.map +1 -1
- package/build/dex/onebit.d.ts +25 -0
- package/build/dex/onebit.js +42 -0
- package/build/dex/onebit.js.map +1 -0
- package/build/dex/oswap/config.d.ts +5 -0
- package/build/dex/oswap/config.js +31 -0
- package/build/dex/oswap/config.js.map +1 -0
- package/build/dex/oswap/oswap-pool.d.ts +51 -0
- package/build/dex/oswap/oswap-pool.js +150 -0
- package/build/dex/oswap/oswap-pool.js.map +1 -0
- package/build/dex/oswap/oswap.d.ts +46 -0
- package/build/dex/oswap/oswap.js +266 -0
- package/build/dex/oswap/oswap.js.map +1 -0
- package/build/dex/oswap/types.d.ts +20 -0
- package/build/dex/oswap/types.js +3 -0
- package/build/dex/oswap/types.js.map +1 -0
- package/build/dex/platypus/asset.d.ts +14 -0
- package/build/dex/platypus/asset.js +97 -0
- package/build/dex/platypus/asset.js.map +1 -0
- package/build/dex/platypus/config.d.ts +11 -0
- package/build/dex/platypus/config.js +69 -0
- package/build/dex/platypus/config.js.map +1 -0
- package/build/dex/platypus/platypus.d.ts +62 -0
- package/build/dex/platypus/platypus.js +442 -0
- package/build/dex/platypus/platypus.js.map +1 -0
- package/build/dex/platypus/pool-avax.d.ts +8 -0
- package/build/dex/platypus/pool-avax.js +54 -0
- package/build/dex/platypus/pool-avax.js.map +1 -0
- package/build/dex/platypus/pool-base.d.ts +19 -0
- package/build/dex/platypus/pool-base.js +86 -0
- package/build/dex/platypus/pool-base.js.map +1 -0
- package/build/dex/platypus/pool-pure.d.ts +8 -0
- package/build/dex/platypus/pool-pure.js +37 -0
- package/build/dex/platypus/pool-pure.js.map +1 -0
- package/build/dex/platypus/pool-subscriber.d.ts +14 -0
- package/build/dex/platypus/pool-subscriber.js +167 -0
- package/build/dex/platypus/pool-subscriber.js.map +1 -0
- package/build/dex/platypus/pool.d.ts +8 -0
- package/build/dex/platypus/pool.js +58 -0
- package/build/dex/platypus/pool.js.map +1 -0
- package/build/dex/platypus/types.d.ts +92 -0
- package/build/dex/platypus/types.js +10 -0
- package/build/dex/platypus/types.js.map +1 -0
- package/build/dex/quickswap/spiritswap-v3.d.ts +6 -0
- package/build/dex/quickswap/spiritswap-v3.js +19 -0
- package/build/dex/quickswap/spiritswap-v3.js.map +1 -0
- package/build/dex/sdai/config.d.ts +11 -0
- package/build/dex/sdai/config.js +21 -0
- package/build/dex/sdai/config.js.map +1 -0
- package/build/dex/sdai/constants.d.ts +2 -0
- package/build/dex/sdai/constants.js +6 -0
- package/build/dex/sdai/constants.js.map +1 -0
- package/build/dex/sdai/scripts/validate-state.d.ts +1 -0
- package/build/dex/sdai/scripts/validate-state.js +102 -0
- package/build/dex/sdai/scripts/validate-state.js.map +1 -0
- package/build/dex/sdai/sdai-pool.d.ts +16 -0
- package/build/dex/sdai/sdai-pool.js +85 -0
- package/build/dex/sdai/sdai-pool.js.map +1 -0
- package/build/dex/sdai/sdai.d.ts +51 -0
- package/build/dex/sdai/sdai.js +172 -0
- package/build/dex/sdai/sdai.js.map +1 -0
- package/build/dex/sdai/types.d.ts +21 -0
- package/build/dex/sdai/types.js +11 -0
- package/build/dex/sdai/types.js.map +1 -0
- package/build/dex/sdai/utils.d.ts +4 -0
- package/build/dex/sdai/utils.js +39 -0
- package/build/dex/sdai/utils.js.map +1 -0
- package/build/dex/simple-exchange.d.ts +1 -1
- package/build/dex/simple-exchange.js +4 -2
- package/build/dex/simple-exchange.js.map +1 -1
- package/build/dex/smardex/config.d.ts +4 -0
- package/build/dex/smardex/config.js +64 -0
- package/build/dex/smardex/config.js.map +1 -0
- package/build/dex/smardex/constants.d.ts +18 -0
- package/build/dex/smardex/constants.js +33 -0
- package/build/dex/smardex/constants.js.map +1 -0
- package/build/dex/smardex/sdk/constants.d.ts +6 -0
- package/build/dex/smardex/sdk/constants.js +13 -0
- package/build/dex/smardex/sdk/constants.js.map +1 -0
- package/build/dex/smardex/sdk/core.d.ts +113 -0
- package/build/dex/smardex/sdk/core.js +499 -0
- package/build/dex/smardex/sdk/core.js.map +1 -0
- package/build/dex/smardex/sdk/errors.d.ts +15 -0
- package/build/dex/smardex/sdk/errors.js +22 -0
- package/build/dex/smardex/sdk/errors.js.map +1 -0
- package/build/dex/smardex/sdk/types.d.ts +62 -0
- package/build/dex/smardex/sdk/types.js +3 -0
- package/build/dex/smardex/sdk/types.js.map +1 -0
- package/build/dex/smardex/sdk/utils.d.ts +44 -0
- package/build/dex/smardex/sdk/utils.js +133 -0
- package/build/dex/smardex/sdk/utils.js.map +1 -0
- package/build/dex/smardex/smardex-event-pool.d.ts +28 -0
- package/build/dex/smardex/smardex-event-pool.js +119 -0
- package/build/dex/smardex/smardex-event-pool.js.map +1 -0
- package/build/dex/smardex/smardex.d.ts +65 -0
- package/build/dex/smardex/smardex.js +519 -0
- package/build/dex/smardex/smardex.js.map +1 -0
- package/build/dex/smardex/types.d.ts +55 -0
- package/build/dex/smardex/types.js +3 -0
- package/build/dex/smardex/types.js.map +1 -0
- package/build/dex/smoothy.d.ts +26 -0
- package/build/dex/smoothy.js +48 -0
- package/build/dex/smoothy.js.map +1 -0
- package/build/dex/solidly/forks-override/cone.d.ts +22 -0
- package/build/dex/solidly/forks-override/cone.js +53 -0
- package/build/dex/solidly/forks-override/cone.js.map +1 -0
- package/build/dex/solidly/forks-override/solisnek.d.ts +8 -0
- package/build/dex/solidly/forks-override/solisnek.js +15 -0
- package/build/dex/solidly/forks-override/solisnek.js.map +1 -0
- package/build/dex/spark/spark.js +2 -1
- package/build/dex/spark/spark.js.map +1 -1
- package/build/dex/stable-pool.d.ts +28 -0
- package/build/dex/stable-pool.js +62 -0
- package/build/dex/stable-pool.js.map +1 -0
- package/build/dex/swaap-v1/config.d.ts +17 -0
- package/build/dex/swaap-v1/config.js +56 -0
- package/build/dex/swaap-v1/config.js.map +1 -0
- package/build/dex/swaap-v1/constants.d.ts +6 -0
- package/build/dex/swaap-v1/constants.js +17 -0
- package/build/dex/swaap-v1/constants.js.map +1 -0
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.d.ts +25 -0
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.js +62 -0
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.js.map +1 -0
- package/build/dex/swaap-v1/libraries/Const.d.ts +18 -0
- package/build/dex/swaap-v1/libraries/Const.js +26 -0
- package/build/dex/swaap-v1/libraries/Const.js.map +1 -0
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.d.ts +77 -0
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js +316 -0
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js.map +1 -0
- package/build/dex/swaap-v1/libraries/LogExpMath.d.ts +75 -0
- package/build/dex/swaap-v1/libraries/LogExpMath.js +418 -0
- package/build/dex/swaap-v1/libraries/LogExpMath.js.map +1 -0
- package/build/dex/swaap-v1/libraries/MathMMM.d.ts +185 -0
- package/build/dex/swaap-v1/libraries/MathMMM.js +453 -0
- package/build/dex/swaap-v1/libraries/MathMMM.js.map +1 -0
- package/build/dex/swaap-v1/libraries/Num.d.ts +31 -0
- package/build/dex/swaap-v1/libraries/Num.js +167 -0
- package/build/dex/swaap-v1/libraries/Num.js.map +1 -0
- package/build/dex/swaap-v1/libraries/PoolQuotations.d.ts +23 -0
- package/build/dex/swaap-v1/libraries/PoolQuotations.js +131 -0
- package/build/dex/swaap-v1/libraries/PoolQuotations.js.map +1 -0
- package/build/dex/swaap-v1/libraries/Struct.d.ts +56 -0
- package/build/dex/swaap-v1/libraries/Struct.js +3 -0
- package/build/dex/swaap-v1/libraries/Struct.js.map +1 -0
- package/build/dex/swaap-v1/swaap-v1-pool.d.ts +45 -0
- package/build/dex/swaap-v1/swaap-v1-pool.js +656 -0
- package/build/dex/swaap-v1/swaap-v1-pool.js.map +1 -0
- package/build/dex/swaap-v1/swaap-v1.d.ts +61 -0
- package/build/dex/swaap-v1/swaap-v1.js +369 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -0
- package/build/dex/swaap-v1/types.d.ts +106 -0
- package/build/dex/swaap-v1/types.js +9 -0
- package/build/dex/swaap-v1/types.js.map +1 -0
- package/build/dex/trader-joe-v2.1.d.ts +43 -0
- package/build/dex/trader-joe-v2.1.js +79 -0
- package/build/dex/trader-joe-v2.1.js.map +1 -0
- package/build/executor/Executor01BytecodeBuilder.js +3 -1
- package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor02BytecodeBuilder.js +3 -1
- package/build/executor/Executor02BytecodeBuilder.js.map +1 -1
- package/build/executor/Executor03BytecodeBuilder.js +2 -0
- package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
- package/build/executor/ExecutorBytecodeBuilder.js +2 -0
- package/build/executor/ExecutorBytecodeBuilder.js.map +1 -1
- package/build/executor/compressor/Compressor.d.ts +23 -0
- package/build/executor/compressor/Compressor.js +144 -0
- package/build/executor/compressor/Compressor.js.map +1 -0
- package/build/executor/compressor/compress.d.ts +17 -0
- package/build/executor/compressor/compress.js +187 -0
- package/build/executor/compressor/compress.js.map +1 -0
- package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +6 -0
- package/build/executor/compressor/compress_functions/addressSubstitution.js +29 -0
- package/build/executor/compressor/compress_functions/addressSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +10 -0
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +40 -0
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +1 -0
- package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +11 -0
- package/build/executor/compressor/compress_functions/byteSubstitution.js +64 -0
- package/build/executor/compressor/compress_functions/byteSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +7 -0
- package/build/executor/compressor/compress_functions/ffSubstitution.js +54 -0
- package/build/executor/compressor/compress_functions/ffSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +8 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +67 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +1 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +8 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +61 -0
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +1 -0
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +6 -0
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +37 -0
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +1 -0
- package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +9 -0
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js +33 -0
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +1 -0
- package/build/executor/compressor/fetchSaved.d.ts +0 -0
- package/build/executor/compressor/fetchSaved.js +17 -0
- package/build/executor/compressor/fetchSaved.js.map +1 -0
- package/build/executor/compressor/utils/computeCostL2.d.ts +2 -0
- package/build/executor/compressor/utils/computeCostL2.js +14 -0
- package/build/executor/compressor/utils/computeCostL2.js.map +1 -0
- package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +2 -0
- package/build/executor/compressor/utils/findLongestDuplicatedString.js +30 -0
- package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +1 -0
- package/build/executor/compressor/utils/getAllIndexes.d.ts +2 -0
- package/build/executor/compressor/utils/getAllIndexes.js +12 -0
- package/build/executor/compressor/utils/getAllIndexes.js.map +1 -0
- package/build/executor/compressor/utils/getByteForAddress.d.ts +2 -0
- package/build/executor/compressor/utils/getByteForAddress.js +14 -0
- package/build/executor/compressor/utils/getByteForAddress.js.map +1 -0
- package/build/executor/compressor/utils/intTo2Bytes.d.ts +2 -0
- package/build/executor/compressor/utils/intTo2Bytes.js +14 -0
- package/build/executor/compressor/utils/intTo2Bytes.js.map +1 -0
- package/build/executor/compressor/utils/intTo3Bytes.d.ts +2 -0
- package/build/executor/compressor/utils/intTo3Bytes.js +18 -0
- package/build/executor/compressor/utils/intTo3Bytes.js.map +1 -0
- package/build/executor/compressor/utils/intToByte.d.ts +2 -0
- package/build/executor/compressor/utils/intToByte.js +10 -0
- package/build/executor/compressor/utils/intToByte.js.map +1 -0
- package/build/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/dex/aave-v3/aave-v3-e2e.test.ts +4 -9
- package/src/dex/aave-v3/aave-v3.ts +5 -0
- package/src/dex/aave-v3-stata/aave-v3-stata.ts +1 -0
- package/src/dex/angle-staked-stable/angle-staked-stable.ts +8 -0
- package/src/dex/compound/compound.ts +5 -0
- package/src/dex/etherfi.ts +5 -0
- package/src/dex/idle-dao/idle-dao.ts +1 -0
- package/src/dex/simple-exchange.ts +5 -5
- package/src/dex/spark/spark-e2e.test.ts +9 -1
- package/src/dex/spark/spark.ts +5 -0
- package/src/executor/Executor01BytecodeBuilder.ts +3 -1
- package/src/executor/Executor02BytecodeBuilder.ts +3 -1
- package/src/executor/Executor03BytecodeBuilder.ts +2 -0
- package/src/executor/ExecutorBytecodeBuilder.ts +2 -0
- package/src/executor/executor01-bytecode-builder-e2e.test.ts +25 -0
- package/src/executor/executor02-bytecode-builder-e2e.test.ts +29 -0
- package/src/types.ts +1 -0
- package/tests/constants-e2e.ts +13 -13
- package/tests/utils-e2e.ts +1 -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
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SDaiEventPool = void 0;
|
|
4
|
+
const bigint_constants_1 = require("../../bigint-constants");
|
|
5
|
+
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const RAY = bigint_constants_1.BI_POWS[27];
|
|
8
|
+
const ZERO = BigInt(0);
|
|
9
|
+
const TWO = BigInt(2);
|
|
10
|
+
const HALF = RAY / TWO;
|
|
11
|
+
// function file(bytes32,uint256)
|
|
12
|
+
const FILE_TOPICHASH = `0x29ae811400000000000000000000000000000000000000000000000000000000`;
|
|
13
|
+
// function drip()
|
|
14
|
+
const DRIP_TOPICHASH = `0x9f678cca00000000000000000000000000000000000000000000000000000000`;
|
|
15
|
+
// function cage()
|
|
16
|
+
const CAGE_TOPICHASH = `0x6924500900000000000000000000000000000000000000000000000000000000`;
|
|
17
|
+
// bytes32 repr of "dsr" string
|
|
18
|
+
const DSR_TOPIC = `0x6473720000000000000000000000000000000000000000000000000000000000`;
|
|
19
|
+
const rpow = (x, n) => {
|
|
20
|
+
if (!x && !n)
|
|
21
|
+
return RAY;
|
|
22
|
+
if (!x)
|
|
23
|
+
return ZERO;
|
|
24
|
+
let z = n % TWO > ZERO ? x : RAY;
|
|
25
|
+
for (n = n / TWO; n; n /= TWO) {
|
|
26
|
+
x = (x * x + HALF) / RAY;
|
|
27
|
+
if (n % TWO > ZERO) {
|
|
28
|
+
z = (z * x + HALF) / RAY;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return z;
|
|
32
|
+
};
|
|
33
|
+
const calcChi = (state, currentTimestamp) => {
|
|
34
|
+
currentTimestamp || (currentTimestamp = Math.floor(Date.now() / 1000));
|
|
35
|
+
if (!state.live)
|
|
36
|
+
return RAY;
|
|
37
|
+
const { dsr: dsr_, chi: chi_, rho: rho_ } = state;
|
|
38
|
+
const now = BigInt(currentTimestamp);
|
|
39
|
+
const rho = BigInt(rho_);
|
|
40
|
+
const dsr = BigInt(dsr_);
|
|
41
|
+
const chi = BigInt(chi_);
|
|
42
|
+
return now > rho ? (rpow(dsr, now - rho) * chi) / RAY : chi;
|
|
43
|
+
};
|
|
44
|
+
class SDaiEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
45
|
+
constructor(parentName, dexHelper, potAddress, potInterface, logger) {
|
|
46
|
+
super(parentName, 'sdai', dexHelper, logger);
|
|
47
|
+
this.dexHelper = dexHelper;
|
|
48
|
+
this.potAddress = potAddress;
|
|
49
|
+
this.potInterface = potInterface;
|
|
50
|
+
this.addressesSubscribed = [potAddress];
|
|
51
|
+
}
|
|
52
|
+
processLog(state, log, blockHeader) {
|
|
53
|
+
if (log.topics[0] === FILE_TOPICHASH && log.topics[2] === DSR_TOPIC) {
|
|
54
|
+
return {
|
|
55
|
+
...state,
|
|
56
|
+
dsr: BigInt(log.topics[3]).toString(),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (log.topics[0] === DRIP_TOPICHASH) {
|
|
60
|
+
return {
|
|
61
|
+
...state,
|
|
62
|
+
rho: blockHeader.timestamp.toString(),
|
|
63
|
+
chi: calcChi(state, +blockHeader.timestamp).toString(),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
async generateState(blockNumber = 'latest') {
|
|
69
|
+
return (0, utils_1.getOnChainState)(this.dexHelper.multiContract, this.potAddress, this.potInterface, blockNumber);
|
|
70
|
+
}
|
|
71
|
+
convertToSDai(daiAmount, blockNumber) {
|
|
72
|
+
const state = this.getState(blockNumber);
|
|
73
|
+
if (!state)
|
|
74
|
+
throw new Error(`SDai state at ${blockNumber} does not exists`);
|
|
75
|
+
return (daiAmount * RAY) / calcChi(state);
|
|
76
|
+
}
|
|
77
|
+
convertToDai(sdaiAmount, blockNumber) {
|
|
78
|
+
const state = this.getState(blockNumber);
|
|
79
|
+
if (!state)
|
|
80
|
+
throw new Error(`SDai state at ${blockNumber} does not exists`);
|
|
81
|
+
return (sdaiAmount * calcChi(state)) / RAY;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.SDaiEventPool = SDaiEventPool;
|
|
85
|
+
//# sourceMappingURL=sdai-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdai-pool.js","sourceRoot":"","sources":["../../../src/dex/sdai/sdai-pool.ts"],"names":[],"mappings":";;;AAAA,6DAAiD;AACjD,+EAA0E;AAO1E,mCAA0C;AAE1C,MAAM,GAAG,GAAG,0BAAO,CAAC,EAAE,CAAC,CAAC;AACxB,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACvB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACtB,MAAM,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC;AAEvB,iCAAiC;AACjC,MAAM,cAAc,GAAG,oEAAoE,CAAC;AAC5F,kBAAkB;AAClB,MAAM,cAAc,GAAG,oEAAoE,CAAC;AAC5F,kBAAkB;AAClB,MAAM,cAAc,GAAG,oEAAoE,CAAC;AAC5F,+BAA+B;AAC/B,MAAM,SAAS,GAAG,oEAAoE,CAAC;AAEvF,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE;IAC5C,IAAI,CAAC,CAAC,IAAI,CAAC,C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G,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,WAAW,kBAAkB,CAAC,CAAC;QAE5E,OAAO,CAAC,SAAS,GAAG,GAAG,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,YAAY,CAAC,UAAkB,EAAE,WAAmB;QAClD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,WAAW,kBAAkB,CAAC,CAAC;QAE5E,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC;IAC7C,CAAC;CACF;AA3DD,sCA2DC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
2
|
+
import { IDex } from '../idex';
|
|
3
|
+
import { SDaiParams, SDaiData } from './types';
|
|
4
|
+
import { Network, SwapSide } from '../../constants';
|
|
5
|
+
import { AdapterExchangeParam, Address, ExchangePrices, Logger, PoolLiquidity, PoolPrices, SimpleExchangeParam, Token } from '../../types';
|
|
6
|
+
import { IDexHelper } from '../../dex-helper';
|
|
7
|
+
import { Interface } from 'ethers/lib/utils';
|
|
8
|
+
import { SDaiEventPool } from './sdai-pool';
|
|
9
|
+
export declare class SDai extends SimpleExchange implements IDex<SDaiData, SDaiParams> {
|
|
10
|
+
protected network: Network;
|
|
11
|
+
protected dexHelper: IDexHelper;
|
|
12
|
+
readonly daiAddress: string;
|
|
13
|
+
readonly sdaiAddress: string;
|
|
14
|
+
readonly potAddress: string;
|
|
15
|
+
protected adapters: {
|
|
16
|
+
[side: string]: {
|
|
17
|
+
name: string;
|
|
18
|
+
index: number;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
protected sdaiInterface: Interface;
|
|
22
|
+
protected potInterface: Interface;
|
|
23
|
+
readonly hasConstantPriceLargeAmounts = true;
|
|
24
|
+
readonly isFeeOnTransferSupported = false;
|
|
25
|
+
static dexKeysWithNetwork: {
|
|
26
|
+
key: string;
|
|
27
|
+
networks: Network[];
|
|
28
|
+
}[];
|
|
29
|
+
readonly eventPool: SDaiEventPool;
|
|
30
|
+
logger: Logger;
|
|
31
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, daiAddress?: string, sdaiAddress?: string, potAddress?: string, adapters?: {
|
|
32
|
+
[side: string]: {
|
|
33
|
+
name: string;
|
|
34
|
+
index: number;
|
|
35
|
+
}[];
|
|
36
|
+
}, sdaiInterface?: Interface, potInterface?: Interface);
|
|
37
|
+
getAdapters(side: SwapSide): {
|
|
38
|
+
name: string;
|
|
39
|
+
index: number;
|
|
40
|
+
}[] | null;
|
|
41
|
+
isSDai(tokenAddress: Address): boolean;
|
|
42
|
+
isDai(tokenAddress: Address): boolean;
|
|
43
|
+
isAppropriatePair(srcToken: Token, destToken: Token): boolean;
|
|
44
|
+
initializePricing(blockNumber: number): Promise<void>;
|
|
45
|
+
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
46
|
+
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<SDaiData>>;
|
|
47
|
+
getCalldataGasCost(poolPrices: PoolPrices<SDaiData>): number | number[];
|
|
48
|
+
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
49
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: SDaiData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
50
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: SDaiData, side: SwapSide): AdapterExchangeParam;
|
|
51
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.SDai = void 0;
|
|
30
|
+
const simple_exchange_1 = require("../simple-exchange");
|
|
31
|
+
const types_1 = require("./types");
|
|
32
|
+
const constants_1 = require("../../constants");
|
|
33
|
+
const utils_1 = require("../../utils");
|
|
34
|
+
const config_1 = require("./config");
|
|
35
|
+
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
36
|
+
const pot_json_1 = __importDefault(require("../../abi/maker-psm/pot.json"));
|
|
37
|
+
const SavingsDai_abi_json_1 = __importDefault(require("../../abi/sdai/SavingsDai.abi.json"));
|
|
38
|
+
const utils_2 = require("ethers/lib/utils");
|
|
39
|
+
const sdai_pool_1 = require("./sdai-pool");
|
|
40
|
+
const bigint_constants_1 = require("../../bigint-constants");
|
|
41
|
+
const constants_2 = require("./constants");
|
|
42
|
+
class SDai extends simple_exchange_1.SimpleExchange {
|
|
43
|
+
constructor(network, dexKey, dexHelper, daiAddress = config_1.SDaiConfig[dexKey][network].daiAddress, sdaiAddress = config_1.SDaiConfig[dexKey][network].sdaiAddress, potAddress = config_1.SDaiConfig[dexKey][network].potAddress, adapters = config_1.Adapters[network] || {}, sdaiInterface = new utils_2.Interface(SavingsDai_abi_json_1.default), potInterface = new utils_2.Interface(pot_json_1.default)) {
|
|
44
|
+
super(dexHelper, dexKey);
|
|
45
|
+
this.network = network;
|
|
46
|
+
this.dexHelper = dexHelper;
|
|
47
|
+
this.daiAddress = daiAddress;
|
|
48
|
+
this.sdaiAddress = sdaiAddress;
|
|
49
|
+
this.potAddress = potAddress;
|
|
50
|
+
this.adapters = adapters;
|
|
51
|
+
this.sdaiInterface = sdaiInterface;
|
|
52
|
+
this.potInterface = potInterface;
|
|
53
|
+
this.hasConstantPriceLargeAmounts = true;
|
|
54
|
+
this.isFeeOnTransferSupported = false;
|
|
55
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
56
|
+
this.eventPool = new sdai_pool_1.SDaiEventPool(this.dexKey, dexHelper, this.potAddress, this.potInterface, this.logger);
|
|
57
|
+
}
|
|
58
|
+
getAdapters(side) {
|
|
59
|
+
return this.adapters[side] || null;
|
|
60
|
+
}
|
|
61
|
+
isSDai(tokenAddress) {
|
|
62
|
+
return this.sdaiAddress.toLowerCase() === tokenAddress.toLowerCase();
|
|
63
|
+
}
|
|
64
|
+
isDai(tokenAddress) {
|
|
65
|
+
return this.daiAddress.toLowerCase() === tokenAddress.toLowerCase();
|
|
66
|
+
}
|
|
67
|
+
isAppropriatePair(srcToken, destToken) {
|
|
68
|
+
return ((this.isDai(srcToken.address) && this.isSDai(destToken.address)) ||
|
|
69
|
+
(this.isDai(destToken.address) && this.isSDai(srcToken.address)));
|
|
70
|
+
}
|
|
71
|
+
async initializePricing(blockNumber) {
|
|
72
|
+
await this.eventPool.initialize(blockNumber);
|
|
73
|
+
}
|
|
74
|
+
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
75
|
+
return this.isAppropriatePair(srcToken, destToken)
|
|
76
|
+
? [`${this.dexKey}_${this.sdaiAddress}`]
|
|
77
|
+
: [];
|
|
78
|
+
}
|
|
79
|
+
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
80
|
+
if (!this.isAppropriatePair(srcToken, destToken))
|
|
81
|
+
return null;
|
|
82
|
+
if (!this.eventPool.getState(blockNumber))
|
|
83
|
+
return null;
|
|
84
|
+
if (side === constants_1.SwapSide.SELL) {
|
|
85
|
+
const calcSellFn = (blockNumber, amountIn) => this.isDai(srcToken.address)
|
|
86
|
+
? this.eventPool.convertToSDai(amountIn, blockNumber)
|
|
87
|
+
: this.eventPool.convertToDai(amountIn, blockNumber);
|
|
88
|
+
return [
|
|
89
|
+
{
|
|
90
|
+
prices: amounts.map(amount => calcSellFn(blockNumber, amount)),
|
|
91
|
+
unit: calcSellFn(blockNumber, bigint_constants_1.BI_POWS[18]),
|
|
92
|
+
gasCost: constants_2.SDAI_DEPOSIT_GAS_COST,
|
|
93
|
+
exchange: this.dexKey,
|
|
94
|
+
data: { exchange: `${this.sdaiAddress}` },
|
|
95
|
+
poolAddresses: [`${this.sdaiAddress}`],
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
const calcBuyFn = (blockNumber, amountIn) => this.isDai(srcToken.address)
|
|
101
|
+
? this.eventPool.convertToDai(amountIn, blockNumber)
|
|
102
|
+
: this.eventPool.convertToSDai(amountIn, blockNumber);
|
|
103
|
+
return [
|
|
104
|
+
{
|
|
105
|
+
prices: amounts.map(amount => calcBuyFn(blockNumber, amount)),
|
|
106
|
+
unit: calcBuyFn(blockNumber, bigint_constants_1.BI_POWS[18]),
|
|
107
|
+
gasCost: constants_2.SDAI_REDEEM_GAS_COST,
|
|
108
|
+
exchange: this.dexKey,
|
|
109
|
+
data: { exchange: `${this.sdaiAddress}` },
|
|
110
|
+
poolAddresses: [`${this.sdaiAddress}`],
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
116
|
+
getCalldataGasCost(poolPrices) {
|
|
117
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
118
|
+
}
|
|
119
|
+
async getTopPoolsForToken(tokenAddress, limit) {
|
|
120
|
+
if (!this.isDai(tokenAddress) && !this.isSDai(tokenAddress))
|
|
121
|
+
return [];
|
|
122
|
+
return [
|
|
123
|
+
{
|
|
124
|
+
exchange: this.dexKey,
|
|
125
|
+
address: this.sdaiAddress,
|
|
126
|
+
connectorTokens: [
|
|
127
|
+
{
|
|
128
|
+
decimals: 18,
|
|
129
|
+
address: this.isDai(tokenAddress)
|
|
130
|
+
? this.sdaiAddress
|
|
131
|
+
: this.daiAddress,
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
139
|
+
const isSell = side === constants_1.SwapSide.SELL;
|
|
140
|
+
const { exchange } = data;
|
|
141
|
+
let swapData;
|
|
142
|
+
if (this.isDai(srcToken)) {
|
|
143
|
+
swapData = this.sdaiInterface.encodeFunctionData(isSell ? types_1.SDaiFunctions.deposit : types_1.SDaiFunctions.mint, [isSell ? srcAmount : destAmount, this.augustusAddress]);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
swapData = this.sdaiInterface.encodeFunctionData(isSell ? types_1.SDaiFunctions.redeem : types_1.SDaiFunctions.withdraw, [
|
|
147
|
+
isSell ? srcAmount : destAmount,
|
|
148
|
+
this.augustusAddress,
|
|
149
|
+
this.augustusAddress,
|
|
150
|
+
]);
|
|
151
|
+
}
|
|
152
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, exchange);
|
|
153
|
+
}
|
|
154
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
155
|
+
const { exchange } = data;
|
|
156
|
+
const payload = this.abiCoder.encodeParameter({
|
|
157
|
+
ParentStruct: {
|
|
158
|
+
toStaked: 'bool',
|
|
159
|
+
},
|
|
160
|
+
}, {
|
|
161
|
+
toStaked: this.isDai(srcToken),
|
|
162
|
+
});
|
|
163
|
+
return {
|
|
164
|
+
targetExchange: exchange,
|
|
165
|
+
payload,
|
|
166
|
+
networkFee: '0',
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.SDai = SDai;
|
|
171
|
+
SDai.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.SDaiConfig);
|
|
172
|
+
//# sourceMappingURL=sdai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdai.js","sourceRoot":"","sources":["../../../src/dex/sdai/sdai.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAoD;AAEpD,mCAA8D;AAC9D,+CAAoD;AACpD,uCAAoD;AACpD,qCAAgD;AAYhD,2EAA6D;AAC7D,4EAAkD;AAClD,6FAA+D;AAC/D,4CAA6C;AAC7C,2CAA4C;AAC5C,6DAAiD;AACjD,2CAA0E;AAE1E,MAAa,IAAK,SAAQ,gCAAc;IAUtC,YACY,OAAgB,EAC1B,MAAc,EACJ,SAAqB,EAEtB,aAAqB,mBAAU,CA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Ae,CAAC,CACxD,CAAC;SACH;aAAM;YACL,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAC9C,MAAM,CAAC,CAAC,CAAC,qBAAa,CAAC,MAAM,CAAC,CAAC,CAAC,qBAAa,CAAC,QAAQ,EACtD;gBACE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU;gBAC/B,IAAI,CAAC,eAAe;gBACpB,IAAI,CAAC,eAAe;aACrB,CACF,CAAC;SACH;QAED,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAc,EACd,IAAc;QAEd,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAE1B,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAC3C;YACE,YAAY,EAAE;gBACZ,QAAQ,EAAE,MAAM;aACjB;SACF,EACD;YACE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;SAC/B,CACF,CAAC;QAEF,OAAO;YACL,cAAc,EAAE,QAAQ;YACxB,OAAO;YACP,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;;AA9MH,oBA+MC;AA3Me,uBAAkB,GAC9B,IAAA,6BAAqB,EAAC,mBAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Address } from '../../types';
|
|
2
|
+
export declare type SDaiData = {
|
|
3
|
+
exchange: Address;
|
|
4
|
+
};
|
|
5
|
+
export declare type SDaiParams = {
|
|
6
|
+
sdaiAddress: Address;
|
|
7
|
+
daiAddress: Address;
|
|
8
|
+
potAddress: Address;
|
|
9
|
+
};
|
|
10
|
+
export declare enum SDaiFunctions {
|
|
11
|
+
deposit = "deposit",
|
|
12
|
+
redeem = "redeem",
|
|
13
|
+
withdraw = "withdraw",
|
|
14
|
+
mint = "mint"
|
|
15
|
+
}
|
|
16
|
+
export declare type SDaiPoolState = {
|
|
17
|
+
rho: string;
|
|
18
|
+
chi: string;
|
|
19
|
+
dsr: string;
|
|
20
|
+
live: boolean;
|
|
21
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SDaiFunctions = void 0;
|
|
4
|
+
var SDaiFunctions;
|
|
5
|
+
(function (SDaiFunctions) {
|
|
6
|
+
SDaiFunctions["deposit"] = "deposit";
|
|
7
|
+
SDaiFunctions["redeem"] = "redeem";
|
|
8
|
+
SDaiFunctions["withdraw"] = "withdraw";
|
|
9
|
+
SDaiFunctions["mint"] = "mint";
|
|
10
|
+
})(SDaiFunctions = exports.SDaiFunctions || (exports.SDaiFunctions = {}));
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/sdai/types.ts"],"names":[],"mappings":";;;AAUA,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,kCAAiB,CAAA;IACjB,sCAAqB,CAAA;IACrB,8BAAa,CAAA;AACf,CAAC,EALW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAKxB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Contract } from 'web3-eth-contract';
|
|
2
|
+
import { SDaiPoolState } from './types';
|
|
3
|
+
import { Interface } from '@ethersproject/abi';
|
|
4
|
+
export declare function getOnChainState(multiContract: Contract, potAddress: string, potInterface: Interface, blockNumber: number | 'latest'): Promise<SDaiPoolState>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOnChainState = void 0;
|
|
4
|
+
const abi_1 = require("@ethersproject/abi");
|
|
5
|
+
const coder = new abi_1.AbiCoder();
|
|
6
|
+
// - `dsr`: the Dai Savings Rate
|
|
7
|
+
// - `chi`: the Rate Accumulator
|
|
8
|
+
// - `rho`: time of last drip
|
|
9
|
+
async function getOnChainState(multiContract, potAddress, potInterface, blockNumber) {
|
|
10
|
+
const data = await multiContract.methods
|
|
11
|
+
.aggregate([
|
|
12
|
+
{
|
|
13
|
+
target: potAddress,
|
|
14
|
+
callData: potInterface.encodeFunctionData('dsr', []),
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
target: potAddress,
|
|
18
|
+
callData: potInterface.encodeFunctionData('chi', []),
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
target: potAddress,
|
|
22
|
+
callData: potInterface.encodeFunctionData('rho', []),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
target: potAddress,
|
|
26
|
+
callData: potInterface.encodeFunctionData('live', []),
|
|
27
|
+
},
|
|
28
|
+
])
|
|
29
|
+
.call({}, blockNumber);
|
|
30
|
+
const [dsr, chi, rho, live] = data.returnData.map(item => coder.decode(['uint256'], item)[0].toString());
|
|
31
|
+
return {
|
|
32
|
+
live: !!live,
|
|
33
|
+
dsr,
|
|
34
|
+
chi,
|
|
35
|
+
rho,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.getOnChainState = getOnChainState;
|
|
39
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/sdai/utils.ts"],"names":[],"mappings":";;;AAEA,4CAAyD;AAGzD,MAAM,KAAK,GAAG,IAAI,cAAQ,EAAE,CAAC;AAE7B,gCAAgC;AAChC,gCAAgC;AAChC,6BAA6B;AACtB,KAAK,UAAU,eAAe,CACnC,aAAuB,EACvB,UAAkB,EAClB,YAAuB,EACvB,WAA8B;IAE9B,MAAM,IAAI,GAA0B,MAAM,aAAa,CAAC,OAAO;SAC5D,SAAS,CAAC;QACT;YACE,MAAM,EAAE,UAAU;YAClB,QAAQ,EAAE,YAAY,CAAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC;SACrD;QACD;YACE,MAAM,EAAE,UAAU;YAClB,QAAQ,EAAE,YAAY,CAAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC;SACrD;QACD;YACE,MAAM,EAAE,UAAU;YAClB,QAAQ,EAAE,YAAY,CAAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC;SACrD;QACD;YACE,MAAM,EAAE,UAAU;YAClB,QAAQ,EAAE,YAAY,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE,CAAC;SACtD;KACF,CAAC;SACD,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;IAEzB,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CACvD,KAAK,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAC9C,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,GAAG;QACH,GAAG;QACH,GAAG;KACJ,CAAC;AACJ,CAAC;AArCD,0CAqCC"}
|
|
@@ -22,6 +22,6 @@ export declare class SimpleExchange {
|
|
|
22
22
|
readonly cacheStateKey: string;
|
|
23
23
|
constructor(dexHelper: IDexHelper, dexKey: string);
|
|
24
24
|
protected getApproveSimpleParam(token: Address, target: Address, amount: string): Promise<SimpleExchangeParam>;
|
|
25
|
-
protected buildSimpleParamWithoutWETHConversion(src: Address, srcAmount: NumberAsString, dest: Address, destAmount: NumberAsString, swapCallData: string, swapCallee: Address, spender?: Address, networkFee?: NumberAsString, preCalls?: Omit<SimpleExchangeParam, 'networkFee'
|
|
25
|
+
protected buildSimpleParamWithoutWETHConversion(src: Address, srcAmount: NumberAsString, dest: Address, destAmount: NumberAsString, swapCallData: string, swapCallee: Address, spender?: Address, networkFee?: NumberAsString, preCalls?: Omit<SimpleExchangeParam, 'networkFee'>, skipApproval?: boolean): Promise<SimpleExchangeParam>;
|
|
26
26
|
protected isWETH(tokenAddress: string): boolean;
|
|
27
27
|
}
|
|
@@ -60,8 +60,10 @@ class SimpleExchange {
|
|
|
60
60
|
networkFee: '0',
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
async buildSimpleParamWithoutWETHConversion(src, srcAmount, dest, destAmount, swapCallData, swapCallee, spender, networkFee = '0', preCalls) {
|
|
64
|
-
const approveParam =
|
|
63
|
+
async buildSimpleParamWithoutWETHConversion(src, srcAmount, dest, destAmount, swapCallData, swapCallee, spender, networkFee = '0', preCalls, skipApproval) {
|
|
64
|
+
const approveParam = skipApproval
|
|
65
|
+
? { callees: [], calldata: [], values: [], networkFee: '0' }
|
|
66
|
+
: await this.getApproveSimpleParam(src, spender || swapCallee, srcAmount);
|
|
65
67
|
const swapValue = (BigInt(networkFee) + ((0, utils_1.isETHAddress)(src) ? BigInt(srcAmount) : 0n)).toString();
|
|
66
68
|
return {
|
|
67
69
|
callees: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple-exchange.js","sourceRoot":"","sources":["../../src/dex/simple-exchange.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+C;AAC/C,gEAAiD;AAQjD,4CAA2D;AAC3D,qGAAqE;AACrE,mEAAyC;AACzC,yEAA+C;AAC/C,oCAAwC;AACxC,4CAAwC;AAKxC,2EAAwD;AAGxD;;;;;;;GAOG;AACU,QAAA,uBAAuB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACjD,MAAM,qCAAqC,GAAG,GAAG,EAAE,CACxD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC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AAY;aACb;YACD,MAAM,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,CAAC,EAAE,GAAG,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC;YACxE,UAAU;SACX,CAAC;IACJ,CAAC;IAES,MAAM,CAAC,YAAoB;QACnC,MAAM,IAAI,GACR,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,WAAW,EAAE,CAAC;QAErE,OAAO,YAAY,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC;IAC7C,CAAC;CACF;AA9GD,wCA8GC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Adapters = exports.SmardexConfig = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const GATEWAY_SUBGRAPH = 'https://subgraph.smardex.io';
|
|
6
|
+
const MAINNET_INIT_HASH = '0xc762a0f9885cc92b9fd8eef224b75997682b634460611bc0f2138986e20b653f';
|
|
7
|
+
const LAYER2_INIT_HASH = '0x33bee911475f015247aeb1eebe149d1c6d2669be54126c29d85df6b0abb4c4e9';
|
|
8
|
+
exports.SmardexConfig = {
|
|
9
|
+
Smardex: {
|
|
10
|
+
[constants_1.Network.MAINNET]: {
|
|
11
|
+
factoryAddress: '0xB878DC600550367e14220d4916Ff678fB284214F',
|
|
12
|
+
router: '0xC33984ABcAe20f47a754eF78f6526FeF266c0C6F',
|
|
13
|
+
initCode: MAINNET_INIT_HASH,
|
|
14
|
+
subgraphURL: `${GATEWAY_SUBGRAPH}/ethereum`,
|
|
15
|
+
},
|
|
16
|
+
[constants_1.Network.ARBITRUM]: {
|
|
17
|
+
factoryAddress: '0x41A00e3FbE7F479A99bA6822704d9c5dEB611F22',
|
|
18
|
+
router: '0xDA3970a20cdc2B1269fc96C4E8D300E0fdDB7b3D',
|
|
19
|
+
initCode: LAYER2_INIT_HASH,
|
|
20
|
+
subgraphURL: `${GATEWAY_SUBGRAPH}/arbitrum`,
|
|
21
|
+
},
|
|
22
|
+
[constants_1.Network.BSC]: {
|
|
23
|
+
factoryAddress: '0xA8EF6FEa013034E62E2C4A9Ec1CDb059fE23Af33',
|
|
24
|
+
router: '0xaB3699B71e89a53c529eC037C3389B5A2Caf545A',
|
|
25
|
+
initCode: LAYER2_INIT_HASH,
|
|
26
|
+
subgraphURL: `${GATEWAY_SUBGRAPH}/bsc`,
|
|
27
|
+
},
|
|
28
|
+
[constants_1.Network.POLYGON]: {
|
|
29
|
+
factoryAddress: '0x9A1e1681f6D59Ca051776410465AfAda6384398f',
|
|
30
|
+
router: '0xedD758D17175Dc9131992ebd02F55Cc4ebeb7B7c',
|
|
31
|
+
initCode: LAYER2_INIT_HASH,
|
|
32
|
+
subgraphURL: `${GATEWAY_SUBGRAPH}/polygon`,
|
|
33
|
+
},
|
|
34
|
+
[constants_1.Network.BASE]: {
|
|
35
|
+
factoryAddress: '0xdd4536dD9636564D891c919416880a3e250f975A',
|
|
36
|
+
router: '0xF03D133627364E5eDDaB8134faB3A030cf7b3020',
|
|
37
|
+
initCode: LAYER2_INIT_HASH,
|
|
38
|
+
subgraphURL: `${GATEWAY_SUBGRAPH}/base`,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
exports.Adapters = {
|
|
43
|
+
[constants_1.Network.MAINNET]: {
|
|
44
|
+
[constants_1.SwapSide.SELL]: [{ name: 'Adapter04', index: 6 }],
|
|
45
|
+
[constants_1.SwapSide.BUY]: [{ name: 'BuyAdapter02', index: 2 }],
|
|
46
|
+
},
|
|
47
|
+
[constants_1.Network.ARBITRUM]: {
|
|
48
|
+
[constants_1.SwapSide.SELL]: [{ name: 'ArbitrumAdapter02', index: 9 }],
|
|
49
|
+
[constants_1.SwapSide.BUY]: [{ name: 'ArbitrumBuyAdapter', index: 9 }],
|
|
50
|
+
},
|
|
51
|
+
[constants_1.Network.BSC]: {
|
|
52
|
+
[constants_1.SwapSide.SELL]: [{ name: 'BscAdapter02', index: 8 }],
|
|
53
|
+
[constants_1.SwapSide.BUY]: [{ name: 'BscBuyAdapter', index: 7 }],
|
|
54
|
+
},
|
|
55
|
+
[constants_1.Network.POLYGON]: {
|
|
56
|
+
[constants_1.SwapSide.SELL]: [{ name: 'PolygonAdapter02', index: 9 }],
|
|
57
|
+
[constants_1.SwapSide.BUY]: [{ name: 'PolygonBuyAdapter', index: 8 }],
|
|
58
|
+
},
|
|
59
|
+
[constants_1.Network.BASE]: {
|
|
60
|
+
[constants_1.SwapSide.SELL]: [{ name: 'BaseAdapter01', index: 8 }],
|
|
61
|
+
[constants_1.SwapSide.BUY]: [{ name: 'BaseBuyAdapter', index: 5 }],
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/smardex/config.ts"],"names":[],"mappings":";;;AAEA,+CAAoD;AAEpD,MAAM,gBAAgB,GAAG,6BAA6B,CAAC;AACvD,MAAM,iBAAiB,GACrB,oEAAoE,CAAC;AACvE,MAAM,gBAAgB,GACpB,oEAAoE,CAAC;AAE1D,QAAA,aAAa,GAA4B;IACpD,OAAO,EAAE;QACP,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,cAAc,EAAE,4CAA4C;YAC5D,MAAM,EAAE,4CAA4C;YACpD,QAAQ,EAAE,iBAAiB;YAC3B,WAAW,EAAE,GAAG,gBAAgB,WAAW;SAC5C;QACD,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE;YAClB,cAAc,EAAE,4CAA4C;YAC5D,MAAM,EAAE,4CAA4C;YACpD,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,GAAG,gBAAgB,WAAW;SAC5C;QACD,CAAC,mBAAO,CAAC,GAAG,CAAC,EAAE;YACb,cAAc,EAAE,4CAA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AAC,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;KACtD;IACD,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;QACjB,CAAC,oBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QACzD,CAAC,oBAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;KAC1D;IACD,CAAC,mBAAO,CAAC,IAAI,CAAC,EAAE;QACd,CAAC,oBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QACtD,CAAC,oBAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;KACvD;CACF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SmardexFees } from './types';
|
|
2
|
+
export declare enum TOPICS {
|
|
3
|
+
SYNC_EVENT = "0x2a368c7f33bb86e2d999940a3989d849031aff29b750f67947e6b8e8c3d2ffd6",
|
|
4
|
+
SWAP_EVENT = "0xa4228e1eb11eb9b31069d9ed20e7af9a010ca1a02d4855cee54e08e188fcc32c",
|
|
5
|
+
FEES_EVENT = "0x64f84976d9c917a44796104a59950fdbd9b3c16a5dd348b546d738301f6bd068"
|
|
6
|
+
}
|
|
7
|
+
export declare enum SmardexRouterFunctions {
|
|
8
|
+
sellExactEth = "swapExactETHForTokens",
|
|
9
|
+
sellExactToken = "swapExactTokensForETH",
|
|
10
|
+
swapExactIn = "swapExactTokensForTokens",
|
|
11
|
+
buyExactEth = "swapTokensForExactETH",
|
|
12
|
+
buyExactToken = "swapETHForExactTokens",
|
|
13
|
+
swapExactOut = "swapTokensForExactTokens"
|
|
14
|
+
}
|
|
15
|
+
export declare const directSmardexFunctionName: SmardexRouterFunctions[];
|
|
16
|
+
export declare const SUBGRAPH_TIMEOUT: number;
|
|
17
|
+
export declare const DefaultSmardexPoolGasCost: number;
|
|
18
|
+
export declare const FEES_LAYER_ONE: SmardexFees;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FEES_LAYER_ONE = exports.DefaultSmardexPoolGasCost = exports.SUBGRAPH_TIMEOUT = exports.directSmardexFunctionName = exports.SmardexRouterFunctions = exports.TOPICS = void 0;
|
|
4
|
+
var TOPICS;
|
|
5
|
+
(function (TOPICS) {
|
|
6
|
+
TOPICS["SYNC_EVENT"] = "0x2a368c7f33bb86e2d999940a3989d849031aff29b750f67947e6b8e8c3d2ffd6";
|
|
7
|
+
TOPICS["SWAP_EVENT"] = "0xa4228e1eb11eb9b31069d9ed20e7af9a010ca1a02d4855cee54e08e188fcc32c";
|
|
8
|
+
TOPICS["FEES_EVENT"] = "0x64f84976d9c917a44796104a59950fdbd9b3c16a5dd348b546d738301f6bd068";
|
|
9
|
+
})(TOPICS = exports.TOPICS || (exports.TOPICS = {}));
|
|
10
|
+
var SmardexRouterFunctions;
|
|
11
|
+
(function (SmardexRouterFunctions) {
|
|
12
|
+
SmardexRouterFunctions["sellExactEth"] = "swapExactETHForTokens";
|
|
13
|
+
SmardexRouterFunctions["sellExactToken"] = "swapExactTokensForETH";
|
|
14
|
+
SmardexRouterFunctions["swapExactIn"] = "swapExactTokensForTokens";
|
|
15
|
+
SmardexRouterFunctions["buyExactEth"] = "swapTokensForExactETH";
|
|
16
|
+
SmardexRouterFunctions["buyExactToken"] = "swapETHForExactTokens";
|
|
17
|
+
SmardexRouterFunctions["swapExactOut"] = "swapTokensForExactTokens";
|
|
18
|
+
})(SmardexRouterFunctions = exports.SmardexRouterFunctions || (exports.SmardexRouterFunctions = {}));
|
|
19
|
+
exports.directSmardexFunctionName = [
|
|
20
|
+
SmardexRouterFunctions.sellExactEth,
|
|
21
|
+
SmardexRouterFunctions.sellExactToken,
|
|
22
|
+
SmardexRouterFunctions.swapExactIn,
|
|
23
|
+
SmardexRouterFunctions.buyExactEth,
|
|
24
|
+
SmardexRouterFunctions.buyExactToken,
|
|
25
|
+
SmardexRouterFunctions.swapExactOut,
|
|
26
|
+
];
|
|
27
|
+
exports.SUBGRAPH_TIMEOUT = 20 * 1000;
|
|
28
|
+
exports.DefaultSmardexPoolGasCost = 130 * 1000;
|
|
29
|
+
exports.FEES_LAYER_ONE = {
|
|
30
|
+
feesLP: 500n,
|
|
31
|
+
feesPool: 200n,
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dex/smardex/constants.ts"],"names":[],"mappings":";;;AAGA,IAAY,MAIX;AAJD,WAAY,MAAM;IAChB,2FAAiF,CAAA;IACjF,2FAAiF,CAAA;IACjF,2FAAiF,CAAA;AACnF,CAAC,EAJW,MAAM,GAAN,cAAM,KAAN,cAAM,QAIjB;AAED,IAAY,sBAOX;AAPD,WAAY,sBAAsB;IAChC,gEAAsC,CAAA;IACtC,kEAAwC,CAAA;IACxC,kEAAwC,CAAA;IACxC,+DAAqC,CAAA;IACrC,iEAAuC,CAAA;IACvC,mEAAyC,CAAA;AAC3C,CAAC,EAPW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAOjC;AAEY,QAAA,yBAAyB,GAAG;IACvC,sBAAsB,CAAC,YAAY;IACnC,sBAAsB,CAAC,cAAc;IACrC,sBAAsB,CAAC,WAAW;IAClC,sBAAsB,CAAC,WAAW;IAClC,sBAAsB,CAAC,aAAa;IACpC,sBAAsB,CAAC,YAAY;CACpC,CAAC;AAEW,QAAA,gBAAgB,GAAG,EAAE,GAAG,IAAI,CAAC;AAE7B,QAAA,yBAAyB,GAAG,GAAG,GAAG,IAAI,CAAC;AAEvC,QAAA,cAAc,GAAgB;IACzC,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,IAAI;CACf,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TradeType = exports.LATENCY_OFFSET_SECONDS = exports.FEES_BASE = void 0;
|
|
4
|
+
// Protocol's fees constants
|
|
5
|
+
exports.FEES_BASE = 1000000n;
|
|
6
|
+
// constant for function 'updatePriceAverage'
|
|
7
|
+
exports.LATENCY_OFFSET_SECONDS = 20;
|
|
8
|
+
var TradeType;
|
|
9
|
+
(function (TradeType) {
|
|
10
|
+
TradeType[TradeType["EXACT_INPUT"] = 0] = "EXACT_INPUT";
|
|
11
|
+
TradeType[TradeType["EXACT_OUTPUT"] = 1] = "EXACT_OUTPUT";
|
|
12
|
+
})(TradeType = exports.TradeType || (exports.TradeType = {}));
|
|
13
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/dex/smardex/sdk/constants.ts"],"names":[],"mappings":";;;AAAA,4BAA4B;AACf,QAAA,SAAS,GAAG,QAAQ,CAAC;AAElC,6CAA6C;AAChC,QAAA,sBAAsB,GAAG,EAAE,CAAC;AAEzC,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,uDAAW,CAAA;IACX,yDAAY,CAAA;AACd,CAAC,EAHW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAGpB"}
|