@paraswap/dex-lib 3.8.2 → 3.8.3-integral-dex
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/config.js +1 -1
- 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/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.d.ts +18 -0
- package/build/dex/compound.js +46 -0
- package/build/dex/compound.js.map +1 -0
- package/build/dex/curve-v1-factory/config.js +10 -47
- package/build/dex/curve-v1-factory/config.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +2 -2
- package/build/dex/curve-v1-factory/curve-v1-factory.js +36 -96
- package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/constants.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dx.js +1 -13
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dx.js.map +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.d.ts +2 -2
- package/build/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.js +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.js.map +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js.map +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/pool-polling-base.d.ts +3 -4
- package/build/dex/curve-v1-factory/state-polling-pools/pool-polling-base.js +9 -24
- package/build/dex/curve-v1-factory/state-polling-pools/pool-polling-base.js.map +1 -1
- package/build/dex/curve-v1-factory/types.d.ts +4 -20
- package/build/dex/curve-v1-factory/types.js +3 -11
- package/build/dex/curve-v1-factory/types.js.map +1 -1
- package/build/dex/curve-v1-stable-ng/config.js +0 -18
- package/build/dex/curve-v1-stable-ng/config.js.map +1 -1
- 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/index.js +21 -3
- package/build/dex/index.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 +40 -0
- package/build/dex/integral/context.js +158 -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 +24 -0
- package/build/dex/integral/integral-token.js +56 -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 +377 -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-e2e.d.ts +9 -0
- package/build/dex/integral/utils-e2e.js +131 -0
- package/build/dex/integral/utils-e2e.js.map +1 -0
- package/build/dex/integral/utils.d.ts +17 -0
- package/build/dex/integral/utils.js +94 -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/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/paraswap-limit-orders/paraswap-limit-orders.js +0 -3
- package/build/dex/paraswap-limit-orders/paraswap-limit-orders.js.map +1 -1
- 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/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/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/dex/uniswap-v3/contract-math/Oracle.js +4 -4
- package/build/dex/uniswap-v3/contract-math/Oracle.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/generic-swap-transaction-builder.js +3 -1
- package/build/generic-swap-transaction-builder.js.map +1 -1
- package/build/router/simpleswap.js +3 -1
- package/build/router/simpleswap.js.map +1 -1
- package/package.json +2 -2
- package/src/abi/BProtocol.json +1155 -0
- package/src/abi/Jarvis.json +1172 -0
- package/src/abi/MStableAsset.json +1545 -0
- package/src/abi/OneInchLp.json +1304 -0
- package/src/abi/Onebit.json +736 -0
- package/src/abi/Shell.json +1294 -0
- package/src/abi/TraderJoeV2Router.json +50 -0
- package/src/abi/integral/factory.json +333 -0
- package/src/abi/integral/oracle.json +501 -0
- package/src/abi/integral/pool.json +1041 -0
- package/src/abi/integral/relayer.json +1536 -0
- package/src/abi/zrx.v2.json +1967 -0
- package/src/abi/zrx.v3.json +3454 -0
- package/src/abi/zrx.v4.json +2193 -0
- package/src/config.ts +1 -1
- package/src/dex/OneInchLp.ts +84 -0
- package/src/dex/bProtocol/bProtocol-e2e.test.ts +93 -0
- package/src/dex/bProtocol/bProtocol.ts +108 -0
- package/src/dex/bProtocol/types.ts +13 -0
- package/src/dex/curve-v1-factory/config.ts +10 -47
- package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +16 -92
- package/src/dex/curve-v1-factory/curve-v1-factory-integration.test.ts +5 -125
- package/src/dex/curve-v1-factory/curve-v1-factory.ts +45 -137
- package/src/dex/curve-v1-factory/price-handlers/functions/constants.ts +2 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_dx.ts +1 -24
- package/src/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.ts +2 -3
- package/src/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.ts +0 -1
- package/src/dex/curve-v1-factory/state-polling-pools/pool-polling-base.ts +10 -31
- package/src/dex/curve-v1-factory/types.ts +6 -22
- package/src/dex/curve-v1-stable-ng/config.ts +0 -18
- package/src/dex/curve-v1-stable-ng/curve-v1-stable-ng-e2e.test.ts +0 -17
- package/src/dex/index.ts +20 -3
- package/src/dex/integral/config.ts +20 -0
- package/src/dex/integral/context.ts +287 -0
- package/src/dex/integral/integral-e2e.test.ts +86 -0
- package/src/dex/integral/integral-events.test.ts +412 -0
- package/src/dex/integral/integral-factory.ts +146 -0
- package/src/dex/integral/integral-integration.test.ts +221 -0
- package/src/dex/integral/integral-pool.ts +198 -0
- package/src/dex/integral/integral-pricing.ts +190 -0
- package/src/dex/integral/integral-relayer.ts +285 -0
- package/src/dex/integral/integral-token.ts +95 -0
- package/src/dex/integral/integral.ts +523 -0
- package/src/dex/integral/test-artifacts/configs.json +1 -0
- package/src/dex/integral/test-artifacts/logs.json +1 -0
- package/src/dex/integral/test-artifacts/states.json +1 -0
- package/src/dex/integral/types.ts +88 -0
- package/src/dex/integral/utils-e2e.ts +194 -0
- package/src/dex/integral/utils.ts +146 -0
- package/src/dex/jarvis.ts +262 -0
- package/src/dex/mStable.ts +147 -0
- package/src/dex/onebit/onebit.ts +113 -0
- package/src/dex/onebit/types.ts +17 -0
- package/src/dex/paraswap-limit-orders/paraswap-limit-orders-e2e.test.ts +68 -152
- package/src/dex/paraswap-limit-orders/paraswap-limit-orders.ts +0 -3
- package/src/dex/shell.ts +84 -0
- package/src/dex/trader-joe-v2.ts +148 -0
- package/src/dex/uniswap-v3/contract-math/Oracle.ts +5 -4
- package/src/dex/zerox/config.ts +31 -0
- package/src/dex/zerox/index.ts +328 -0
- package/src/dex/zerox/order.ts +62 -0
- package/src/dex/zerox/types.ts +82 -0
- package/src/dex/zerox/zerox-e2e.test.ts +110 -0
- package/src/generic-swap-transaction-builder.ts +3 -1
- package/src/router/simpleswap.ts +3 -1
- package/tests/constants-e2e.ts +2 -2
- package/tests/utils-e2e.ts +0 -2
- package/.idea/aws.xml +0 -17
- package/.idea/codeStyles/Project.xml +0 -19
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/paraswap-dex-lib.iml +0 -9
- package/.idea/prettier.xml +0 -7
- package/.idea/vcs.xml +0 -6
- package/src/abi/curve-v1-factory/CurveV1Router.abi.json +0 -331
- package/src/dex/curve-v1-factory/optimizer.ts +0 -61
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPoolBackReferencedFrom = exports.getPoolIdentifier = exports.isInverted = exports.getTickCumulatives = exports.getAveragePrice = exports.getSpotPrice = exports.getPrice = exports.getDecimalsConverter = exports.sortTokens = exports.uint32ToNumber = exports.ceil_div = void 0;
|
|
4
|
+
const decoders_1 = require("../../lib/decoders");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const FullMath_1 = require("../uniswap-v3/contract-math/FullMath");
|
|
7
|
+
const Oracle_1 = require("../uniswap-v3/contract-math/Oracle");
|
|
8
|
+
const TickMath_1 = require("../uniswap-v3/contract-math/TickMath");
|
|
9
|
+
function ceil_div(a, b) {
|
|
10
|
+
const c = a / b;
|
|
11
|
+
if (a != b * c) {
|
|
12
|
+
return c + 1n;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return c;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ceil_div = ceil_div;
|
|
19
|
+
const uint32ToNumber = (result) => {
|
|
20
|
+
return (0, decoders_1.generalDecoder)(result, ['uint32'], 0, value => parseInt(value[0].toString(), 10));
|
|
21
|
+
};
|
|
22
|
+
exports.uint32ToNumber = uint32ToNumber;
|
|
23
|
+
function sortTokens(srcAddress, destAddress) {
|
|
24
|
+
return [srcAddress, destAddress].sort((a, b) => (a < b ? -1 : 1));
|
|
25
|
+
}
|
|
26
|
+
exports.sortTokens = sortTokens;
|
|
27
|
+
function getDecimalsConverter(decimals0, decimals1, inverted) {
|
|
28
|
+
return (10n **
|
|
29
|
+
(18n + BigInt(inverted ? decimals1 - decimals0 : decimals0 - decimals1)));
|
|
30
|
+
}
|
|
31
|
+
exports.getDecimalsConverter = getDecimalsConverter;
|
|
32
|
+
function getPrice(states, inverted) {
|
|
33
|
+
const { base, pricing, relayer } = states;
|
|
34
|
+
const decimalsConverter = getDecimalsConverter(base.decimals0, base.decimals1, false);
|
|
35
|
+
const spotPrice = getSpotPrice(pricing, decimalsConverter);
|
|
36
|
+
const averagePrice = getAveragePrice(relayer, pricing, decimalsConverter);
|
|
37
|
+
if (inverted) {
|
|
38
|
+
return 10n ** 36n / (spotPrice > averagePrice ? spotPrice : averagePrice);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return spotPrice < averagePrice ? spotPrice : averagePrice;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.getPrice = getPrice;
|
|
45
|
+
function getSpotPrice(pricing, decimalsConverter) {
|
|
46
|
+
const sqrtPriceX96 = pricing.slot0.sqrtPriceX96;
|
|
47
|
+
const priceX128 = FullMath_1.FullMath.mulDiv(sqrtPriceX96, sqrtPriceX96, 2n ** 64n);
|
|
48
|
+
return FullMath_1.FullMath.mulDiv(priceX128, decimalsConverter, 2n ** 128n);
|
|
49
|
+
}
|
|
50
|
+
exports.getSpotPrice = getSpotPrice;
|
|
51
|
+
function getAveragePrice(relayer, pricing, decimalsConverter) {
|
|
52
|
+
(0, utils_1._require)(relayer.twapInterval > 0, 'Twap Interval not set');
|
|
53
|
+
const secondsAgo = BigInt(relayer.twapInterval);
|
|
54
|
+
const secondsAgos = [secondsAgo, 0n];
|
|
55
|
+
const tickCumulatives = getTickCumulatives(pricing, secondsAgos);
|
|
56
|
+
const delta = tickCumulatives[1] - tickCumulatives[0];
|
|
57
|
+
let arithmeticMeanTick = delta / secondsAgo;
|
|
58
|
+
if (delta < 0 && delta % secondsAgo != 0n) {
|
|
59
|
+
--arithmeticMeanTick;
|
|
60
|
+
}
|
|
61
|
+
const sqrtRatioX96 = TickMath_1.TickMath.getSqrtRatioAtTick(arithmeticMeanTick);
|
|
62
|
+
const ratioX128 = FullMath_1.FullMath.mulDiv(sqrtRatioX96, sqrtRatioX96, 2n ** 64n);
|
|
63
|
+
return FullMath_1.FullMath.mulDiv(ratioX128, decimalsConverter, 2n ** 128n);
|
|
64
|
+
}
|
|
65
|
+
exports.getAveragePrice = getAveragePrice;
|
|
66
|
+
function getTickCumulatives(poolState, secondsAgos) {
|
|
67
|
+
const { tickCumulatives } = secondsAgos.reduce((memo, secondsAgo, i) => {
|
|
68
|
+
[memo.tickCumulatives[i], memo.secondsPerLiquidityCumulativeX128s[i]] =
|
|
69
|
+
Oracle_1.Oracle.observeSingle(poolState, BigInt.asUintN(32, poolState.blockTimestamp), secondsAgo, poolState.slot0.tick, poolState.slot0.observationIndex, poolState.liquidity, poolState.slot0.observationCardinality);
|
|
70
|
+
return memo;
|
|
71
|
+
}, {
|
|
72
|
+
tickCumulatives: Array(secondsAgos.length),
|
|
73
|
+
secondsPerLiquidityCumulativeX128s: Array(secondsAgos.length),
|
|
74
|
+
});
|
|
75
|
+
return tickCumulatives;
|
|
76
|
+
}
|
|
77
|
+
exports.getTickCumulatives = getTickCumulatives;
|
|
78
|
+
function isInverted(tokenIn, tokenOut) {
|
|
79
|
+
const [, token1] = tokenIn.toLowerCase() < tokenOut.toLowerCase()
|
|
80
|
+
? [tokenIn, tokenOut]
|
|
81
|
+
: [tokenOut, tokenIn];
|
|
82
|
+
return tokenIn === token1;
|
|
83
|
+
}
|
|
84
|
+
exports.isInverted = isInverted;
|
|
85
|
+
function getPoolIdentifier(dexKey, srcAddress, destAddress) {
|
|
86
|
+
const tokenAddresses = sortTokens(srcAddress.toLowerCase(), destAddress.toLowerCase()).join('_');
|
|
87
|
+
return `${dexKey}_${tokenAddresses}`;
|
|
88
|
+
}
|
|
89
|
+
exports.getPoolIdentifier = getPoolIdentifier;
|
|
90
|
+
function getPoolBackReferencedFrom(context, poolAddress) {
|
|
91
|
+
return Object.entries(context.pools).find(([, pool]) => pool.base?.poolAddress === poolAddress);
|
|
92
|
+
}
|
|
93
|
+
exports.getPoolBackReferencedFrom = getPoolBackReferencedFrom;
|
|
94
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/integral/utils.ts"],"names":[],"mappings":";;;AAEA,iDAAoD;AAGpD,uCAAuC;AACvC,mEAAgE;AAChE,+DA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,QAAiB;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC,GACd,OAAO,CAAC,WAAW,EAAE,GAAG,QAAQ,CAAC,WAAW,EAAE;QAC5C,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC;QACrB,CAAC,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC1B,OAAO,OAAO,KAAK,MAAM,CAAC;AAC5B,CAAC;AAND,gCAMC;AAED,SAAgB,iBAAiB,CAC/B,MAAc,EACd,UAAmB,EACnB,WAAoB;IAEpB,MAAM,cAAc,GAAG,UAAU,CAC/B,UAAU,CAAC,WAAW,EAAE,EACxB,WAAW,CAAC,WAAW,EAAE,CAC1B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACZ,OAAO,GAAG,MAAM,IAAI,cAAc,EAAE,CAAC;AACvC,CAAC;AAVD,8CAUC;AAED,SAAgB,yBAAyB,CACvC,OAAwB,EACxB,WAAoB;IAEpB,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CACvC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,KAAK,WAAW,CACrD,CAAC;AACJ,CAAC;AAPD,8DAOC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { NumberAsString, SwapSide } from '@paraswap/core';
|
|
3
|
+
import { AdapterExchangeParam, Address, SimpleExchangeParam } from '../types';
|
|
4
|
+
import { IDexTxBuilder } from './idex';
|
|
5
|
+
import { IDexHelper } from '../dex-helper';
|
|
6
|
+
export declare const stETH: any;
|
|
7
|
+
export declare enum stETHFunctions {
|
|
8
|
+
submit = "submit"
|
|
9
|
+
}
|
|
10
|
+
export declare type LidoData = {};
|
|
11
|
+
export declare class Lido implements IDexTxBuilder<LidoData, any> {
|
|
12
|
+
static dexKeys: string[];
|
|
13
|
+
stETHInterface: Interface;
|
|
14
|
+
needWrapNative: boolean;
|
|
15
|
+
private network;
|
|
16
|
+
constructor(dexHelper: IDexHelper);
|
|
17
|
+
getAdapterParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, data: LidoData, side: SwapSide): AdapterExchangeParam;
|
|
18
|
+
getSimpleParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, data: LidoData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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.Lido = exports.stETHFunctions = exports.stETH = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const stETH_json_1 = __importDefault(require("../abi/stETH.json"));
|
|
9
|
+
const constants_1 = require("../constants");
|
|
10
|
+
exports.stETH = {
|
|
11
|
+
1: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84',
|
|
12
|
+
};
|
|
13
|
+
var stETHFunctions;
|
|
14
|
+
(function (stETHFunctions) {
|
|
15
|
+
stETHFunctions["submit"] = "submit";
|
|
16
|
+
})(stETHFunctions = exports.stETHFunctions || (exports.stETHFunctions = {}));
|
|
17
|
+
class Lido {
|
|
18
|
+
constructor(dexHelper) {
|
|
19
|
+
this.needWrapNative = false;
|
|
20
|
+
this.network = dexHelper.config.data.network;
|
|
21
|
+
this.stETHInterface = new abi_1.Interface(stETH_json_1.default);
|
|
22
|
+
}
|
|
23
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
24
|
+
return {
|
|
25
|
+
targetExchange: exports.stETH[this.network],
|
|
26
|
+
payload: '0x',
|
|
27
|
+
networkFee: '0',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
31
|
+
const swapData = this.stETHInterface.encodeFunctionData(stETHFunctions.submit, [constants_1.NULL_ADDRESS]);
|
|
32
|
+
return {
|
|
33
|
+
callees: [exports.stETH[this.network]],
|
|
34
|
+
calldata: [swapData],
|
|
35
|
+
values: [srcAmount],
|
|
36
|
+
networkFee: '0',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.Lido = Lido;
|
|
41
|
+
Lido.dexKeys = ['lido'];
|
|
42
|
+
//# sourceMappingURL=lido.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lido.js","sourceRoot":"","sources":["../../src/dex/lido.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAI7D,mEAAyC;AACzC,4CAA4C;AAI/B,QAAA,KAAK,GAAQ;IACxB,CAAC,EAAE,4CAA4C;CAChD,CAAC;AAEF,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,mCAAiB,CAAA;AACnB,CAAC,EAFW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAEzB;AAID,MAAa,IAAI;IAQf,YAAY,SAAqB;QAJjC,mBAAc,GAAG,KAAK,CAAC;QAKrB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QAE7C,IAAI,CAAC,cAAc,GAAG,IAAI,eAAS,CAAC,oBAA0B,CAAC,CAAC;IAClE,CAAC;IAED,eAAe,CACb,QAAiB,EACjB,SAAkB,EAClB,SAAyB,EACzB,UAA0B,EAC1B,IAAc,EACd,IAAc;QAEd,OAAO;YACL,cAAc,EAAE,aAAK,CAAC,IAAI,CAAC,OAAO,CAAC;YACnC,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAiB,EACjB,SAAkB,EAClB,SAAyB,EACzB,UAA0B,EAC1B,IAAc,EACd,IAAc;QAEd,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,kBAAkB,CACrD,cAAc,CAAC,MAAM,EACrB,CAAC,wBAAY,CAAC,CACf,CAAC;QAEF,OAAO;YACL,OAAO,EAAE,CAAC,aAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC9B,QAAQ,EAAE,CAAC,QAAQ,CAAC;YACpB,MAAM,EAAE,CAAC,SAAS,CAAC;YACnB,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;;AAhDH,oBAiDC;AAhDQ,YAAO,GAAG,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { SwapSide } from '../constants';
|
|
3
|
+
import { AdapterExchangeParam, Address, SimpleExchangeParam } from '../types';
|
|
4
|
+
import { IDexTxBuilder } from './idex';
|
|
5
|
+
import { SimpleExchange } from './simple-exchange';
|
|
6
|
+
import { IDexHelper } from '../dex-helper';
|
|
7
|
+
export declare type OnebitData = {
|
|
8
|
+
router: Address;
|
|
9
|
+
};
|
|
10
|
+
declare type OnebitParam = [
|
|
11
|
+
srcToken: string,
|
|
12
|
+
destToken: string,
|
|
13
|
+
srcAmount: string,
|
|
14
|
+
destAmountMin: string,
|
|
15
|
+
to: string
|
|
16
|
+
];
|
|
17
|
+
export declare class Onebit extends SimpleExchange implements IDexTxBuilder<OnebitData, OnebitParam> {
|
|
18
|
+
static dexKeys: string[];
|
|
19
|
+
exchangeRouterInterface: Interface;
|
|
20
|
+
needWrapNative: boolean;
|
|
21
|
+
constructor(dexHelper: IDexHelper);
|
|
22
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: OnebitData, side: SwapSide): AdapterExchangeParam;
|
|
23
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: OnebitData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
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.Onebit = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const simple_exchange_1 = require("./simple-exchange");
|
|
9
|
+
const Onebit_json_1 = __importDefault(require("../abi/Onebit.json"));
|
|
10
|
+
var OnebitFunctions;
|
|
11
|
+
(function (OnebitFunctions) {
|
|
12
|
+
OnebitFunctions["swapTokensWithTrust"] = "swapTokensWithTrust";
|
|
13
|
+
})(OnebitFunctions || (OnebitFunctions = {}));
|
|
14
|
+
class Onebit extends simple_exchange_1.SimpleExchange {
|
|
15
|
+
constructor(dexHelper) {
|
|
16
|
+
super(dexHelper, 'omm1');
|
|
17
|
+
this.needWrapNative = true;
|
|
18
|
+
this.exchangeRouterInterface = new abi_1.Interface(Onebit_json_1.default);
|
|
19
|
+
}
|
|
20
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
21
|
+
return {
|
|
22
|
+
targetExchange: data.router,
|
|
23
|
+
payload: '0x',
|
|
24
|
+
networkFee: '0',
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
28
|
+
const swapFunction = OnebitFunctions.swapTokensWithTrust;
|
|
29
|
+
const swapFunctionParams = [
|
|
30
|
+
srcToken,
|
|
31
|
+
destToken,
|
|
32
|
+
srcAmount,
|
|
33
|
+
destAmount,
|
|
34
|
+
this.augustusAddress,
|
|
35
|
+
];
|
|
36
|
+
const swapData = this.exchangeRouterInterface.encodeFunctionData(swapFunction, swapFunctionParams);
|
|
37
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, data.router);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.Onebit = Onebit;
|
|
41
|
+
Onebit.dexKeys = ['omm1'];
|
|
42
|
+
//# sourceMappingURL=onebit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onebit.js","sourceRoot":"","sources":["../../src/dex/onebit.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAK7D,uDAAmD;AACnD,qEAA2C;AAc3C,IAAK,eAEJ;AAFD,WAAK,eAAe;IAClB,8DAA2C,CAAA;AAC7C,CAAC,EAFI,eAAe,KAAf,eAAe,QAEnB;AAED,MAAa,MACX,SAAQ,gCAAc;IAOtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAH3B,mBAAc,GAAG,IAAI,CAAC;QAIpB,IAAI,CAAC,uBAAuB,GAAG,IAAI,eAAS,CAAC,qBAA2B,CAAC,CAAC;IAC5E,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAgB,EAChB,IAAc;QAEd,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,MAAM;YAC3B,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAgB,EAChB,IAAc;QAEd,MAAM,YAAY,GAAG,eAAe,CAAC,mBAAmB,CAAC;QACzD,MAAM,kBAAkB,GAAgB;YACtC,QAAQ;YACR,SAAS;YACT,SAAS;YACT,UAAU;YACV,IAAI,CAAC,eAAe;SACrB,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAC9D,YAAY,EACZ,kBAAkB,CACnB,CAAC;QAEF,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC;;AAzDH,wBA0DC;AAtDQ,cAAO,GAAG,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DexParams } from './types';
|
|
2
|
+
import { DexConfigMap, AdapterMappings } from '../../types';
|
|
3
|
+
export declare const OSWAP_GAS_COST = 80000;
|
|
4
|
+
export declare const OSwapConfig: DexConfigMap<DexParams>;
|
|
5
|
+
export declare const Adapters: Record<number, AdapterMappings>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Adapters = exports.OSwapConfig = exports.OSWAP_GAS_COST = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
exports.OSWAP_GAS_COST = 80000;
|
|
6
|
+
// Important:
|
|
7
|
+
// - All addresses should be lower case.
|
|
8
|
+
// - Only tokens with 18 decimals are supported.
|
|
9
|
+
exports.OSwapConfig = {
|
|
10
|
+
OSwap: {
|
|
11
|
+
[constants_1.Network.MAINNET]: {
|
|
12
|
+
pools: [
|
|
13
|
+
{
|
|
14
|
+
id: 'OSwap_0x85b78aca6deae198fbf201c82daf6ca21942acc6',
|
|
15
|
+
address: '0x85b78aca6deae198fbf201c82daf6ca21942acc6',
|
|
16
|
+
token0: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
17
|
+
token1: '0xae7ab96520de3a18e5e111b5eaab095312d7fe84', // STETH
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
exports.Adapters = {
|
|
24
|
+
[constants_1.Network.MAINNET]: {
|
|
25
|
+
// Note: We re-use the SmarDex adapters since it implements
|
|
26
|
+
// an Uniswap V2 router compatible interface, which OSwap supports.
|
|
27
|
+
[constants_1.SwapSide.SELL]: [{ name: 'Adapter04', index: 6 }],
|
|
28
|
+
[constants_1.SwapSide.BUY]: [{ name: 'BuyAdapter02', index: 2 }],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/oswap/config.ts"],"names":[],"mappings":";;;AAEA,+CAAoD;AAEvC,QAAA,cAAc,GAAG,KAAM,CAAC;AAErC,aAAa;AACb,yCAAyC;AACzC,iDAAiD;AACpC,QAAA,WAAW,GAA4B;IAClD,KAAK,EAAE;QACL,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,KAAK,EAAE;gBACL;oBACE,EAAE,EAAE,kDAAkD;oBACtD,OAAO,EAAE,4CAA4C;oBACrD,MAAM,EAAE,4CAA4C;oBACpD,MAAM,EAAE,4CAA4C,EAAE,QAAQ;iBAC/D;aACF;SACF;KACF;CACF,CAAC;AAEW,QAAA,QAAQ,GAAoC;IACvD,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;QACjB,2DAA2D;QAC3D,mEAAmE;QACnE,CAAC,oBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAClD,CAAC,oBAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;KACrD;CACF,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import { Log, Logger } from '../../types';
|
|
4
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
5
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
6
|
+
import { OSwapPool, OSwapPoolState } from './types';
|
|
7
|
+
export declare class OSwapEventPool extends StatefulEventSubscriber<OSwapPoolState> {
|
|
8
|
+
readonly parentName: string;
|
|
9
|
+
readonly pool: OSwapPool;
|
|
10
|
+
protected network: number;
|
|
11
|
+
protected dexHelper: IDexHelper;
|
|
12
|
+
protected iOSwap: Interface;
|
|
13
|
+
protected iERC20: Interface;
|
|
14
|
+
handlers: {
|
|
15
|
+
[event: string]: (event: any, state: DeepReadonly<OSwapPoolState>, log: Readonly<Log>) => DeepReadonly<OSwapPoolState> | null;
|
|
16
|
+
};
|
|
17
|
+
logDecoder: (log: Log) => any;
|
|
18
|
+
addressesSubscribed: string[];
|
|
19
|
+
constructor(parentName: string, pool: OSwapPool, network: number, dexHelper: IDexHelper, logger: Logger, iOSwap?: Interface, iERC20?: Interface);
|
|
20
|
+
protected parseLog(log: Log): import("@ethersproject/abi").LogDescription;
|
|
21
|
+
/**
|
|
22
|
+
* The function is called every time any of the subscribed
|
|
23
|
+
* addresses release log. The function accepts the current
|
|
24
|
+
* state, updates the state according to the log, and returns
|
|
25
|
+
* the updated state.
|
|
26
|
+
* @param state - Current state of event subscriber
|
|
27
|
+
* @param log - Log released by one of the subscribed addresses
|
|
28
|
+
* @returns Updates state of the event subscriber after the log
|
|
29
|
+
*/
|
|
30
|
+
protected processLog(state: DeepReadonly<OSwapPoolState>, log: Readonly<Log>): DeepReadonly<OSwapPoolState> | null;
|
|
31
|
+
/**
|
|
32
|
+
* The function generates state using on-chain calls. This
|
|
33
|
+
* function is called to regenerate state if the event based
|
|
34
|
+
* system fails to fetch events and the local state is no
|
|
35
|
+
* more correct.
|
|
36
|
+
* @param blockNumber - Blocknumber for which the state should
|
|
37
|
+
* should be generated
|
|
38
|
+
* @returns state of the event subscriber at blocknumber
|
|
39
|
+
*/
|
|
40
|
+
generateState(blockNumber: number): Promise<DeepReadonly<OSwapPoolState>>;
|
|
41
|
+
getStateOrGenerate(blockNumber: number, readonly?: boolean): Promise<OSwapPoolState>;
|
|
42
|
+
/**
|
|
43
|
+
* Handle a trade rate change on the pool.
|
|
44
|
+
*/
|
|
45
|
+
handleTraderateChanged(event: any, state: DeepReadonly<OSwapPoolState>, log: Readonly<Log>): DeepReadonly<OSwapPoolState> | null;
|
|
46
|
+
/**
|
|
47
|
+
* Process the transfer events for tokens in/out of the pool
|
|
48
|
+
* to keep the state's token balances up to date.
|
|
49
|
+
*/
|
|
50
|
+
handleTransfer(event: any, state: DeepReadonly<OSwapPoolState>, log: Readonly<Log>): DeepReadonly<OSwapPoolState> | null;
|
|
51
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
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.OSwapEventPool = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
|
|
10
|
+
const decoders_1 = require("../../lib/decoders");
|
|
11
|
+
const oswap_abi_json_1 = __importDefault(require("../../abi/oswap/oswap.abi.json"));
|
|
12
|
+
const ERC20_abi_json_1 = __importDefault(require("../../abi/ERC20.abi.json"));
|
|
13
|
+
class OSwapEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
14
|
+
constructor(parentName, pool, network, dexHelper, logger, iOSwap = new abi_1.Interface(oswap_abi_json_1.default), iERC20 = new abi_1.Interface(ERC20_abi_json_1.default)) {
|
|
15
|
+
super(parentName, pool.id, dexHelper, logger);
|
|
16
|
+
this.parentName = parentName;
|
|
17
|
+
this.pool = pool;
|
|
18
|
+
this.network = network;
|
|
19
|
+
this.dexHelper = dexHelper;
|
|
20
|
+
this.iOSwap = iOSwap;
|
|
21
|
+
this.iERC20 = iERC20;
|
|
22
|
+
this.handlers = {};
|
|
23
|
+
this.logDecoder = (log) => this.parseLog(log);
|
|
24
|
+
this.addressesSubscribed = [pool.address, pool.token0, pool.token1];
|
|
25
|
+
this.handlers['TraderateChanged'] = this.handleTraderateChanged.bind(this);
|
|
26
|
+
this.handlers['Transfer'] = this.handleTransfer.bind(this);
|
|
27
|
+
}
|
|
28
|
+
parseLog(log) {
|
|
29
|
+
if (log.address.toLowerCase() === this.pool.address) {
|
|
30
|
+
return this.iOSwap.parseLog(log);
|
|
31
|
+
}
|
|
32
|
+
return this.iERC20.parseLog(log);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The function is called every time any of the subscribed
|
|
36
|
+
* addresses release log. The function accepts the current
|
|
37
|
+
* state, updates the state according to the log, and returns
|
|
38
|
+
* the updated state.
|
|
39
|
+
* @param state - Current state of event subscriber
|
|
40
|
+
* @param log - Log released by one of the subscribed addresses
|
|
41
|
+
* @returns Updates state of the event subscriber after the log
|
|
42
|
+
*/
|
|
43
|
+
processLog(state, log) {
|
|
44
|
+
try {
|
|
45
|
+
const event = this.logDecoder(log);
|
|
46
|
+
if (event.name in this.handlers) {
|
|
47
|
+
return this.handlers[event.name](event, state, log);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
(0, utils_1.catchParseLogError)(e, this.logger);
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The function generates state using on-chain calls. This
|
|
57
|
+
* function is called to regenerate state if the event based
|
|
58
|
+
* system fails to fetch events and the local state is no
|
|
59
|
+
* more correct.
|
|
60
|
+
* @param blockNumber - Blocknumber for which the state should
|
|
61
|
+
* should be generated
|
|
62
|
+
* @returns state of the event subscriber at blocknumber
|
|
63
|
+
*/
|
|
64
|
+
async generateState(blockNumber) {
|
|
65
|
+
const iERC20 = new abi_1.Interface(ERC20_abi_json_1.default);
|
|
66
|
+
const callData = [
|
|
67
|
+
{
|
|
68
|
+
target: this.pool.token0,
|
|
69
|
+
callData: iERC20.encodeFunctionData('balanceOf', [this.pool.address]),
|
|
70
|
+
decodeFunction: decoders_1.uint256ToBigInt,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
target: this.pool.token1,
|
|
74
|
+
callData: iERC20.encodeFunctionData('balanceOf', [this.pool.address]),
|
|
75
|
+
decodeFunction: decoders_1.uint256ToBigInt,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
target: this.pool.address,
|
|
79
|
+
callData: this.iOSwap.encodeFunctionData('traderate0', []),
|
|
80
|
+
decodeFunction: decoders_1.uint256ToBigInt,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
target: this.pool.address,
|
|
84
|
+
callData: this.iOSwap.encodeFunctionData('traderate1', []),
|
|
85
|
+
decodeFunction: decoders_1.uint256ToBigInt,
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
const results = await this.dexHelper.multiWrapper.aggregate(callData, blockNumber, this.dexHelper.multiWrapper.defaultBatchSize);
|
|
89
|
+
return {
|
|
90
|
+
balance0: results[0],
|
|
91
|
+
balance1: results[1],
|
|
92
|
+
traderate0: results[2],
|
|
93
|
+
traderate1: results[3],
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async getStateOrGenerate(blockNumber, readonly = true) {
|
|
97
|
+
let state = this.getState(blockNumber);
|
|
98
|
+
if (!state) {
|
|
99
|
+
state = await this.generateState(blockNumber);
|
|
100
|
+
if (!readonly)
|
|
101
|
+
this.setState(state, blockNumber);
|
|
102
|
+
}
|
|
103
|
+
return state;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Handle a trade rate change on the pool.
|
|
107
|
+
*/
|
|
108
|
+
handleTraderateChanged(event, state, log) {
|
|
109
|
+
return {
|
|
110
|
+
...state,
|
|
111
|
+
traderate0: event.args.traderate0.toBigInt(),
|
|
112
|
+
traderate1: event.args.traderate1.toBigInt(),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Process the transfer events for tokens in/out of the pool
|
|
117
|
+
* to keep the state's token balances up to date.
|
|
118
|
+
*/
|
|
119
|
+
handleTransfer(event, state, log) {
|
|
120
|
+
let balance0 = state.balance0;
|
|
121
|
+
let balance1 = state.balance1;
|
|
122
|
+
const tokenAddress = log.address.toLowerCase();
|
|
123
|
+
const fromAddress = event.args.from.toLowerCase();
|
|
124
|
+
const toAddress = event.args.to.toLowerCase();
|
|
125
|
+
const amount = event.args.value.toBigInt();
|
|
126
|
+
if (fromAddress == this.pool.address) {
|
|
127
|
+
if (tokenAddress === this.pool.token0) {
|
|
128
|
+
balance0 -= amount;
|
|
129
|
+
}
|
|
130
|
+
else if (tokenAddress === this.pool.token1) {
|
|
131
|
+
balance1 -= amount;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else if (toAddress == this.pool.address) {
|
|
135
|
+
if (tokenAddress === this.pool.token0) {
|
|
136
|
+
balance0 += amount;
|
|
137
|
+
}
|
|
138
|
+
else if (tokenAddress === this.pool.token1) {
|
|
139
|
+
balance1 += amount;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
...state,
|
|
144
|
+
balance0,
|
|
145
|
+
balance1,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.OSwapEventPool = OSwapEventPool;
|
|
150
|
+
//# sourceMappingURL=oswap-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oswap-pool.js","sourceRoot":"","sources":["../../../src/dex/oswap/oswap-pool.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+C;AAG/C,uCAAiD;AACjD,+EAA0E;AAG1E,iDAAqD;AAErD,oFAAsD;AACtD,8EAAgD;AAEhD,MAAa,cAAe,SAAQ,mDAAuC;IAazE,YACW,UAAkB,EAClB,IAAe,EACd,OAAe,EACf,SAAqB,EAC/B,MAAc,EACJ,SAAS,IAAI,e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;QAClD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAE3C,IAAI,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACpC,IAAI,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBACrC,QAAQ,IAAI,MAAM,CAAC;aACpB;iBAAM,IAAI,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBAC5C,QAAQ,IAAI,MAAM,CAAC;aACpB;SACF;aAAM,IAAI,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACzC,IAAI,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBACrC,QAAQ,IAAI,MAAM,CAAC;aACpB;iBAAM,IAAI,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBAC5C,QAAQ,IAAI,MAAM,CAAC;aACpB;SACF;QAED,OAAO;YACL,GAAG,KAAK;YACR,QAAQ;YACR,QAAQ;SACT,CAAC;IACJ,CAAC;CACF;AAjLD,wCAiLC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { AsyncOrSync } from 'ts-essentials';
|
|
3
|
+
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, PoolLiquidity, Logger, NumberAsString, DexExchangeParam } from '../../types';
|
|
4
|
+
import { SwapSide, Network } from '../../constants';
|
|
5
|
+
import { Context, IDex } from '../../dex/idex';
|
|
6
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
7
|
+
import { OSwapData, OSwapPool, OSwapPoolState } from './types';
|
|
8
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
9
|
+
import { OSwapEventPool } from './oswap-pool';
|
|
10
|
+
export declare class OSwap extends SimpleExchange implements IDex<OSwapData> {
|
|
11
|
+
readonly network: Network;
|
|
12
|
+
readonly dexKey: string;
|
|
13
|
+
readonly dexHelper: IDexHelper;
|
|
14
|
+
protected adapters: import("../../types").AdapterMappings;
|
|
15
|
+
readonly eventPools: {
|
|
16
|
+
[id: string]: OSwapEventPool;
|
|
17
|
+
};
|
|
18
|
+
readonly hasConstantPriceLargeAmounts = false;
|
|
19
|
+
readonly needWrapNative = true;
|
|
20
|
+
readonly isFeeOnTransferSupported = false;
|
|
21
|
+
static dexKeysWithNetwork: {
|
|
22
|
+
key: string;
|
|
23
|
+
networks: Network[];
|
|
24
|
+
}[];
|
|
25
|
+
logger: Logger;
|
|
26
|
+
readonly iOSwap: Interface;
|
|
27
|
+
readonly pools: [OSwapPool];
|
|
28
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: import("../../types").AdapterMappings);
|
|
29
|
+
getAdapters(side: SwapSide): {
|
|
30
|
+
name: string;
|
|
31
|
+
index: number;
|
|
32
|
+
}[] | null;
|
|
33
|
+
getPoolByTokenPair(srcToken: Token, destToken: Token): OSwapPool | null;
|
|
34
|
+
getPoolById(id: string): OSwapPool | null;
|
|
35
|
+
getPoolsByTokenAddress(tokenAddress: Address): OSwapPool[];
|
|
36
|
+
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
37
|
+
calcPrice(pool: OSwapPool, state: OSwapPoolState, from: Token, amount: bigint, side: SwapSide): bigint;
|
|
38
|
+
checkLiquidity(pool: OSwapPool, state: OSwapPoolState, from: Token, amount: bigint, side: SwapSide): boolean;
|
|
39
|
+
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<OSwapData>>;
|
|
40
|
+
getCalldataGasCost(poolPrices: PoolPrices<OSwapData>): number | number[];
|
|
41
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: OSwapData, side: SwapSide): AdapterExchangeParam;
|
|
42
|
+
getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: OSwapData, side: SwapSide, _: Context, executorAddress: Address): DexExchangeParam;
|
|
43
|
+
updatePoolState(): Promise<void>;
|
|
44
|
+
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
45
|
+
releaseResources(): AsyncOrSync<void>;
|
|
46
|
+
}
|