@paraswap/dex-lib 3.8.26 → 3.8.27-dualsync.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dex/idex.d.ts +4 -0
- package/build/dex/uniswap-v2/uniswap-v2.d.ts +11 -4
- package/build/dex/uniswap-v2/uniswap-v2.js +40 -13
- package/build/dex/uniswap-v2/uniswap-v2.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3-pool.d.ts +3 -2
- package/build/dex/uniswap-v3/uniswap-v3-pool.js +3 -3
- package/build/dex/uniswap-v3/uniswap-v3-pool.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.d.ts +4 -0
- package/build/dex/uniswap-v3/uniswap-v3.js +11 -2
- package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
- package/build/dex-helper/dummy-dex-helper.d.ts +2 -0
- package/build/dex-helper/dummy-dex-helper.js.map +1 -1
- package/build/dex-helper/idex-helper.d.ts +2 -0
- package/build/dex-utils.d.ts +3 -0
- package/build/dex-utils.js +10 -0
- package/build/dex-utils.js.map +1 -0
- package/build/stateful-dual-synchronizer.d.ts +46 -0
- package/build/stateful-dual-synchronizer.js +300 -0
- package/build/stateful-dual-synchronizer.js.map +1 -0
- package/package.json +1 -1
- package/src/dex/idex.ts +8 -0
- package/src/dex/uniswap-v2/uniswap-v2.ts +66 -16
- package/src/dex/uniswap-v3/uniswap-v3-pool.ts +4 -6
- package/src/dex/uniswap-v3/uniswap-v3.ts +28 -2
- package/src/dex-helper/dummy-dex-helper.ts +2 -0
- package/src/dex-helper/idex-helper.ts +2 -0
- package/src/dex-utils.ts +5 -0
- package/src/stateful-dual-synchronizer.ts +415 -0
- package/.vscode/launch.json +0 -16
- package/.vscode/settings.json +0 -3
- package/build/abi/AaveV1_lending_pool.json +0 -27
- package/build/abi/BProtocol.json +0 -1155
- package/build/abi/Jarvis.json +0 -1172
- package/build/abi/MStableAsset.json +0 -1545
- package/build/abi/OneInchLp.json +0 -1304
- package/build/abi/Onebit.json +0 -736
- package/build/abi/Shell.json +0 -1294
- package/build/abi/TraderJoeV2Router.json +0 -50
- package/build/abi/Uncompressor.json +0 -250
- package/build/abi/integral/factory.json +0 -333
- package/build/abi/integral/oracle.json +0 -501
- package/build/abi/integral/pool.json +0 -1041
- package/build/abi/integral/relayer.json +0 -1536
- package/build/abi/platypus/asset.json +0 -490
- package/build/abi/platypus/avax-pool.json +0 -820
- package/build/abi/platypus/oracle.json +0 -119
- package/build/abi/platypus/pool.json +0 -677
- package/build/abi/smardex/all/smardex-router.json +0 -648
- package/build/abi/smardex/layer-1/smardex-factory.json +0 -242
- package/build/abi/smardex/layer-1/smardex-pool.json +0 -506
- package/build/abi/smardex/layer-2/smardex-factory.json +0 -185
- package/build/abi/smardex/layer-2/smardex-pool.json +0 -578
- package/build/abi/swaap-v1/pool.json +0 -1346
- package/build/abi/zrx.v2.json +0 -1967
- package/build/abi/zrx.v3.json +0 -3454
- package/build/abi/zrx.v4.json +0 -2193
- package/build/dex/OneInchLp.d.ts +0 -24
- package/build/dex/OneInchLp.js +0 -43
- package/build/dex/OneInchLp.js.map +0 -1
- package/build/dex/aave-v1/aave-v1.d.ts +0 -33
- package/build/dex/aave-v1/aave-v1.js +0 -158
- package/build/dex/aave-v1/aave-v1.js.map +0 -1
- package/build/dex/aave-v1/config.d.ts +0 -11
- package/build/dex/aave-v1/config.js +0 -20
- package/build/dex/aave-v1/config.js.map +0 -1
- package/build/dex/aave-v1/tokens-mainnet.json +0 -134
- package/build/dex/aave-v1/tokens.d.ts +0 -3
- package/build/dex/aave-v1/tokens.js +0 -50
- package/build/dex/aave-v1/tokens.js.map +0 -1
- package/build/dex/aave-v1/types.d.ts +0 -12
- package/build/dex/aave-v1/types.js +0 -3
- package/build/dex/aave-v1/types.js.map +0 -1
- package/build/dex/bProtocol/bProtocol.d.ts +0 -15
- package/build/dex/bProtocol/bProtocol.js +0 -56
- package/build/dex/bProtocol/bProtocol.js.map +0 -1
- package/build/dex/bProtocol/types.d.ts +0 -11
- package/build/dex/bProtocol/types.js +0 -8
- package/build/dex/bProtocol/types.js.map +0 -1
- package/build/dex/bProtocol.d.ts +0 -18
- package/build/dex/bProtocol.js +0 -39
- package/build/dex/bProtocol.js.map +0 -1
- package/build/dex/bancor.d.ts +0 -26
- package/build/dex/bancor.js +0 -58
- package/build/dex/bancor.js.map +0 -1
- package/build/dex/compound.d.ts +0 -18
- package/build/dex/compound.js +0 -46
- package/build/dex/compound.js.map +0 -1
- package/build/dex/curve-v2.d.ts +0 -58
- package/build/dex/curve-v2.js +0 -180
- package/build/dex/curve-v2.js.map +0 -1
- package/build/dex/dodo-v1.d.ts +0 -33
- package/build/dex/dodo-v1.js +0 -63
- package/build/dex/dodo-v1.js.map +0 -1
- package/build/dex/etherfi/etherfi.d.ts +0 -26
- package/build/dex/etherfi/etherfi.js +0 -96
- package/build/dex/etherfi/etherfi.js.map +0 -1
- package/build/dex/integral/config.d.ts +0 -4
- package/build/dex/integral/config.js +0 -20
- package/build/dex/integral/config.js.map +0 -1
- package/build/dex/integral/context.d.ts +0 -40
- package/build/dex/integral/context.js +0 -158
- package/build/dex/integral/context.js.map +0 -1
- package/build/dex/integral/helpers.d.ts +0 -17
- package/build/dex/integral/helpers.js +0 -157
- package/build/dex/integral/helpers.js.map +0 -1
- package/build/dex/integral/integral-factory.d.ts +0 -24
- package/build/dex/integral/integral-factory.js +0 -95
- package/build/dex/integral/integral-factory.js.map +0 -1
- package/build/dex/integral/integral-pool.d.ts +0 -50
- package/build/dex/integral/integral-pool.js +0 -149
- package/build/dex/integral/integral-pool.js.map +0 -1
- package/build/dex/integral/integral-pricing.d.ts +0 -18
- package/build/dex/integral/integral-pricing.js +0 -114
- package/build/dex/integral/integral-pricing.js.map +0 -1
- package/build/dex/integral/integral-relayer.d.ts +0 -42
- package/build/dex/integral/integral-relayer.js +0 -192
- package/build/dex/integral/integral-relayer.js.map +0 -1
- package/build/dex/integral/integral-token.d.ts +0 -27
- package/build/dex/integral/integral-token.js +0 -59
- package/build/dex/integral/integral-token.js.map +0 -1
- package/build/dex/integral/integral.d.ts +0 -41
- package/build/dex/integral/integral.js +0 -376
- package/build/dex/integral/integral.js.map +0 -1
- package/build/dex/integral/types.d.ts +0 -85
- package/build/dex/integral/types.js +0 -9
- package/build/dex/integral/types.js.map +0 -1
- package/build/dex/integral/utils-e2e.d.ts +0 -9
- package/build/dex/integral/utils-e2e.js +0 -131
- package/build/dex/integral/utils-e2e.js.map +0 -1
- package/build/dex/integral/utils.d.ts +0 -17
- package/build/dex/integral/utils.js +0 -94
- package/build/dex/integral/utils.js.map +0 -1
- package/build/dex/jarvis.d.ts +0 -56
- package/build/dex/jarvis.js +0 -163
- package/build/dex/jarvis.js.map +0 -1
- package/build/dex/lido.d.ts +0 -19
- package/build/dex/lido.js +0 -42
- package/build/dex/lido.js.map +0 -1
- package/build/dex/mStable.d.ts +0 -44
- package/build/dex/mStable.js +0 -75
- package/build/dex/mStable.js.map +0 -1
- package/build/dex/onebit/onebit.d.ts +0 -16
- package/build/dex/onebit/onebit.js +0 -61
- package/build/dex/onebit/onebit.js.map +0 -1
- package/build/dex/onebit/types.d.ts +0 -14
- package/build/dex/onebit/types.js +0 -8
- package/build/dex/onebit/types.js.map +0 -1
- package/build/dex/onebit.d.ts +0 -25
- package/build/dex/onebit.js +0 -42
- package/build/dex/onebit.js.map +0 -1
- package/build/dex/platypus/asset.d.ts +0 -14
- package/build/dex/platypus/asset.js +0 -97
- package/build/dex/platypus/asset.js.map +0 -1
- package/build/dex/platypus/config.d.ts +0 -11
- package/build/dex/platypus/config.js +0 -69
- package/build/dex/platypus/config.js.map +0 -1
- package/build/dex/platypus/platypus.d.ts +0 -62
- package/build/dex/platypus/platypus.js +0 -442
- package/build/dex/platypus/platypus.js.map +0 -1
- package/build/dex/platypus/pool-avax.d.ts +0 -8
- package/build/dex/platypus/pool-avax.js +0 -54
- package/build/dex/platypus/pool-avax.js.map +0 -1
- package/build/dex/platypus/pool-base.d.ts +0 -19
- package/build/dex/platypus/pool-base.js +0 -86
- package/build/dex/platypus/pool-base.js.map +0 -1
- package/build/dex/platypus/pool-pure.d.ts +0 -8
- package/build/dex/platypus/pool-pure.js +0 -37
- package/build/dex/platypus/pool-pure.js.map +0 -1
- package/build/dex/platypus/pool-subscriber.d.ts +0 -14
- package/build/dex/platypus/pool-subscriber.js +0 -167
- package/build/dex/platypus/pool-subscriber.js.map +0 -1
- package/build/dex/platypus/pool.d.ts +0 -8
- package/build/dex/platypus/pool.js +0 -58
- package/build/dex/platypus/pool.js.map +0 -1
- package/build/dex/platypus/types.d.ts +0 -92
- package/build/dex/platypus/types.js +0 -10
- package/build/dex/platypus/types.js.map +0 -1
- package/build/dex/quickswap/spiritswap-v3.d.ts +0 -6
- package/build/dex/quickswap/spiritswap-v3.js +0 -19
- package/build/dex/quickswap/spiritswap-v3.js.map +0 -1
- package/build/dex/sdai/config.d.ts +0 -11
- package/build/dex/sdai/config.js +0 -21
- package/build/dex/sdai/config.js.map +0 -1
- package/build/dex/sdai/constants.d.ts +0 -2
- package/build/dex/sdai/constants.js +0 -6
- package/build/dex/sdai/constants.js.map +0 -1
- package/build/dex/sdai/scripts/validate-state.d.ts +0 -1
- package/build/dex/sdai/scripts/validate-state.js +0 -102
- package/build/dex/sdai/scripts/validate-state.js.map +0 -1
- package/build/dex/sdai/sdai-pool.d.ts +0 -16
- package/build/dex/sdai/sdai-pool.js +0 -85
- package/build/dex/sdai/sdai-pool.js.map +0 -1
- package/build/dex/sdai/sdai.d.ts +0 -51
- package/build/dex/sdai/sdai.js +0 -172
- package/build/dex/sdai/sdai.js.map +0 -1
- package/build/dex/sdai/types.d.ts +0 -21
- package/build/dex/sdai/types.js +0 -11
- package/build/dex/sdai/types.js.map +0 -1
- package/build/dex/sdai/utils.d.ts +0 -4
- package/build/dex/sdai/utils.js +0 -39
- package/build/dex/sdai/utils.js.map +0 -1
- package/build/dex/shell.d.ts +0 -25
- package/build/dex/shell.js +0 -41
- package/build/dex/shell.js.map +0 -1
- package/build/dex/smardex/config.d.ts +0 -4
- package/build/dex/smardex/config.js +0 -64
- package/build/dex/smardex/config.js.map +0 -1
- package/build/dex/smardex/constants.d.ts +0 -18
- package/build/dex/smardex/constants.js +0 -33
- package/build/dex/smardex/constants.js.map +0 -1
- package/build/dex/smardex/sdk/constants.d.ts +0 -6
- package/build/dex/smardex/sdk/constants.js +0 -13
- package/build/dex/smardex/sdk/constants.js.map +0 -1
- package/build/dex/smardex/sdk/core.d.ts +0 -113
- package/build/dex/smardex/sdk/core.js +0 -499
- package/build/dex/smardex/sdk/core.js.map +0 -1
- package/build/dex/smardex/sdk/errors.d.ts +0 -15
- package/build/dex/smardex/sdk/errors.js +0 -22
- package/build/dex/smardex/sdk/errors.js.map +0 -1
- package/build/dex/smardex/sdk/types.d.ts +0 -62
- package/build/dex/smardex/sdk/types.js +0 -3
- package/build/dex/smardex/sdk/types.js.map +0 -1
- package/build/dex/smardex/sdk/utils.d.ts +0 -44
- package/build/dex/smardex/sdk/utils.js +0 -133
- package/build/dex/smardex/sdk/utils.js.map +0 -1
- package/build/dex/smardex/smardex-event-pool.d.ts +0 -28
- package/build/dex/smardex/smardex-event-pool.js +0 -119
- package/build/dex/smardex/smardex-event-pool.js.map +0 -1
- package/build/dex/smardex/smardex.d.ts +0 -65
- package/build/dex/smardex/smardex.js +0 -519
- package/build/dex/smardex/smardex.js.map +0 -1
- package/build/dex/smardex/types.d.ts +0 -55
- package/build/dex/smardex/types.js +0 -3
- package/build/dex/smardex/types.js.map +0 -1
- package/build/dex/smoothy.d.ts +0 -26
- package/build/dex/smoothy.js +0 -48
- package/build/dex/smoothy.js.map +0 -1
- package/build/dex/solidly/forks-override/cone.d.ts +0 -22
- package/build/dex/solidly/forks-override/cone.js +0 -53
- package/build/dex/solidly/forks-override/cone.js.map +0 -1
- package/build/dex/solidly/forks-override/solisnek.d.ts +0 -8
- package/build/dex/solidly/forks-override/solisnek.js +0 -15
- package/build/dex/solidly/forks-override/solisnek.js.map +0 -1
- package/build/dex/stable-pool.d.ts +0 -28
- package/build/dex/stable-pool.js +0 -62
- package/build/dex/stable-pool.js.map +0 -1
- package/build/dex/swaap-v1/config.d.ts +0 -17
- package/build/dex/swaap-v1/config.js +0 -56
- package/build/dex/swaap-v1/config.js.map +0 -1
- package/build/dex/swaap-v1/constants.d.ts +0 -6
- package/build/dex/swaap-v1/constants.js +0 -17
- package/build/dex/swaap-v1/constants.js.map +0 -1
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.d.ts +0 -25
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.js +0 -62
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.js.map +0 -1
- package/build/dex/swaap-v1/libraries/Const.d.ts +0 -18
- package/build/dex/swaap-v1/libraries/Const.js +0 -26
- package/build/dex/swaap-v1/libraries/Const.js.map +0 -1
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.d.ts +0 -77
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js +0 -316
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js.map +0 -1
- package/build/dex/swaap-v1/libraries/LogExpMath.d.ts +0 -75
- package/build/dex/swaap-v1/libraries/LogExpMath.js +0 -418
- package/build/dex/swaap-v1/libraries/LogExpMath.js.map +0 -1
- package/build/dex/swaap-v1/libraries/MathMMM.d.ts +0 -185
- package/build/dex/swaap-v1/libraries/MathMMM.js +0 -453
- package/build/dex/swaap-v1/libraries/MathMMM.js.map +0 -1
- package/build/dex/swaap-v1/libraries/Num.d.ts +0 -31
- package/build/dex/swaap-v1/libraries/Num.js +0 -167
- package/build/dex/swaap-v1/libraries/Num.js.map +0 -1
- package/build/dex/swaap-v1/libraries/PoolQuotations.d.ts +0 -23
- package/build/dex/swaap-v1/libraries/PoolQuotations.js +0 -131
- package/build/dex/swaap-v1/libraries/PoolQuotations.js.map +0 -1
- package/build/dex/swaap-v1/libraries/Struct.d.ts +0 -56
- package/build/dex/swaap-v1/libraries/Struct.js +0 -3
- package/build/dex/swaap-v1/libraries/Struct.js.map +0 -1
- package/build/dex/swaap-v1/swaap-v1-pool.d.ts +0 -45
- package/build/dex/swaap-v1/swaap-v1-pool.js +0 -656
- package/build/dex/swaap-v1/swaap-v1-pool.js.map +0 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +0 -61
- package/build/dex/swaap-v1/swaap-v1.js +0 -369
- package/build/dex/swaap-v1/swaap-v1.js.map +0 -1
- package/build/dex/swaap-v1/types.d.ts +0 -106
- package/build/dex/swaap-v1/types.js +0 -9
- package/build/dex/swaap-v1/types.js.map +0 -1
- package/build/dex/trader-joe-v2.1/optimizer.d.ts +0 -2
- package/build/dex/trader-joe-v2.1/optimizer.js +0 -44
- package/build/dex/trader-joe-v2.1/optimizer.js.map +0 -1
- package/build/dex/trader-joe-v2.1.d.ts +0 -43
- package/build/dex/trader-joe-v2.1.js +0 -79
- package/build/dex/trader-joe-v2.1.js.map +0 -1
- package/build/dex/trader-joe-v2.d.ts +0 -40
- package/build/dex/trader-joe-v2.js +0 -74
- package/build/dex/trader-joe-v2.js.map +0 -1
- package/build/dex/zerox/config.d.ts +0 -2
- package/build/dex/zerox/config.js +0 -33
- package/build/dex/zerox/config.js.map +0 -1
- package/build/dex/zerox/index.d.ts +0 -22
- package/build/dex/zerox/index.js +0 -225
- package/build/dex/zerox/index.js.map +0 -1
- package/build/dex/zerox/order.d.ts +0 -88
- package/build/dex/zerox/order.js +0 -53
- package/build/dex/zerox/order.js.map +0 -1
- package/build/dex/zerox/types.d.ts +0 -73
- package/build/dex/zerox/types.js +0 -21
- package/build/dex/zerox/types.js.map +0 -1
- package/build/executor/compressor/Compressor.d.ts +0 -23
- package/build/executor/compressor/Compressor.js +0 -144
- package/build/executor/compressor/Compressor.js.map +0 -1
- package/build/executor/compressor/compress.d.ts +0 -17
- package/build/executor/compressor/compress.js +0 -187
- package/build/executor/compressor/compress.js.map +0 -1
- package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +0 -6
- package/build/executor/compressor/compress_functions/addressSubstitution.js +0 -29
- package/build/executor/compressor/compress_functions/addressSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +0 -10
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +0 -40
- package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +0 -1
- package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +0 -11
- package/build/executor/compressor/compress_functions/byteSubstitution.js +0 -64
- package/build/executor/compressor/compress_functions/byteSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +0 -7
- package/build/executor/compressor/compress_functions/ffSubstitution.js +0 -54
- package/build/executor/compressor/compress_functions/ffSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +0 -8
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +0 -67
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +0 -1
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +0 -8
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +0 -61
- package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +0 -1
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +0 -6
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +0 -37
- package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +0 -1
- package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +0 -9
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js +0 -33
- package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +0 -1
- package/build/executor/compressor/fetchSaved.d.ts +0 -0
- package/build/executor/compressor/fetchSaved.js +0 -17
- package/build/executor/compressor/fetchSaved.js.map +0 -1
- package/build/executor/compressor/utils/computeCostL2.d.ts +0 -2
- package/build/executor/compressor/utils/computeCostL2.js +0 -14
- package/build/executor/compressor/utils/computeCostL2.js.map +0 -1
- package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +0 -2
- package/build/executor/compressor/utils/findLongestDuplicatedString.js +0 -30
- package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +0 -1
- package/build/executor/compressor/utils/getAllIndexes.d.ts +0 -2
- package/build/executor/compressor/utils/getAllIndexes.js +0 -12
- package/build/executor/compressor/utils/getAllIndexes.js.map +0 -1
- package/build/executor/compressor/utils/getByteForAddress.d.ts +0 -2
- package/build/executor/compressor/utils/getByteForAddress.js +0 -14
- package/build/executor/compressor/utils/getByteForAddress.js.map +0 -1
- package/build/executor/compressor/utils/intTo2Bytes.d.ts +0 -2
- package/build/executor/compressor/utils/intTo2Bytes.js +0 -14
- package/build/executor/compressor/utils/intTo2Bytes.js.map +0 -1
- package/build/executor/compressor/utils/intTo3Bytes.d.ts +0 -2
- package/build/executor/compressor/utils/intTo3Bytes.js +0 -18
- package/build/executor/compressor/utils/intTo3Bytes.js.map +0 -1
- package/build/executor/compressor/utils/intToByte.d.ts +0 -2
- package/build/executor/compressor/utils/intToByte.js +0 -10
- package/build/executor/compressor/utils/intToByte.js.map +0 -1
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Address, Token } from '../../types';
|
|
2
|
-
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
3
|
-
import { PlatypusPurePoolState, PlatypusPurePoolConfigInfo } from './types';
|
|
4
|
-
import { PlatypusPoolBase } from './pool-base';
|
|
5
|
-
export declare class PlatypusPurePool extends PlatypusPoolBase<PlatypusPurePoolState> {
|
|
6
|
-
constructor(dexKey: string, network: number, name: string, poolAddress: Address, poolCfg: PlatypusPurePoolConfigInfo, dexHelper: IDexHelper);
|
|
7
|
-
computePrices(srcToken: Token, destToken: Token, amounts: bigint[], state: PlatypusPurePoolState): bigint[];
|
|
8
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlatypusPurePool = void 0;
|
|
4
|
-
const lens_1 = require("../../lens");
|
|
5
|
-
const asset_1 = require("./asset");
|
|
6
|
-
const pool_subscriber_1 = require("./pool-subscriber");
|
|
7
|
-
const utils_1 = require("../../utils");
|
|
8
|
-
const pool_base_1 = require("./pool-base");
|
|
9
|
-
class PlatypusPurePool extends pool_base_1.PlatypusPoolBase {
|
|
10
|
-
constructor(dexKey, network, name, poolAddress, poolCfg, dexHelper) {
|
|
11
|
-
super(dexKey, network, name, dexHelper, [
|
|
12
|
-
new pool_subscriber_1.PlatypusPoolSubscriber(poolAddress, (0, lens_1.lens)().params, dexHelper.getLogger(`${dexKey}-${network} Params ${name}`)),
|
|
13
|
-
...Object.entries(poolCfg.tokens).map(([tokenAddress, c]) => new asset_1.PlatypusAssetSubscriber(c.assetAddress, (0, lens_1.lens)().asset[tokenAddress], dexHelper.getLogger(`${dexKey}-${network} ${c.tokenSymbol} asset ${name}`))),
|
|
14
|
-
], {
|
|
15
|
-
params: {
|
|
16
|
-
paused: false,
|
|
17
|
-
slippageParamK: 0n,
|
|
18
|
-
slippageParamN: 0n,
|
|
19
|
-
c1: 0n,
|
|
20
|
-
xThreshold: 0n,
|
|
21
|
-
haircutRate: 0n,
|
|
22
|
-
retentionRatio: 0n,
|
|
23
|
-
maxPriceDeviation: 0n,
|
|
24
|
-
},
|
|
25
|
-
asset: {},
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
computePrices(srcToken, destToken, amounts, state) {
|
|
29
|
-
return amounts.map(fromAmount => {
|
|
30
|
-
const idealToAmount = (fromAmount * (0, utils_1.getBigIntPow)(destToken.decimals)) /
|
|
31
|
-
(0, utils_1.getBigIntPow)(srcToken.decimals);
|
|
32
|
-
return (0, pool_base_1.calcPrice)(srcToken, destToken, fromAmount, idealToAmount, state);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.PlatypusPurePool = PlatypusPurePool;
|
|
37
|
-
//# sourceMappingURL=pool-pure.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pool-pure.js","sourceRoot":"","sources":["../../../src/dex/platypus/pool-pure.ts"],"names":[],"mappings":";;;AAEA,qCAAkC;AAClC,mCAAkD;AAClD,uDAA2D;AAG3D,uCAA2C;AAC3C,2CAA0D;AAE1D,MAAa,gBAAiB,SAAQ,4BAAuC;IAC3E,YACE,MAAc,EACd,OAAe,EACf,IAAY,EACZ,WAAoB,EACpB,OAAmC,EACnC,SAAqB;QAErB,KAAK,CACH,MAAM,EACN,OAAO,EACP,IAAI,EACJ,SAAS,EACT;YACE,IAAI,wCAAsB,CACxB,WAAW,EACX,IAAA,WAAI,GAAuC,CAAC,MAAM,EAClD,SAAS,CAAC,SAAS,CAAC,GAAG,MAAM,IAAI,OAAO,WAAW,IAAI,EAAE,CAAC,CAC3D;YACD,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CACnC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE,CACpB,IAAI,+BAAuB,CACzB,CAAC,CAAC,YAAY,EACd,IAAA,WAAI,GAAuC,CAAC,KAAK,CAAC,YAAY,CAAC,EAC/D,SAAS,CAAC,SAAS,CACjB,GAAG,MAAM,IAAI,OAAO,IAAI,CAAC,CAAC,WAAW,UAAU,IAAI,EAAE,CACtD,CACF,CACJ;SACF,EACD;YACE,MAAM,EAAE;gBACN,MAAM,EAAE,KAAK;gBACb,cAAc,EAAE,EAAE;gBAClB,cAAc,EAAE,EAAE;gBAClB,EAAE,EAAE,EAAE;gBACN,UAAU,EAAE,EAAE;gBACd,WAAW,EAAE,EAAE;gBACf,cAAc,EAAE,EAAE;gBAClB,iBAAiB,EAAE,EAAE;aACtB;YACD,KAAK,EAAE,EAAE;SACV,CACF,CAAC;IACJ,CAAC;IAEM,aAAa,CAClB,QAAe,EACf,SAAgB,EAChB,OAAiB,EACjB,KAA4B;QAE5B,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YAC9B,MAAM,aAAa,GACjB,CAAC,UAAU,GAAG,IAAA,oBAAY,EAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;gBAC/C,IAAA,oBAAY,EAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAClC,OAAO,IAAA,qBAAS,EAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC;QAC1E,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA5DD,4CA4DC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DeepReadonly } from 'ts-essentials';
|
|
2
|
-
import { PartialEventSubscriber } from '../../composed-event-subscriber';
|
|
3
|
-
import { Address, BlockHeader, Log, Logger, MultiCallInput, MultiCallOutput } from '../../types';
|
|
4
|
-
import { Lens } from '../../lens';
|
|
5
|
-
import { Interface } from '@ethersproject/abi';
|
|
6
|
-
import { PlatypusPoolParams } from './types';
|
|
7
|
-
export declare class PlatypusPoolSubscriber<State> extends PartialEventSubscriber<State, PlatypusPoolParams> {
|
|
8
|
-
private pool;
|
|
9
|
-
static readonly poolInterface: Interface;
|
|
10
|
-
constructor(pool: Address, lens: Lens<DeepReadonly<State>, DeepReadonly<PlatypusPoolParams>>, logger: Logger);
|
|
11
|
-
processLog(state: DeepReadonly<PlatypusPoolParams>, log: Readonly<Log>, blockHeader: Readonly<BlockHeader>): DeepReadonly<PlatypusPoolParams> | null;
|
|
12
|
-
getGenerateStateMultiCallInputs(): MultiCallInput[];
|
|
13
|
-
generateState(multicallOutputs: MultiCallOutput[], blockNumber?: number | 'latest'): DeepReadonly<PlatypusPoolParams>;
|
|
14
|
-
}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PlatypusPoolSubscriber = void 0;
|
|
7
|
-
const composed_event_subscriber_1 = require("../../composed-event-subscriber");
|
|
8
|
-
const abi_1 = require("@ethersproject/abi");
|
|
9
|
-
const pool_json_1 = __importDefault(require("../../abi/platypus/pool.json"));
|
|
10
|
-
class PlatypusPoolSubscriber extends composed_event_subscriber_1.PartialEventSubscriber {
|
|
11
|
-
constructor(pool, lens, logger) {
|
|
12
|
-
super([pool], lens, logger);
|
|
13
|
-
this.pool = pool;
|
|
14
|
-
}
|
|
15
|
-
processLog(state, log, blockHeader) {
|
|
16
|
-
try {
|
|
17
|
-
const parsed = PlatypusPoolSubscriber.poolInterface.parseLog(log);
|
|
18
|
-
switch (parsed.name) {
|
|
19
|
-
case 'Paused': {
|
|
20
|
-
return {
|
|
21
|
-
...state,
|
|
22
|
-
paused: true,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
case 'Unpaused': {
|
|
26
|
-
return {
|
|
27
|
-
...state,
|
|
28
|
-
paused: false,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
case 'PriceDeviationUpdated': {
|
|
32
|
-
const previousPriceDeviation = BigInt(parsed.args.previousPriceDeviation.toString());
|
|
33
|
-
const newPriceDeviation = BigInt(parsed.args.newPriceDeviation.toString());
|
|
34
|
-
if (state.maxPriceDeviation !== previousPriceDeviation) {
|
|
35
|
-
this.logger.error('state.maxPriceDeviation !== previousPriceDeviation');
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
...state,
|
|
39
|
-
maxPriceDeviation: newPriceDeviation,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
case 'SlippageParamsUpdated': {
|
|
43
|
-
const previousK = BigInt(parsed.args.previousK.toString());
|
|
44
|
-
const newK = BigInt(parsed.args.newK.toString());
|
|
45
|
-
const previousN = BigInt(parsed.args.previousN.toString());
|
|
46
|
-
const newN = BigInt(parsed.args.newN.toString());
|
|
47
|
-
const previousC1 = BigInt(parsed.args.previousC1.toString());
|
|
48
|
-
const newC1 = BigInt(parsed.args.newC1.toString());
|
|
49
|
-
const previousXThreshold = BigInt(parsed.args.previousXThreshold.toString());
|
|
50
|
-
const newXThreshold = BigInt(parsed.args.newXThreshold.toString());
|
|
51
|
-
if (state.slippageParamK !== previousK) {
|
|
52
|
-
this.logger.error('state.slippageParamK !== previousK');
|
|
53
|
-
}
|
|
54
|
-
if (state.slippageParamN !== previousN) {
|
|
55
|
-
this.logger.error('state.slippageParamN !== previousN');
|
|
56
|
-
}
|
|
57
|
-
if (state.c1 !== previousC1) {
|
|
58
|
-
this.logger.error('state.c1 !== previousC1');
|
|
59
|
-
}
|
|
60
|
-
if (state.xThreshold !== previousXThreshold) {
|
|
61
|
-
this.logger.error('state.xThreshold !== previousXThreshold');
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
...state,
|
|
65
|
-
slippageParamK: newK,
|
|
66
|
-
slippageParamN: newN,
|
|
67
|
-
c1: newC1,
|
|
68
|
-
xThreshold: newXThreshold,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
case 'HaircutRateUpdated': {
|
|
72
|
-
const previousHaircut = BigInt(parsed.args.previousHaircut.toString());
|
|
73
|
-
const newHaircut = BigInt(parsed.args.newHaircut.toString());
|
|
74
|
-
if (state.haircutRate !== previousHaircut) {
|
|
75
|
-
this.logger.error('state.haircutRate !== previousHaircut');
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
...state,
|
|
79
|
-
haircutRate: newHaircut,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
case 'RetentionRatioUpdated': {
|
|
83
|
-
const previousRetentionRatio = BigInt(parsed.args.previousRetentionRatio.toString());
|
|
84
|
-
const newRetentionRatio = BigInt(parsed.args.newRetentionRatio.toString());
|
|
85
|
-
if (state.retentionRatio !== previousRetentionRatio) {
|
|
86
|
-
this.logger.error('state.retentionRatio !== previousRetentionRatio');
|
|
87
|
-
}
|
|
88
|
-
return {
|
|
89
|
-
...state,
|
|
90
|
-
retentionRatio: newRetentionRatio,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
default:
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
catch (e) {
|
|
98
|
-
this.logger.error('Failed to parse log', e);
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
getGenerateStateMultiCallInputs() {
|
|
103
|
-
return [
|
|
104
|
-
{
|
|
105
|
-
target: this.pool,
|
|
106
|
-
callData: PlatypusPoolSubscriber.poolInterface.encodeFunctionData('paused'),
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
target: this.pool,
|
|
110
|
-
callData: PlatypusPoolSubscriber.poolInterface.encodeFunctionData('getSlippageParamK'),
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
target: this.pool,
|
|
114
|
-
callData: PlatypusPoolSubscriber.poolInterface.encodeFunctionData('getSlippageParamN'),
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
target: this.pool,
|
|
118
|
-
callData: PlatypusPoolSubscriber.poolInterface.encodeFunctionData('getC1'),
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
target: this.pool,
|
|
122
|
-
callData: PlatypusPoolSubscriber.poolInterface.encodeFunctionData('getXThreshold'),
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
target: this.pool,
|
|
126
|
-
callData: PlatypusPoolSubscriber.poolInterface.encodeFunctionData('getHaircutRate'),
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
target: this.pool,
|
|
130
|
-
callData: PlatypusPoolSubscriber.poolInterface.encodeFunctionData('getRetentionRatio'),
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
target: this.pool,
|
|
134
|
-
callData: PlatypusPoolSubscriber.poolInterface.encodeFunctionData('getMaxPriceDeviation'),
|
|
135
|
-
},
|
|
136
|
-
];
|
|
137
|
-
}
|
|
138
|
-
generateState(multicallOutputs, blockNumber) {
|
|
139
|
-
return {
|
|
140
|
-
paused: PlatypusPoolSubscriber.poolInterface.decodeFunctionResult('paused', multicallOutputs[0])[0],
|
|
141
|
-
slippageParamK: BigInt(PlatypusPoolSubscriber.poolInterface
|
|
142
|
-
.decodeFunctionResult('getSlippageParamK', multicallOutputs[1])[0]
|
|
143
|
-
.toString()),
|
|
144
|
-
slippageParamN: BigInt(PlatypusPoolSubscriber.poolInterface
|
|
145
|
-
.decodeFunctionResult('getSlippageParamN', multicallOutputs[2])[0]
|
|
146
|
-
.toString()),
|
|
147
|
-
c1: BigInt(PlatypusPoolSubscriber.poolInterface
|
|
148
|
-
.decodeFunctionResult('getC1', multicallOutputs[3])[0]
|
|
149
|
-
.toString()),
|
|
150
|
-
xThreshold: BigInt(PlatypusPoolSubscriber.poolInterface
|
|
151
|
-
.decodeFunctionResult('getXThreshold', multicallOutputs[4])[0]
|
|
152
|
-
.toString()),
|
|
153
|
-
haircutRate: BigInt(PlatypusPoolSubscriber.poolInterface
|
|
154
|
-
.decodeFunctionResult('getHaircutRate', multicallOutputs[5])[0]
|
|
155
|
-
.toString()),
|
|
156
|
-
retentionRatio: BigInt(PlatypusPoolSubscriber.poolInterface
|
|
157
|
-
.decodeFunctionResult('getRetentionRatio', multicallOutputs[6])[0]
|
|
158
|
-
.toString()),
|
|
159
|
-
maxPriceDeviation: BigInt(PlatypusPoolSubscriber.poolInterface
|
|
160
|
-
.decodeFunctionResult('getMaxPriceDeviation', multicallOutputs[7])[0]
|
|
161
|
-
.toString()),
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
exports.PlatypusPoolSubscriber = PlatypusPoolSubscriber;
|
|
166
|
-
PlatypusPoolSubscriber.poolInterface = new abi_1.Interface(pool_json_1.default);
|
|
167
|
-
//# sourceMappingURL=pool-subscriber.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pool-sub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/idex-helper';
|
|
3
|
-
import { PlatypusPoolState, PlatypusPoolConfigInfo } from './types';
|
|
4
|
-
import { PlatypusPoolBase } from './pool-base';
|
|
5
|
-
export declare class PlatypusPool extends PlatypusPoolBase<PlatypusPoolState> {
|
|
6
|
-
constructor(dexKey: string, network: number, name: string, poolAddress: Address, poolCfg: PlatypusPoolConfigInfo, dexHelper: IDexHelper);
|
|
7
|
-
computePrices(srcToken: Token, destToken: Token, amounts: bigint[], state: PlatypusPoolState): bigint[];
|
|
8
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlatypusPool = void 0;
|
|
4
|
-
const lens_1 = require("../../lens");
|
|
5
|
-
const chainlink_1 = require("../../lib/chainlink");
|
|
6
|
-
const asset_1 = require("./asset");
|
|
7
|
-
const pool_subscriber_1 = require("./pool-subscriber");
|
|
8
|
-
const utils_1 = require("../../utils");
|
|
9
|
-
const pool_base_1 = require("./pool-base");
|
|
10
|
-
class PlatypusPool extends pool_base_1.PlatypusPoolBase {
|
|
11
|
-
constructor(dexKey, network, name, poolAddress, poolCfg, dexHelper) {
|
|
12
|
-
super(dexKey, network, name, dexHelper, [
|
|
13
|
-
new pool_subscriber_1.PlatypusPoolSubscriber(poolAddress, (0, lens_1.lens)().params, dexHelper.getLogger(`${dexKey}-${network} Params ${name}`)),
|
|
14
|
-
...Object.entries(poolCfg.tokens)
|
|
15
|
-
.map(([tokenAddress, c]) => [
|
|
16
|
-
new asset_1.PlatypusAssetSubscriber(c.assetAddress, (0, lens_1.lens)().asset[tokenAddress], dexHelper.getLogger(`${dexKey}-${network} ${c.tokenSymbol} asset ${name}`)),
|
|
17
|
-
new chainlink_1.ChainLinkSubscriber(c.chainlink.proxyAddress, c.chainlink.aggregatorAddress, (0, lens_1.lens)().chainlink[tokenAddress], dexHelper.getLogger(`${c.tokenSymbol} ChainLink for ${dexKey}-${network} ${name}`)),
|
|
18
|
-
])
|
|
19
|
-
.flat(),
|
|
20
|
-
], {
|
|
21
|
-
params: {
|
|
22
|
-
paused: false,
|
|
23
|
-
slippageParamK: 0n,
|
|
24
|
-
slippageParamN: 0n,
|
|
25
|
-
c1: 0n,
|
|
26
|
-
xThreshold: 0n,
|
|
27
|
-
haircutRate: 0n,
|
|
28
|
-
retentionRatio: 0n,
|
|
29
|
-
maxPriceDeviation: 0n,
|
|
30
|
-
},
|
|
31
|
-
asset: {},
|
|
32
|
-
chainlink: {},
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
computePrices(srcToken, destToken, amounts, state) {
|
|
36
|
-
const tokenAPrice = state.chainlink[srcToken.address].answer;
|
|
37
|
-
const tokenBPrice = state.chainlink[destToken.address].answer;
|
|
38
|
-
if (tokenBPrice > tokenAPrice) {
|
|
39
|
-
if (((tokenBPrice - tokenAPrice) * pool_base_1.ETH_UNIT) / tokenBPrice >
|
|
40
|
-
state.params.maxPriceDeviation) {
|
|
41
|
-
return Array(amounts.length).fill(0n);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
if (((tokenAPrice - tokenBPrice) * pool_base_1.ETH_UNIT) / tokenAPrice >
|
|
46
|
-
state.params.maxPriceDeviation) {
|
|
47
|
-
return Array(amounts.length).fill(0n);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return amounts.map(fromAmount => {
|
|
51
|
-
const idealToAmount = (fromAmount * (0, utils_1.getBigIntPow)(destToken.decimals)) /
|
|
52
|
-
(0, utils_1.getBigIntPow)(srcToken.decimals);
|
|
53
|
-
return (0, pool_base_1.calcPrice)(srcToken, destToken, fromAmount, idealToAmount, state);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.PlatypusPool = PlatypusPool;
|
|
58
|
-
//# sourceMappingURL=pool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pool.js","sourceRoot":"","sources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ACL,CAAC;CACF;AAvFD,oCAuFC"}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Address } from '../../types';
|
|
2
|
-
import { ChainLinkState } from '../../lib/chainlink';
|
|
3
|
-
import { StakedAvaxState } from '../../lib/benqi/staked-avax';
|
|
4
|
-
export declare enum PlatypusOracleType {
|
|
5
|
-
None = "None",
|
|
6
|
-
ChainLink = "ChainLink",
|
|
7
|
-
StakedAvax = "StakedAvax"
|
|
8
|
-
}
|
|
9
|
-
export declare type PlatypusPoolStateCommon = {
|
|
10
|
-
params: PlatypusPoolParams;
|
|
11
|
-
asset: {
|
|
12
|
-
[underlyingAddress: string]: PlatypusAssetState;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export declare type PlatypusPoolState = PlatypusPoolStateCommon & {
|
|
16
|
-
chainlink: {
|
|
17
|
-
[underlyingAddress: string]: ChainLinkState;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
export declare type PlatypusPurePoolState = PlatypusPoolStateCommon;
|
|
21
|
-
export declare type PlatypusAvaxPoolState = PlatypusPoolStateCommon & {
|
|
22
|
-
stakedAvax: StakedAvaxState;
|
|
23
|
-
};
|
|
24
|
-
export declare type PlatypusPoolParams = {
|
|
25
|
-
paused: boolean;
|
|
26
|
-
slippageParamK: bigint;
|
|
27
|
-
slippageParamN: bigint;
|
|
28
|
-
c1: bigint;
|
|
29
|
-
xThreshold: bigint;
|
|
30
|
-
haircutRate: bigint;
|
|
31
|
-
retentionRatio: bigint;
|
|
32
|
-
maxPriceDeviation: bigint;
|
|
33
|
-
};
|
|
34
|
-
export declare type PlatypusAssetState = {
|
|
35
|
-
cash: bigint;
|
|
36
|
-
liability: bigint;
|
|
37
|
-
};
|
|
38
|
-
export declare type PlatypusConfigInfo = {
|
|
39
|
-
poolAddresses: Address[];
|
|
40
|
-
pools: {
|
|
41
|
-
[poolAddress: string]: PlatypusPoolConfigInfo | PlatypusPurePoolConfigInfo | PlatypusAvaxPoolConfigInfo;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
export declare type PlatypusPoolConfigInfo = {
|
|
45
|
-
oracleType: PlatypusOracleType.ChainLink;
|
|
46
|
-
priceOracleAddress: Address;
|
|
47
|
-
tokenAddresses: Address[];
|
|
48
|
-
tokens: {
|
|
49
|
-
[tokenAddress: string]: {
|
|
50
|
-
tokenSymbol: string;
|
|
51
|
-
tokenDecimals: number;
|
|
52
|
-
assetAddress: Address;
|
|
53
|
-
chainlink: {
|
|
54
|
-
proxyAddress: Address;
|
|
55
|
-
aggregatorAddress: Address;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
export declare type PlatypusPurePoolConfigInfo = {
|
|
61
|
-
oracleType: PlatypusOracleType.None;
|
|
62
|
-
tokenAddresses: Address[];
|
|
63
|
-
tokens: {
|
|
64
|
-
[tokenAddress: string]: {
|
|
65
|
-
tokenSymbol: string;
|
|
66
|
-
tokenDecimals: number;
|
|
67
|
-
assetAddress: Address;
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
export declare type PlatypusAvaxPoolConfigInfo = {
|
|
72
|
-
oracleType: PlatypusOracleType.StakedAvax;
|
|
73
|
-
priceOracleAddress: Address;
|
|
74
|
-
tokenAddresses: Address[];
|
|
75
|
-
tokens: {
|
|
76
|
-
[tokenAddress: string]: {
|
|
77
|
-
tokenSymbol: string;
|
|
78
|
-
tokenDecimals: number;
|
|
79
|
-
assetAddress: Address;
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
export declare type PlatypusData = {
|
|
84
|
-
pool: Address;
|
|
85
|
-
};
|
|
86
|
-
export declare type DexParams = {
|
|
87
|
-
pools: {
|
|
88
|
-
address: Address;
|
|
89
|
-
name: string;
|
|
90
|
-
oracleType: PlatypusOracleType;
|
|
91
|
-
}[];
|
|
92
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlatypusOracleType = void 0;
|
|
4
|
-
var PlatypusOracleType;
|
|
5
|
-
(function (PlatypusOracleType) {
|
|
6
|
-
PlatypusOracleType["None"] = "None";
|
|
7
|
-
PlatypusOracleType["ChainLink"] = "ChainLink";
|
|
8
|
-
PlatypusOracleType["StakedAvax"] = "StakedAvax";
|
|
9
|
-
})(PlatypusOracleType = exports.PlatypusOracleType || (exports.PlatypusOracleType = {}));
|
|
10
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/platypus/types.ts"],"names":[],"mappings":";;;AAIA,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,mCAAa,CAAA;IACb,6CAAuB,CAAA;IACvB,+CAAyB,CAAA;AAC3B,CAAC,EAJW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAI7B"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SpiritSwapV3 = void 0;
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const config_1 = require("./config");
|
|
9
|
-
const quickswap_v3_1 = require("./quickswap-v3");
|
|
10
|
-
const config = lodash_1.default.pick(config_1.QuickSwapConfig, ['SpiritSwapV3']).SpiritSwapV3;
|
|
11
|
-
class SpiritSwapV3 extends quickswap_v3_1.QuickSwapV3 {
|
|
12
|
-
// public static dexKeysWithNetwork
|
|
13
|
-
constructor(dexHelper) {
|
|
14
|
-
super(dexHelper, 'spiritswapv3', config[dexHelper.config.data.network].router);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.SpiritSwapV3 = SpiritSwapV3;
|
|
18
|
-
SpiritSwapV3.dexKeys = ['spiritswapv3'];
|
|
19
|
-
//# sourceMappingURL=spiritswap-v3.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spiritswap-v3.js","sourceRoot":"","sources":["../../../src/dex/quickswap/spiritswap-v3.ts"],"names":[],"mappings":";;;;;;AACA,oDAAuB;AACvB,qCAA2C;AAC3C,iDAA6C;AAE7C,MAAM,MAAM,GAAG,gBAAC,CAAC,IAAI,CAAC,wBAAe,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,YAAY,CAAC;AAEtE,MAAa,YAAa,SAAQ,0BAAW;IAG3C,mCAAmC;IACnC,YAAY,SAAqB;QAC/B,KAAK,CACH,SAAS,EACT,cAAc,EACd,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAC7C,CAAC;IACJ,CAAC;;AAVH,oCAWC;AAVQ,oBAAO,GAAG,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { SDaiParams } from './types';
|
|
2
|
-
import { DexConfigMap } from '../../types';
|
|
3
|
-
export declare const SDaiConfig: DexConfigMap<SDaiParams>;
|
|
4
|
-
export declare const Adapters: {
|
|
5
|
-
[chainId: number]: {
|
|
6
|
-
[side: string]: {
|
|
7
|
-
name: string;
|
|
8
|
-
index: number;
|
|
9
|
-
}[];
|
|
10
|
-
};
|
|
11
|
-
};
|
package/build/dex/sdai/config.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Adapters = exports.SDaiConfig = void 0;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
5
|
-
const core_1 = require("@paraswap/core");
|
|
6
|
-
exports.SDaiConfig = {
|
|
7
|
-
sdai: {
|
|
8
|
-
[constants_1.Network.MAINNET]: {
|
|
9
|
-
sdaiAddress: '0x83F20F44975D03b1b09e64809B757c47f942BEeA',
|
|
10
|
-
daiAddress: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
|
11
|
-
potAddress: '0x197E90f9FAD81970bA7976f33CbD77088E5D7cf7',
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
exports.Adapters = {
|
|
16
|
-
[constants_1.Network.MAINNET]: {
|
|
17
|
-
[core_1.SwapSide.SELL]: [{ name: 'Adapter06', index: 1 }],
|
|
18
|
-
[core_1.SwapSide.BUY]: [{ name: 'BuyAdapter02', index: 4 }],
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/sdai/config.ts"],"names":[],"mappings":";;;AAEA,+CAA0C;AAC1C,yCAA0C;AAE7B,QAAA,UAAU,GAA6B;IAClD,IAAI,EAAE;QACJ,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;YACjB,WAAW,EAAE,4CAA4C;YACzD,UAAU,EAAE,4CAA4C;YACxD,UAAU,EAAE,4CAA4C;SACzD;KACF;CACF,CAAC;AAEW,QAAA,QAAQ,GAIjB;IACF,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE;QACjB,CAAC,eAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAClD,CAAC,eAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;KACrD;CACF,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SDAI_REDEEM_GAS_COST = exports.SDAI_DEPOSIT_GAS_COST = void 0;
|
|
4
|
-
exports.SDAI_DEPOSIT_GAS_COST = 165000;
|
|
5
|
-
exports.SDAI_REDEEM_GAS_COST = 90000;
|
|
6
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dex/sdai/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,MAAO,CAAC;AAChC,QAAA,oBAAoB,GAAG,KAAM,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/* eslint-disable no-console */
|
|
7
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
|
8
|
-
dotenv_1.default.config();
|
|
9
|
-
const constants_1 = require("../../../constants");
|
|
10
|
-
const dex_helper_1 = require("../../../dex-helper");
|
|
11
|
-
const ethers_1 = require("ethers");
|
|
12
|
-
const sdai_1 = require("../sdai");
|
|
13
|
-
const config_1 = require("../config");
|
|
14
|
-
const utils_1 = require("../utils");
|
|
15
|
-
const abi_1 = require("@ethersproject/abi");
|
|
16
|
-
const pot_json_1 = __importDefault(require("../../../abi/maker-psm/pot.json"));
|
|
17
|
-
const network = constants_1.Network.MAINNET;
|
|
18
|
-
const dexKey = 'sdai';
|
|
19
|
-
const { potAddress } = config_1.SDaiConfig[dexKey][network];
|
|
20
|
-
const blockHeaders = {};
|
|
21
|
-
const dexHelper = new dex_helper_1.DummyDexHelper(network);
|
|
22
|
-
const logger = dexHelper.getLogger(dexKey);
|
|
23
|
-
function preprocessField(value) {
|
|
24
|
-
if (typeof value === 'bigint' ||
|
|
25
|
-
typeof value === 'number' ||
|
|
26
|
-
ethers_1.ethers.BigNumber.isBigNumber(value)) {
|
|
27
|
-
return value.toString();
|
|
28
|
-
}
|
|
29
|
-
return value;
|
|
30
|
-
}
|
|
31
|
-
function compareAndLogDifferences(obj1, obj2, keyNames, checkEachKey = false) {
|
|
32
|
-
let isValid = true;
|
|
33
|
-
let keys = keyNames;
|
|
34
|
-
if (checkEachKey) {
|
|
35
|
-
// find common keys
|
|
36
|
-
const keys1 = Object.keys(obj1);
|
|
37
|
-
const keys2 = new Set(Object.keys(obj2));
|
|
38
|
-
keys = keys1.filter(key => keys2.has(key));
|
|
39
|
-
}
|
|
40
|
-
for (let fieldName of keys) {
|
|
41
|
-
const value1 = preprocessField(obj1[fieldName]);
|
|
42
|
-
const value2 = preprocessField(obj2[fieldName]);
|
|
43
|
-
if (value1 !== value2) {
|
|
44
|
-
console.log(`${fieldName.toString()} mismatch: actual: ${value1} vs pool: ${value2}`);
|
|
45
|
-
isValid = false;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return isValid;
|
|
49
|
-
}
|
|
50
|
-
async function isPoolStateEqualToReal(state, blockNumber) {
|
|
51
|
-
const expected = await (0, utils_1.getOnChainState)(dexHelper.multiContract, potAddress, new abi_1.Interface(pot_json_1.default), blockNumber);
|
|
52
|
-
const isValidState = compareAndLogDifferences(state, expected, [
|
|
53
|
-
'rho',
|
|
54
|
-
'dsr',
|
|
55
|
-
'dsr',
|
|
56
|
-
]);
|
|
57
|
-
return isValidState;
|
|
58
|
-
}
|
|
59
|
-
async function checkPoolStateForBlockRange(startBlockNumber, endBlockNumber) {
|
|
60
|
-
const network = constants_1.Network.MAINNET;
|
|
61
|
-
const dexKey = 'sdai';
|
|
62
|
-
const dexHelper = new dex_helper_1.DummyDexHelper(network);
|
|
63
|
-
const sdai = new sdai_1.SDai(network, dexKey, dexHelper);
|
|
64
|
-
const pool = await sdai.eventPool;
|
|
65
|
-
const logsToDispatch = await dexHelper.provider.getLogs({
|
|
66
|
-
fromBlock: startBlockNumber,
|
|
67
|
-
toBlock: endBlockNumber,
|
|
68
|
-
address: potAddress,
|
|
69
|
-
});
|
|
70
|
-
console.log(logsToDispatch.length);
|
|
71
|
-
// group logs by block number
|
|
72
|
-
const logsByBlockNumber = {};
|
|
73
|
-
for (let log of logsToDispatch) {
|
|
74
|
-
if (!logsByBlockNumber[log.blockNumber]) {
|
|
75
|
-
logsByBlockNumber[log.blockNumber] = [];
|
|
76
|
-
}
|
|
77
|
-
logsByBlockNumber[log.blockNumber].push(log);
|
|
78
|
-
}
|
|
79
|
-
const sortedBlocks = Object.keys(logsByBlockNumber)
|
|
80
|
-
.map(Number)
|
|
81
|
-
.sort((a, b) => Number(a) - Number(b));
|
|
82
|
-
for (let blockNumber of sortedBlocks) {
|
|
83
|
-
if (!blockHeaders[blockNumber]) {
|
|
84
|
-
blockHeaders[blockNumber] = await dexHelper.web3Provider.eth.getBlock(blockNumber);
|
|
85
|
-
}
|
|
86
|
-
await pool?.update(logsByBlockNumber[blockNumber], {
|
|
87
|
-
[blockNumber]: blockHeaders[blockNumber],
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
const state = pool?.getState(startBlockNumber);
|
|
91
|
-
return isPoolStateEqualToReal(state, endBlockNumber);
|
|
92
|
-
}
|
|
93
|
-
async function main() {
|
|
94
|
-
// use findBreakingBlock to find the block where the state is broken
|
|
95
|
-
// console.log(await findBreakingBlock(startBlockNumber, endBlockNumber));
|
|
96
|
-
// previously broken block 150502863
|
|
97
|
-
console.log(await checkPoolStateForBlockRange(19199247 - 10000, 19199247));
|
|
98
|
-
}
|
|
99
|
-
main()
|
|
100
|
-
.then(() => console.log('Done'))
|
|
101
|
-
.catch(e => console.error(e));
|
|
102
|
-
//# sourceMappingURL=validate-state.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-state.js","sourceRoot":"","sources":["../../../../src/dex/sdai/scripts/validate-state.ts"],"names":[],"mappings":";;;;;AAAA,+BAA+B;AAC/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