@paraswap/dex-lib 5.0.1-new-dexs-encoding.0 → 5.0.2-native-dex-math.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/abi/BProtocol.json +1155 -0
- package/build/abi/Jarvis.json +1172 -0
- package/build/abi/MStableAsset.json +1545 -0
- package/build/abi/OneInchLp.json +1304 -0
- package/build/abi/Onebit.json +736 -0
- package/build/abi/Shell.json +1294 -0
- package/build/abi/TraderJoeV2Router.json +50 -0
- package/build/abi/idle-dao/idle-cdo-factory.json +38 -0
- package/build/abi/idle-dao/idle-cdo.json +1245 -0
- package/build/abi/infusion/InfusionFactory.json +147 -0
- package/build/abi/infusion/InfusionPair.json +658 -0
- package/build/abi/infusion/InfusionRouter.json +442 -0
- package/build/abi/maker-psm/pot.json +322 -0
- package/build/abi/maker-psm/psm.json +243 -0
- package/build/abi/maker-psm/vat.json +363 -0
- package/build/abi/nomiswap-v2/nomiswap-v2-pool.json +773 -0
- package/build/abi/quick-perps/fast-price-events.json +70 -0
- package/build/abi/quick-perps/fast-price-feed.json +741 -0
- package/build/abi/quick-perps/reader.json +313 -0
- package/build/abi/quick-perps/vault-price-feed.json +323 -0
- package/build/abi/quick-perps/vault.json +1953 -0
- package/build/abi/uniswap-v2/excalibur-pool.json +881 -0
- package/build/abi/uniswap-v2/mdex-factory.json +759 -0
- package/build/abi/wUSDM.json +757 -0
- package/build/abi/zrx.v2.json +1967 -0
- package/build/abi/zrx.v3.json +3454 -0
- package/build/abi/zrx.v4.json +2193 -0
- package/build/dex/OneInchLp.d.ts +24 -0
- package/build/dex/OneInchLp.js +43 -0
- package/build/dex/OneInchLp.js.map +1 -0
- package/build/dex/aave-gsm/config.js +2 -2
- package/build/dex/bProtocol/bProtocol.d.ts +15 -0
- package/build/dex/bProtocol/bProtocol.js +56 -0
- package/build/dex/bProtocol/bProtocol.js.map +1 -0
- package/build/dex/bProtocol/types.d.ts +11 -0
- package/build/dex/bProtocol/types.js +8 -0
- package/build/dex/bProtocol/types.js.map +1 -0
- package/build/dex/ekubo/pools/base-pool.d.ts +47 -0
- package/build/dex/ekubo/pools/base-pool.js +184 -0
- package/build/dex/ekubo/pools/base-pool.js.map +1 -0
- package/build/dex/ekubo/pools/iface.d.ts +46 -0
- package/build/dex/ekubo/pools/iface.js +75 -0
- package/build/dex/ekubo/pools/iface.js.map +1 -0
- package/build/dex/ekubo/pools/math/price.d.ts +7 -0
- package/build/dex/ekubo/pools/math/price.js +112 -0
- package/build/dex/ekubo/pools/math/price.js.map +1 -0
- package/build/dex/ekubo/pools/oracle-pool.d.ts +10 -0
- package/build/dex/ekubo/pools/oracle-pool.js +19 -0
- package/build/dex/ekubo/pools/oracle-pool.js.map +1 -0
- package/build/dex/ekubo/pools/pool-utils.d.ts +44 -0
- package/build/dex/ekubo/pools/pool-utils.js +240 -0
- package/build/dex/ekubo/pools/pool-utils.js.map +1 -0
- package/build/dex/idex.d.ts +3 -3
- package/build/dex/idle-dao/config.d.ts +5 -0
- package/build/dex/idle-dao/config.js +24 -0
- package/build/dex/idle-dao/config.js.map +1 -0
- package/build/dex/idle-dao/idle-dao.d.ts +42 -0
- package/build/dex/idle-dao/idle-dao.js +279 -0
- package/build/dex/idle-dao/idle-dao.js.map +1 -0
- package/build/dex/idle-dao/token_list.d.ts +4 -0
- package/build/dex/idle-dao/token_list.js +289 -0
- package/build/dex/idle-dao/token_list.js.map +1 -0
- package/build/dex/idle-dao/tokens.d.ts +9 -0
- package/build/dex/idle-dao/tokens.js +68 -0
- package/build/dex/idle-dao/tokens.js.map +1 -0
- package/build/dex/idle-dao/types.d.ts +35 -0
- package/build/dex/idle-dao/types.js +11 -0
- package/build/dex/idle-dao/types.js.map +1 -0
- package/build/dex/idle-dao/utils.d.ts +8 -0
- package/build/dex/idle-dao/utils.js +149 -0
- package/build/dex/idle-dao/utils.js.map +1 -0
- package/build/dex/infusion/config.d.ts +3 -0
- package/build/dex/infusion/config.js +20 -0
- package/build/dex/infusion/config.js.map +1 -0
- package/build/dex/infusion/infusion-stable-pool.d.ts +4 -0
- package/build/dex/infusion/infusion-stable-pool.js +74 -0
- package/build/dex/infusion/infusion-stable-pool.js.map +1 -0
- package/build/dex/infusion/infusion.d.ts +51 -0
- package/build/dex/infusion/infusion.js +500 -0
- package/build/dex/infusion/infusion.js.map +1 -0
- package/build/dex/infusion/types.d.ts +45 -0
- package/build/dex/infusion/types.js.map +1 -0
- package/build/dex/infusion/utils/isStablePair.d.ts +2 -0
- package/build/dex/infusion/utils/isStablePair.js +18 -0
- package/build/dex/infusion/utils/isStablePair.js.map +1 -0
- package/build/dex/jarvis.d.ts +56 -0
- package/build/dex/jarvis.js +163 -0
- package/build/dex/jarvis.js.map +1 -0
- package/build/dex/mStable.d.ts +44 -0
- package/build/dex/mStable.js +75 -0
- package/build/dex/mStable.js.map +1 -0
- package/build/dex/maker-psm/config.d.ts +11 -0
- package/build/dex/maker-psm/config.js +53 -0
- package/build/dex/maker-psm/config.js.map +1 -0
- package/build/dex/maker-psm/maker-psm.d.ts +103 -0
- package/build/dex/maker-psm/maker-psm.js +493 -0
- package/build/dex/maker-psm/maker-psm.js.map +1 -0
- package/build/dex/maker-psm/types.d.ts +39 -0
- package/build/{generic-swap-transaction-builder/dex-encoder/ports.js → dex/maker-psm/types.js} +1 -1
- package/build/dex/maker-psm/types.js.map +1 -0
- package/build/dex/metric/metric.d.ts +2 -2
- package/build/dex/metric/metric.js +2 -5
- package/build/dex/metric/metric.js.map +1 -1
- package/build/dex/onebit/onebit.d.ts +16 -0
- package/build/dex/onebit/onebit.js +61 -0
- package/build/dex/onebit/onebit.js.map +1 -0
- package/build/dex/onebit/types.d.ts +14 -0
- package/build/dex/onebit/types.js +8 -0
- package/build/dex/onebit/types.js.map +1 -0
- package/build/dex/pancakeswap-infinity/encoder.js +16 -12
- package/build/dex/pancakeswap-infinity/encoder.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3-pool.d.ts +2 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3-pool.js +5 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3-pool.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3.d.ts +6 -3
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js +85 -9
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js.map +1 -1
- package/build/dex/quick-perps/config.d.ts +11 -0
- package/build/dex/quick-perps/config.js +27 -0
- package/build/dex/quick-perps/config.js.map +1 -0
- package/build/dex/quick-perps/fast-price-feed.d.ts +26 -0
- package/build/dex/quick-perps/fast-price-feed.js +184 -0
- package/build/dex/quick-perps/fast-price-feed.js.map +1 -0
- package/build/dex/quick-perps/pool.d.ts +21 -0
- package/build/dex/quick-perps/pool.js +229 -0
- package/build/dex/quick-perps/pool.js.map +1 -0
- package/build/dex/quick-perps/quick-perps.d.ts +53 -0
- package/build/dex/quick-perps/quick-perps.js +247 -0
- package/build/dex/quick-perps/quick-perps.js.map +1 -0
- package/build/dex/quick-perps/types.d.ts +98 -0
- package/build/{executor/encoding-types.js → dex/quick-perps/types.js} +1 -1
- package/build/dex/quick-perps/types.js.map +1 -0
- package/build/dex/quick-perps/usdq.d.ts +15 -0
- package/build/dex/quick-perps/usdq.js +62 -0
- package/build/dex/quick-perps/usdq.js.map +1 -0
- package/build/dex/quick-perps/vault-price-feed.d.ts +43 -0
- package/build/dex/quick-perps/vault-price-feed.js +203 -0
- package/build/dex/quick-perps/vault-price-feed.js.map +1 -0
- package/build/dex/quick-perps/vault-utils.d.ts +8 -0
- package/build/dex/quick-perps/vault-utils.js +42 -0
- package/build/dex/quick-perps/vault-utils.js.map +1 -0
- package/build/dex/quick-perps/vault.d.ts +46 -0
- package/build/dex/quick-perps/vault.js +182 -0
- package/build/dex/quick-perps/vault.js.map +1 -0
- package/build/dex/se-vlr/config.d.ts +3 -0
- package/build/dex/se-vlr/config.js +24 -0
- package/build/dex/se-vlr/config.js.map +1 -0
- package/build/dex/se-vlr/se-vlr-pool.d.ts +39 -0
- package/build/dex/se-vlr/se-vlr-pool.js +70 -0
- package/build/dex/se-vlr/se-vlr-pool.js.map +1 -0
- package/build/dex/se-vlr/se-vlr.d.ts +35 -0
- package/build/dex/se-vlr/se-vlr.js +131 -0
- package/build/dex/se-vlr/se-vlr.js.map +1 -0
- package/build/dex/se-vlr/types.d.ts +6 -0
- package/build/dex/se-vlr/types.js +3 -0
- package/build/dex/se-vlr/types.js.map +1 -0
- package/build/dex/shell.d.ts +25 -0
- package/build/dex/shell.js +41 -0
- package/build/dex/shell.js.map +1 -0
- package/build/dex/simple-exchange.d.ts +1 -1
- package/build/dex/simple-exchange.js +1 -1
- package/build/dex/simple-exchange.js.map +1 -1
- package/build/dex/solidly/forks-override/aerodrome.d.ts +14 -0
- package/build/dex/solidly/forks-override/aerodrome.js +46 -0
- package/build/dex/solidly/forks-override/aerodrome.js.map +1 -0
- package/build/dex/solidly/forks-override/chronos.d.ts +23 -0
- package/build/dex/solidly/forks-override/chronos.js +141 -0
- package/build/dex/solidly/forks-override/chronos.js.map +1 -0
- package/build/dex/solidly/forks-override/usdfi.d.ts +8 -0
- package/build/dex/solidly/forks-override/usdfi.js +15 -0
- package/build/dex/solidly/forks-override/usdfi.js.map +1 -0
- package/build/dex/solidly/forks-override/velocimeter.d.ts +23 -0
- package/build/dex/solidly/forks-override/velocimeter.js +77 -0
- package/build/dex/solidly/forks-override/velocimeter.js.map +1 -0
- package/build/dex/solidly-v3/solidly-v3-pool.d.ts +3 -0
- package/build/dex/solidly-v3/solidly-v3-pool.js +8 -0
- package/build/dex/solidly-v3/solidly-v3-pool.js.map +1 -1
- package/build/dex/solidly-v3/solidly-v3.d.ts +5 -2
- package/build/dex/solidly-v3/solidly-v3.js +84 -8
- package/build/dex/solidly-v3/solidly-v3.js.map +1 -1
- package/build/dex/tessera/types.d.ts +3 -0
- package/build/dex/tessera/types.js +3 -0
- package/build/dex/tessera/types.js.map +1 -0
- package/build/dex/trader-joe-v2.d.ts +40 -0
- package/build/dex/trader-joe-v2.js +74 -0
- package/build/dex/trader-joe-v2.js.map +1 -0
- package/build/dex/uniswap-v2/dfyn.d.ts +19 -0
- package/build/dex/uniswap-v2/dfyn.js +61 -0
- package/build/dex/uniswap-v2/dfyn.js.map +1 -0
- package/build/dex/uniswap-v2/excalibur.d.ts +24 -0
- package/build/dex/uniswap-v2/excalibur.js +47 -0
- package/build/dex/uniswap-v2/excalibur.js.map +1 -0
- package/build/dex/uniswap-v2/mdex.d.ts +24 -0
- package/build/dex/uniswap-v2/mdex.js +50 -0
- package/build/dex/uniswap-v2/mdex.js.map +1 -0
- package/build/dex/uniswap-v2/nomiswap-v2.d.ts +24 -0
- package/build/dex/uniswap-v2/nomiswap-v2.js +57 -0
- package/build/dex/uniswap-v2/nomiswap-v2.js.map +1 -0
- package/build/dex/uniswap-v3/scripts/bench-all-dexes.js +160 -0
- package/build/dex/uniswap-v3/scripts/bench-all-dexes.js.map +1 -0
- package/build/dex/uniswap-v3/scripts/measure-calc-time.js +222 -110
- package/build/dex/uniswap-v3/scripts/measure-calc-time.js.map +1 -1
- package/build/dex/uniswap-v3/types.d.ts +1 -0
- package/build/dex/uniswap-v3/types.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3-new.d.ts +94 -0
- package/build/dex/uniswap-v3/uniswap-v3-new.js +923 -0
- package/build/dex/uniswap-v3/uniswap-v3-new.js.map +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-pool.d.ts +2 -0
- package/build/dex/uniswap-v3/uniswap-v3-pool.js +5 -0
- package/build/dex/uniswap-v3/uniswap-v3-pool.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.d.ts +11 -3
- package/build/dex/uniswap-v3/uniswap-v3.js +86 -9
- package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
- package/build/dex/uniswap-v4/contract-math/Position.d.ts +3 -0
- package/build/dex/uniswap-v4/contract-math/Position.js +10 -0
- package/build/dex/uniswap-v4/contract-math/Position.js.map +1 -0
- package/build/dex/uniswap-v4/types.d.ts +1 -0
- package/build/dex/uniswap-v4/uniswap-v4-pool-manager.d.ts +2 -0
- package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js +3 -0
- package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js.map +1 -1
- package/build/dex/uniswap-v4/uniswap-v4-pool.d.ts +3 -0
- package/build/dex/uniswap-v4/uniswap-v4-pool.js +18 -0
- package/build/dex/uniswap-v4/uniswap-v4-pool.js.map +1 -1
- package/build/dex/uniswap-v4/uniswap-v4.d.ts +3 -1
- package/build/dex/uniswap-v4/uniswap-v4.js +74 -14
- package/build/dex/uniswap-v4/uniswap-v4.js.map +1 -1
- package/build/dex/usual-bond/config.d.ts +3 -0
- package/build/dex/usual-bond/config.js +13 -0
- package/build/dex/usual-bond/config.js.map +1 -0
- package/build/dex/usual-bond/types.d.ts +7 -0
- package/build/dex/usual-bond/types.js +3 -0
- package/build/dex/usual-bond/types.js.map +1 -0
- package/build/dex/usual-bond/usual-bond.d.ts +35 -0
- package/build/dex/usual-bond/usual-bond.js +176 -0
- package/build/dex/usual-bond/usual-bond.js.map +1 -0
- package/build/dex/wusdm/config.d.ts +3 -0
- package/build/dex/wusdm/config.js +43 -0
- package/build/dex/wusdm/config.js.map +1 -0
- package/build/dex/wusdm/constants.d.ts +2 -0
- package/build/dex/wusdm/constants.js +6 -0
- package/build/dex/wusdm/constants.js.map +1 -0
- package/build/dex/wusdm/types.d.ts +18 -0
- package/build/dex/wusdm/types.js +11 -0
- package/build/dex/wusdm/types.js.map +1 -0
- package/build/dex/wusdm/wusdm-pool.d.ts +21 -0
- package/build/dex/wusdm/wusdm-pool.js +74 -0
- package/build/dex/wusdm/wusdm-pool.js.map +1 -0
- package/build/dex/wusdm/wusdm.d.ts +46 -0
- package/build/dex/wusdm/wusdm.js +243 -0
- package/build/dex/wusdm/wusdm.js.map +1 -0
- package/build/dex/zerox/config.d.ts +2 -0
- package/build/dex/zerox/config.js +33 -0
- package/build/dex/zerox/config.js.map +1 -0
- package/build/dex/zerox/index.d.ts +22 -0
- package/build/dex/zerox/index.js +225 -0
- package/build/dex/zerox/index.js.map +1 -0
- package/build/dex/zerox/order.d.ts +88 -0
- package/build/dex/zerox/order.js +53 -0
- package/build/dex/zerox/order.js.map +1 -0
- package/build/dex/zerox/types.d.ts +73 -0
- package/build/dex/zerox/types.js +21 -0
- package/build/dex/zerox/types.js.map +1 -0
- package/build/generic-swap-transaction-builder.d.ts +4 -6
- package/build/generic-swap-transaction-builder.js +6 -8
- package/build/generic-swap-transaction-builder.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js.map +1 -1
- package/build/pricing-helper.d.ts +1 -1
- package/build/pricing-helper.js +2 -2
- package/build/pricing-helper.js.map +1 -1
- package/build/types.d.ts +0 -3
- package/native/Cargo.lock +331 -0
- package/native/Cargo.toml +22 -0
- package/native/build.rs +5 -0
- package/native/package-lock.json +32 -0
- package/native/package.json +20 -0
- package/native/src/config.rs +73 -0
- package/native/src/lib.rs +528 -0
- package/native/src/math/bit_math.rs +177 -0
- package/native/src/math/full_math.rs +217 -0
- package/native/src/math/liquidity_math.rs +72 -0
- package/native/src/math/mod.rs +10 -0
- package/native/src/math/oracle.rs +493 -0
- package/native/src/math/sqrt_price_math.rs +272 -0
- package/native/src/math/swap_math.rs +306 -0
- package/native/src/math/tick.rs +239 -0
- package/native/src/math/tick_bitmap.rs +312 -0
- package/native/src/math/tick_math.rs +321 -0
- package/native/src/math/unsafe_math.rs +67 -0
- package/native/src/pool_state.rs +41 -0
- package/native/src/query_outputs.rs +379 -0
- package/native/src/v4_query_outputs.rs +255 -0
- package/package.json +2 -1
- package/build/abi/pancakeswap-infinity/cl-pool-manager.json +0 -80
- package/build/dex/fluid-dex/scripts/measure-calc-time.js +0 -178
- package/build/dex/fluid-dex/scripts/measure-calc-time.js.map +0 -1
- package/build/dex/uniswap-v4/api-go/compare-pricing.d.ts +0 -1
- package/build/dex/uniswap-v4/api-go/compare-pricing.js +0 -187
- package/build/dex/uniswap-v4/api-go/compare-pricing.js.map +0 -1
- package/build/dex/uniswap-v4/api-go/compare-states.d.ts +0 -1
- package/build/dex/uniswap-v4/api-go/compare-states.js +0 -149
- package/build/dex/uniswap-v4/api-go/compare-states.js.map +0 -1
- package/build/dex/uniswap-v4/api-go/fetch-pool-key.d.ts +0 -0
- package/build/dex/uniswap-v4/api-go/fetch-pool-key.js +0 -140
- package/build/dex/uniswap-v4/api-go/fetch-pool-key.js.map +0 -1
- package/build/executor/__test-utils__/snapshot-test-helpers.d.ts +0 -10
- package/build/executor/__test-utils__/snapshot-test-helpers.js +0 -72
- package/build/executor/__test-utils__/snapshot-test-helpers.js.map +0 -1
- package/build/executor/address-utils.d.ts +0 -2
- package/build/executor/address-utils.js +0 -7
- package/build/executor/address-utils.js.map +0 -1
- package/build/executor/approval.d.ts +0 -9
- package/build/executor/approval.js +0 -29
- package/build/executor/approval.js.map +0 -1
- package/build/executor/encoding-context.d.ts +0 -4
- package/build/executor/encoding-context.js +0 -54
- package/build/executor/encoding-context.js.map +0 -1
- package/build/executor/encoding-types.d.ts +0 -75
- package/build/executor/encoding-types.js.map +0 -1
- package/build/executor/factory.d.ts +0 -4
- package/build/executor/factory.js +0 -23
- package/build/executor/factory.js.map +0 -1
- package/build/executor/route-plan.d.ts +0 -8
- package/build/executor/route-plan.js +0 -109
- package/build/executor/route-plan.js.map +0 -1
- package/build/generic-swap-transaction-builder/dex-encoder/direct-methods.d.ts +0 -6
- package/build/generic-swap-transaction-builder/dex-encoder/direct-methods.js +0 -39
- package/build/generic-swap-transaction-builder/dex-encoder/direct-methods.js.map +0 -1
- package/build/generic-swap-transaction-builder/dex-encoder/index.d.ts +0 -4
- package/build/generic-swap-transaction-builder/dex-encoder/index.js +0 -21
- package/build/generic-swap-transaction-builder/dex-encoder/index.js.map +0 -1
- package/build/generic-swap-transaction-builder/dex-encoder/ports.d.ts +0 -26
- package/build/generic-swap-transaction-builder/dex-encoder/ports.js.map +0 -1
- package/build/generic-swap-transaction-builder/dex-encoder/ts-adapter.d.ts +0 -22
- package/build/generic-swap-transaction-builder/dex-encoder/ts-adapter.js +0 -299
- package/build/generic-swap-transaction-builder/dex-encoder/ts-adapter.js.map +0 -1
- package/build/generic-swap-transaction-builder/dex-encoder/types.d.ts +0 -207
- package/build/generic-swap-transaction-builder/dex-encoder/types.js +0 -194
- package/build/generic-swap-transaction-builder/dex-encoder/types.js.map +0 -1
- package/build/generic-swap-transaction-builder/orchestration.d.ts +0 -65
- package/build/generic-swap-transaction-builder/orchestration.js +0 -198
- package/build/generic-swap-transaction-builder/orchestration.js.map +0 -1
- package/build/generic-swap-transaction-builder/resolved/build-transaction.d.ts +0 -13
- package/build/generic-swap-transaction-builder/resolved/build-transaction.js +0 -343
- package/build/generic-swap-transaction-builder/resolved/build-transaction.js.map +0 -1
- package/build/generic-swap-transaction-builder/resolved/index.d.ts +0 -4
- package/build/generic-swap-transaction-builder/resolved/index.js +0 -21
- package/build/generic-swap-transaction-builder/resolved/index.js.map +0 -1
- package/build/generic-swap-transaction-builder/resolved/route-plan.d.ts +0 -2
- package/build/generic-swap-transaction-builder/resolved/route-plan.js +0 -11
- package/build/generic-swap-transaction-builder/resolved/route-plan.js.map +0 -1
- package/build/generic-swap-transaction-builder/resolved/types.d.ts +0 -67
- package/build/generic-swap-transaction-builder/resolved/types.js.map +0 -1
- package/build/generic-swap-transaction-builder/resolved/validation.d.ts +0 -10
- package/build/generic-swap-transaction-builder/resolved/validation.js +0 -69
- package/build/generic-swap-transaction-builder/resolved/validation.js.map +0 -1
- /package/build/{generic-swap-transaction-builder/resolved → dex/infusion}/types.js +0 -0
- /package/build/dex/{fluid-dex/scripts/measure-calc-time.d.ts → uniswap-v3/scripts/bench-all-dexes.d.ts} +0 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "aho-corasick"
|
|
7
|
+
version = "1.1.4"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"memchr",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[[package]]
|
|
15
|
+
name = "bitflags"
|
|
16
|
+
version = "2.11.0"
|
|
17
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
18
|
+
checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
|
|
19
|
+
|
|
20
|
+
[[package]]
|
|
21
|
+
name = "cfg-if"
|
|
22
|
+
version = "1.0.4"
|
|
23
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
24
|
+
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
|
25
|
+
|
|
26
|
+
[[package]]
|
|
27
|
+
name = "convert_case"
|
|
28
|
+
version = "0.6.0"
|
|
29
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
30
|
+
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
|
|
31
|
+
dependencies = [
|
|
32
|
+
"unicode-segmentation",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[[package]]
|
|
36
|
+
name = "crossbeam-deque"
|
|
37
|
+
version = "0.8.6"
|
|
38
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
39
|
+
checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
|
|
40
|
+
dependencies = [
|
|
41
|
+
"crossbeam-epoch",
|
|
42
|
+
"crossbeam-utils",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[[package]]
|
|
46
|
+
name = "crossbeam-epoch"
|
|
47
|
+
version = "0.9.18"
|
|
48
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
49
|
+
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
|
|
50
|
+
dependencies = [
|
|
51
|
+
"crossbeam-utils",
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
[[package]]
|
|
55
|
+
name = "crossbeam-utils"
|
|
56
|
+
version = "0.8.21"
|
|
57
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
58
|
+
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
|
59
|
+
|
|
60
|
+
[[package]]
|
|
61
|
+
name = "ctor"
|
|
62
|
+
version = "0.2.9"
|
|
63
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
64
|
+
checksum = "32a2785755761f3ddc1492979ce1e48d2c00d09311c39e4466429188f3dd6501"
|
|
65
|
+
dependencies = [
|
|
66
|
+
"quote",
|
|
67
|
+
"syn",
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
[[package]]
|
|
71
|
+
name = "either"
|
|
72
|
+
version = "1.15.0"
|
|
73
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
74
|
+
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
|
75
|
+
|
|
76
|
+
[[package]]
|
|
77
|
+
name = "ethnum"
|
|
78
|
+
version = "1.5.2"
|
|
79
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
80
|
+
checksum = "ca81e6b4777c89fd810c25a4be2b1bd93ea034fbe58e6a75216a34c6b82c539b"
|
|
81
|
+
|
|
82
|
+
[[package]]
|
|
83
|
+
name = "itoa"
|
|
84
|
+
version = "1.0.18"
|
|
85
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
86
|
+
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
|
87
|
+
|
|
88
|
+
[[package]]
|
|
89
|
+
name = "libloading"
|
|
90
|
+
version = "0.8.9"
|
|
91
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
92
|
+
checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
|
|
93
|
+
dependencies = [
|
|
94
|
+
"cfg-if",
|
|
95
|
+
"windows-link",
|
|
96
|
+
]
|
|
97
|
+
|
|
98
|
+
[[package]]
|
|
99
|
+
name = "memchr"
|
|
100
|
+
version = "2.8.0"
|
|
101
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
102
|
+
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
|
|
103
|
+
|
|
104
|
+
[[package]]
|
|
105
|
+
name = "napi"
|
|
106
|
+
version = "2.16.17"
|
|
107
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
108
|
+
checksum = "55740c4ae1d8696773c78fdafd5d0e5fe9bc9f1b071c7ba493ba5c413a9184f3"
|
|
109
|
+
dependencies = [
|
|
110
|
+
"bitflags",
|
|
111
|
+
"ctor",
|
|
112
|
+
"napi-derive",
|
|
113
|
+
"napi-sys",
|
|
114
|
+
"once_cell",
|
|
115
|
+
"serde",
|
|
116
|
+
"serde_json",
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
[[package]]
|
|
120
|
+
name = "napi-build"
|
|
121
|
+
version = "2.3.1"
|
|
122
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
123
|
+
checksum = "d376940fd5b723c6893cd1ee3f33abbfd86acb1cd1ec079f3ab04a2a3bc4d3b1"
|
|
124
|
+
|
|
125
|
+
[[package]]
|
|
126
|
+
name = "napi-derive"
|
|
127
|
+
version = "2.16.13"
|
|
128
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
129
|
+
checksum = "7cbe2585d8ac223f7d34f13701434b9d5f4eb9c332cccce8dee57ea18ab8ab0c"
|
|
130
|
+
dependencies = [
|
|
131
|
+
"cfg-if",
|
|
132
|
+
"convert_case",
|
|
133
|
+
"napi-derive-backend",
|
|
134
|
+
"proc-macro2",
|
|
135
|
+
"quote",
|
|
136
|
+
"syn",
|
|
137
|
+
]
|
|
138
|
+
|
|
139
|
+
[[package]]
|
|
140
|
+
name = "napi-derive-backend"
|
|
141
|
+
version = "1.0.75"
|
|
142
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
143
|
+
checksum = "1639aaa9eeb76e91c6ae66da8ce3e89e921cd3885e99ec85f4abacae72fc91bf"
|
|
144
|
+
dependencies = [
|
|
145
|
+
"convert_case",
|
|
146
|
+
"once_cell",
|
|
147
|
+
"proc-macro2",
|
|
148
|
+
"quote",
|
|
149
|
+
"regex",
|
|
150
|
+
"semver",
|
|
151
|
+
"syn",
|
|
152
|
+
]
|
|
153
|
+
|
|
154
|
+
[[package]]
|
|
155
|
+
name = "napi-sys"
|
|
156
|
+
version = "2.4.0"
|
|
157
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
158
|
+
checksum = "427802e8ec3a734331fec1035594a210ce1ff4dc5bc1950530920ab717964ea3"
|
|
159
|
+
dependencies = [
|
|
160
|
+
"libloading",
|
|
161
|
+
]
|
|
162
|
+
|
|
163
|
+
[[package]]
|
|
164
|
+
name = "once_cell"
|
|
165
|
+
version = "1.21.4"
|
|
166
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
167
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
168
|
+
|
|
169
|
+
[[package]]
|
|
170
|
+
name = "proc-macro2"
|
|
171
|
+
version = "1.0.106"
|
|
172
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
173
|
+
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
|
174
|
+
dependencies = [
|
|
175
|
+
"unicode-ident",
|
|
176
|
+
]
|
|
177
|
+
|
|
178
|
+
[[package]]
|
|
179
|
+
name = "quote"
|
|
180
|
+
version = "1.0.45"
|
|
181
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
182
|
+
checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
|
|
183
|
+
dependencies = [
|
|
184
|
+
"proc-macro2",
|
|
185
|
+
]
|
|
186
|
+
|
|
187
|
+
[[package]]
|
|
188
|
+
name = "rayon"
|
|
189
|
+
version = "1.11.0"
|
|
190
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
191
|
+
checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f"
|
|
192
|
+
dependencies = [
|
|
193
|
+
"either",
|
|
194
|
+
"rayon-core",
|
|
195
|
+
]
|
|
196
|
+
|
|
197
|
+
[[package]]
|
|
198
|
+
name = "rayon-core"
|
|
199
|
+
version = "1.13.0"
|
|
200
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
201
|
+
checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"
|
|
202
|
+
dependencies = [
|
|
203
|
+
"crossbeam-deque",
|
|
204
|
+
"crossbeam-utils",
|
|
205
|
+
]
|
|
206
|
+
|
|
207
|
+
[[package]]
|
|
208
|
+
name = "regex"
|
|
209
|
+
version = "1.12.3"
|
|
210
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
211
|
+
checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276"
|
|
212
|
+
dependencies = [
|
|
213
|
+
"aho-corasick",
|
|
214
|
+
"memchr",
|
|
215
|
+
"regex-automata",
|
|
216
|
+
"regex-syntax",
|
|
217
|
+
]
|
|
218
|
+
|
|
219
|
+
[[package]]
|
|
220
|
+
name = "regex-automata"
|
|
221
|
+
version = "0.4.14"
|
|
222
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
223
|
+
checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f"
|
|
224
|
+
dependencies = [
|
|
225
|
+
"aho-corasick",
|
|
226
|
+
"memchr",
|
|
227
|
+
"regex-syntax",
|
|
228
|
+
]
|
|
229
|
+
|
|
230
|
+
[[package]]
|
|
231
|
+
name = "regex-syntax"
|
|
232
|
+
version = "0.8.10"
|
|
233
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
234
|
+
checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
|
|
235
|
+
|
|
236
|
+
[[package]]
|
|
237
|
+
name = "semver"
|
|
238
|
+
version = "1.0.27"
|
|
239
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
240
|
+
checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
|
|
241
|
+
|
|
242
|
+
[[package]]
|
|
243
|
+
name = "serde"
|
|
244
|
+
version = "1.0.228"
|
|
245
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
246
|
+
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
|
247
|
+
dependencies = [
|
|
248
|
+
"serde_core",
|
|
249
|
+
"serde_derive",
|
|
250
|
+
]
|
|
251
|
+
|
|
252
|
+
[[package]]
|
|
253
|
+
name = "serde_core"
|
|
254
|
+
version = "1.0.228"
|
|
255
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
256
|
+
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
|
257
|
+
dependencies = [
|
|
258
|
+
"serde_derive",
|
|
259
|
+
]
|
|
260
|
+
|
|
261
|
+
[[package]]
|
|
262
|
+
name = "serde_derive"
|
|
263
|
+
version = "1.0.228"
|
|
264
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
265
|
+
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
|
266
|
+
dependencies = [
|
|
267
|
+
"proc-macro2",
|
|
268
|
+
"quote",
|
|
269
|
+
"syn",
|
|
270
|
+
]
|
|
271
|
+
|
|
272
|
+
[[package]]
|
|
273
|
+
name = "serde_json"
|
|
274
|
+
version = "1.0.149"
|
|
275
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
276
|
+
checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
|
|
277
|
+
dependencies = [
|
|
278
|
+
"itoa",
|
|
279
|
+
"memchr",
|
|
280
|
+
"serde",
|
|
281
|
+
"serde_core",
|
|
282
|
+
"zmij",
|
|
283
|
+
]
|
|
284
|
+
|
|
285
|
+
[[package]]
|
|
286
|
+
name = "syn"
|
|
287
|
+
version = "2.0.117"
|
|
288
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
289
|
+
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
|
|
290
|
+
dependencies = [
|
|
291
|
+
"proc-macro2",
|
|
292
|
+
"quote",
|
|
293
|
+
"unicode-ident",
|
|
294
|
+
]
|
|
295
|
+
|
|
296
|
+
[[package]]
|
|
297
|
+
name = "unicode-ident"
|
|
298
|
+
version = "1.0.24"
|
|
299
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
300
|
+
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
301
|
+
|
|
302
|
+
[[package]]
|
|
303
|
+
name = "unicode-segmentation"
|
|
304
|
+
version = "1.13.2"
|
|
305
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
306
|
+
checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c"
|
|
307
|
+
|
|
308
|
+
[[package]]
|
|
309
|
+
name = "v3-math-native"
|
|
310
|
+
version = "0.1.0"
|
|
311
|
+
dependencies = [
|
|
312
|
+
"ethnum",
|
|
313
|
+
"napi",
|
|
314
|
+
"napi-build",
|
|
315
|
+
"napi-derive",
|
|
316
|
+
"rayon",
|
|
317
|
+
"serde",
|
|
318
|
+
"serde_json",
|
|
319
|
+
]
|
|
320
|
+
|
|
321
|
+
[[package]]
|
|
322
|
+
name = "windows-link"
|
|
323
|
+
version = "0.2.1"
|
|
324
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
325
|
+
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
|
326
|
+
|
|
327
|
+
[[package]]
|
|
328
|
+
name = "zmij"
|
|
329
|
+
version = "1.0.21"
|
|
330
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
331
|
+
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "v3-math-native"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
|
|
6
|
+
[lib]
|
|
7
|
+
crate-type = ["cdylib"]
|
|
8
|
+
|
|
9
|
+
[dependencies]
|
|
10
|
+
napi = { version = "2", features = ["napi6", "serde-json"] }
|
|
11
|
+
napi-derive = "2"
|
|
12
|
+
ethnum = "1"
|
|
13
|
+
rayon = "1"
|
|
14
|
+
serde = { version = "1", features = ["derive"] }
|
|
15
|
+
serde_json = "1"
|
|
16
|
+
|
|
17
|
+
[build-dependencies]
|
|
18
|
+
napi-build = "2"
|
|
19
|
+
|
|
20
|
+
[profile.release]
|
|
21
|
+
lto = true
|
|
22
|
+
strip = "symbols"
|
package/native/build.rs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@paraswap/v3-math-native",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "@paraswap/v3-math-native",
|
|
9
|
+
"version": "0.1.0",
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@napi-rs/cli": "^2.18.0"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"node_modules/@napi-rs/cli": {
|
|
15
|
+
"version": "2.18.4",
|
|
16
|
+
"resolved": "https://registry.npmjs.org/@napi-rs/cli/-/cli-2.18.4.tgz",
|
|
17
|
+
"integrity": "sha512-SgJeA4df9DE2iAEpr3M2H0OKl/yjtg1BnRI5/JyowS71tUWhrfSu2LT0V3vlHET+g1hBVlrO60PmEXwUEKp8Mg==",
|
|
18
|
+
"dev": true,
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"bin": {
|
|
21
|
+
"napi": "scripts/index.js"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">= 10"
|
|
25
|
+
},
|
|
26
|
+
"funding": {
|
|
27
|
+
"type": "github",
|
|
28
|
+
"url": "https://github.com/sponsors/Brooooooklyn"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@paraswap/v3-math-native",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"napi": {
|
|
8
|
+
"name": "v3-math-native",
|
|
9
|
+
"triples": {
|
|
10
|
+
"defaults": true
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "napi build --platform --release",
|
|
15
|
+
"build:debug": "napi build --platform"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@napi-rs/cli": "^2.18.0"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/// Configures math variant differences between Uniswap V3 forks.
|
|
2
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
3
|
+
pub enum MathVariant {
|
|
4
|
+
/// Standard Uniswap V3: feeProtocol is 4-bit (% 16 / >> 4)
|
|
5
|
+
UniswapV3,
|
|
6
|
+
/// PancakeSwap V3: feeProtocol is 16-bit (% 65536 / >> 16), delta = feeAmount * fp / 10000
|
|
7
|
+
PancakeSwapV3,
|
|
8
|
+
/// Solidly V3: No oracle, no feeProtocol, fee from slot0.fee
|
|
9
|
+
SolidlyV3,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
impl MathVariant {
|
|
13
|
+
pub fn from_str(s: &str) -> Self {
|
|
14
|
+
match s {
|
|
15
|
+
"pancakeswap_v3" => MathVariant::PancakeSwapV3,
|
|
16
|
+
"solidly_v3" => MathVariant::SolidlyV3,
|
|
17
|
+
_ => MathVariant::UniswapV3,
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/// Extract the fee protocol value for the given swap direction.
|
|
22
|
+
pub fn fee_protocol(
|
|
23
|
+
&self,
|
|
24
|
+
fee_protocol_raw: ethnum::U256,
|
|
25
|
+
zero_for_one: bool,
|
|
26
|
+
) -> ethnum::U256 {
|
|
27
|
+
match self {
|
|
28
|
+
MathVariant::SolidlyV3 => ethnum::U256::ZERO, // no protocol fee
|
|
29
|
+
MathVariant::UniswapV3 => {
|
|
30
|
+
if zero_for_one {
|
|
31
|
+
fee_protocol_raw % ethnum::U256::from(16u32)
|
|
32
|
+
} else {
|
|
33
|
+
fee_protocol_raw >> 4
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
MathVariant::PancakeSwapV3 => {
|
|
37
|
+
if zero_for_one {
|
|
38
|
+
fee_protocol_raw % ethnum::U256::from(65536u32)
|
|
39
|
+
} else {
|
|
40
|
+
fee_protocol_raw >> 16
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// Calculate protocol fee delta from fee amount.
|
|
47
|
+
/// V3: delta = feeAmount / feeProtocol
|
|
48
|
+
/// PancakeSwap: delta = (feeAmount * feeProtocol) / 10000
|
|
49
|
+
pub fn protocol_fee_delta(
|
|
50
|
+
&self,
|
|
51
|
+
fee_amount: ethnum::U256,
|
|
52
|
+
fee_protocol: ethnum::U256,
|
|
53
|
+
) -> ethnum::U256 {
|
|
54
|
+
match self {
|
|
55
|
+
MathVariant::SolidlyV3 => ethnum::U256::ZERO,
|
|
56
|
+
MathVariant::UniswapV3 => fee_amount / fee_protocol,
|
|
57
|
+
MathVariant::PancakeSwapV3 => {
|
|
58
|
+
(fee_amount * fee_protocol) / ethnum::U256::from(10000u32)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/// Whether this variant uses oracle observations.
|
|
64
|
+
pub fn has_oracle(&self) -> bool {
|
|
65
|
+
!matches!(self, MathVariant::SolidlyV3)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// PancakeSwap V3 and Solidly V3 zero out remaining amounts for BOTH sell and buy at end of cycles.
|
|
69
|
+
/// V3 only zeros for BUY.
|
|
70
|
+
pub fn zero_remaining_for_sell(&self) -> bool {
|
|
71
|
+
matches!(self, MathVariant::SolidlyV3 | MathVariant::PancakeSwapV3)
|
|
72
|
+
}
|
|
73
|
+
}
|