@paraswap/dex-lib 4.0.20 → 4.0.21
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 +53 -0
- package/.vscode/settings.json +2 -0
- package/.vscode/tasks.json +15 -0
- package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +52 -0
- package/build/abi/usual-m-smart-m/usualM.abi.json +483 -0
- package/build/abi/{angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json → wombat/pool.json} +637 -594
- package/build/dex/aave-v1/aave-v1.js +1 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/aave-v2/tokens-avalanche.json +44 -0
- package/build/dex/aave-v2/tokens-mainnet.json +188 -0
- package/build/dex/aave-v2/tokens-polygon.json +44 -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/balancer-v3/abi/balancerBatchRouter.d.ts +729 -0
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js +732 -0
- package/build/dex/balancer-v3/abi/balancerBatchRouter.js.map +1 -0
- package/build/dex/balancer-v3/abi/balancerRouter.d.ts +1406 -0
- package/build/dex/balancer-v3/abi/balancerRouter.js +1175 -0
- package/build/dex/balancer-v3/abi/balancerRouter.js.map +1 -0
- package/build/dex/balancer-v3/abi/vaultExtension.V3.d.ts +2081 -0
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js +1851 -0
- package/build/dex/balancer-v3/abi/vaultExtension.V3.js.map +1 -0
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.d.ts +34 -0
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.js +406 -0
- package/build/dex/balancer-v3/balancer-v3-sepolia-pools.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-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/inception/inception-event-pool.d.ts +4 -4
- package/build/dex/inception/inception-event-pool.js +7 -9
- package/build/dex/inception/inception-event-pool.js.map +1 -1
- package/build/dex/inception/inception.d.ts +6 -6
- package/build/dex/inception/inception.js +16 -40
- package/build/dex/inception/inception.js.map +1 -1
- package/build/dex/inception/utils.d.ts +1 -0
- package/build/dex/inception/utils.js +22 -1
- package/build/dex/inception/utils.js.map +1 -1
- 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/maker-psm/scripts/gem.abi.json +136 -0
- package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
- package/build/dex/maker-psm/scripts/validate-state.js +185 -0
- package/build/dex/maker-psm/scripts/validate-state.js.map +1 -0
- package/build/dex/maker-psm/scripts/vat.abi.json +243 -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/platypus/platypus.js +17 -3
- package/build/dex/platypus/platypus.js.map +1 -1
- 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-v3/scripts/check-event-pool-event.d.ts +1 -0
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js +53 -0
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +1 -0
- package/build/dex/stable-pool.d.ts +28 -0
- package/build/dex/stable-pool.js +55 -0
- package/build/dex/stable-pool.js.map +1 -0
- package/build/dex/stkgho/stkgho.js +4 -2
- package/build/dex/stkgho/stkgho.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.js +4 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +7 -0
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +20 -0
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.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/forks/alien-base-v3/alien-base-v3.d.ts +17 -0
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +64 -0
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +1 -0
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +17 -0
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +79 -0
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-pricing.d.ts +4 -0
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js +43 -0
- package/build/dex/uniswap-v3/uniswap-v3-pricing.js.map +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-worker.d.ts +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-worker.js +10 -0
- package/build/dex/uniswap-v3/uniswap-v3-worker.js.map +1 -0
- package/build/dex/usual/usual-m-smart-m.d.ts +17 -0
- package/build/dex/usual/usual-m-smart-m.js +50 -0
- package/build/dex/usual/usual-m-smart-m.js.map +1 -0
- package/build/dex/usual-m-smart-m/config.d.ts +3 -0
- package/build/dex/usual-m-smart-m/config.js +13 -0
- package/build/dex/usual-m-smart-m/config.js.map +1 -0
- package/build/dex/usual-m-smart-m/types.d.ts +7 -0
- package/build/dex/usual-m-smart-m/types.js +3 -0
- package/build/dex/usual-m-smart-m/types.js.map +1 -0
- package/build/dex/usual-m-smart-m/usual-m-smart-m.d.ts +35 -0
- package/build/dex/usual-m-smart-m/usual-m-smart-m.js +161 -0
- package/build/dex/usual-m-smart-m/usual-m-smart-m.js.map +1 -0
- package/build/dex/usual-m-usd0/config.d.ts +3 -0
- package/build/dex/usual-m-usd0/config.js +14 -0
- package/build/dex/usual-m-usd0/config.js.map +1 -0
- package/build/dex/usual-m-usd0/types.d.ts +8 -0
- package/build/dex/usual-m-usd0/types.js +3 -0
- package/build/dex/usual-m-usd0/types.js.map +1 -0
- package/build/dex/usual-m-usd0/usual-m-usd0.d.ts +35 -0
- package/build/dex/usual-m-usd0/usual-m-usd0.js +159 -0
- package/build/dex/usual-m-usd0/usual-m-usd0.js.map +1 -0
- package/package.json +1 -1
- package/src/dex/stkgho/stkgho.ts +4 -2
- package/build/abi/Aave_GSM.json +0 -751
- package/build/abi/Balancer.json +0 -257
- package/build/abi/BalancerV2.json +0 -1179
- package/build/abi/RamsesV2Pool.abi.json +0 -1554
- package/build/abi/RamsesV2Quoter.abi.json +0 -274
- package/build/abi/USDM.json +0 -807
- package/build/abi/UniswapV2Router.json +0 -397
- package/build/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +0 -509
- package/build/abi/curve-v1/CurveBUSDv2.abi.json +0 -1356
- package/build/abi/curve-v1/CurveTokenV1.json +0 -305
- package/build/abi/curve-v1/CurveTokenV2.json +0 -318
- package/build/abi/curve-v1/CurveV1StableNg.json +0 -1452
- package/build/abi/curve-v1/CurveV2Swap.json +0 -700
- package/build/abi/curve-v1/FactoryCryptoRegistry.json +0 -316
- package/build/abi/curve-v1/FactoryRegistry.json +0 -508
- package/build/abi/curve-v1/StableSwapAave.json +0 -1152
- package/build/abi/curve-v1/StableSwapBUSD.json +0 -814
- package/build/abi/curve-v1/StableSwapCompound.json +0 -814
- package/build/abi/curve-v1/StableSwapIDLE.json +0 -1253
- package/build/abi/curve-v1/StableSwapPax.json +0 -865
- package/build/abi/curve-v1/StableSwapSnow.json +0 -900
- package/build/abi/curve-v1/StableSwapUSDN.json +0 -1004
- package/build/abi/curve-v1/StableSwapUSDT.json +0 -814
- package/build/abi/curve-v1/StableSwapY.json +0 -814
- package/build/abi/inception/inception-ineth.json +0 -609
- package/build/abi/kyberdmm/kyber-storage.abi.json +0 -824
- package/build/abi/kyberdmm.abi.json +0 -1148
- package/build/abi/maverick-v2/MaverickV2Quoter.json +0 -278
- package/build/abi/nerve/nerve-metapool.json +0 -790
- package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
- package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +0 -267
- package/build/dex/balancer-v1/balancer-pools.json +0 -33333
- package/build/dex/bebop/websocket-fetcher.d.ts +0 -35
- package/build/dex/bebop/websocket-fetcher.js +0 -87
- package/build/dex/bebop/websocket-fetcher.js.map +0 -1
- package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
- package/build/dex/idle-dao/idle-dao-pool.js +0 -176
- package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
- package/build/dex/idle-dao/scripts.d.ts +0 -9
- package/build/dex/idle-dao/scripts.js +0 -552
- package/build/dex/idle-dao/scripts.js.map +0 -1
- package/build/dex/inception/inception-native.d.ts +0 -43
- package/build/dex/inception/inception-native.js +0 -131
- package/build/dex/inception/inception-native.js.map +0 -1
- package/build/dex/inception/inception-pool.d.ts +0 -18
- package/build/dex/inception/inception-pool.js +0 -32
- package/build/dex/inception/inception-pool.js.map +0 -1
- package/build/dex/inception/inception-price-feed.d.ts +0 -19
- package/build/dex/inception/inception-price-feed.js +0 -51
- package/build/dex/inception/inception-price-feed.js.map +0 -1
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +0 -9
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -12
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -7
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -7
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -7
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -7
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -12
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +0 -7
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +0 -7
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -78
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -81
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -78
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -78
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -81
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -81
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -81
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -81
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -64
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -85
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -64
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +0 -52
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +0 -52
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -52
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +0 -55
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +0 -55
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +0 -55
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -23
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -37
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -23
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -23
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -51
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +0 -58
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -23
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -23
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -9
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -16
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -23
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -12
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -12
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -12
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -7
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -130
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -136
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -100
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -100
- package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -166
- package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +0 -190
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -114
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -114
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -55
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -73
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -82
|
@@ -0,0 +1,46 @@
|
|
|
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.Compound = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const simple_exchange_1 = require("./simple-exchange");
|
|
10
|
+
const Compound_CETH_json_1 = __importDefault(require("../abi/Compound_CETH.json")); // CETH abi
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
var CompoundFunctions;
|
|
13
|
+
(function (CompoundFunctions) {
|
|
14
|
+
CompoundFunctions["redeem"] = "redeem";
|
|
15
|
+
CompoundFunctions["mint"] = "mint";
|
|
16
|
+
})(CompoundFunctions || (CompoundFunctions = {}));
|
|
17
|
+
class Compound extends simple_exchange_1.SimpleExchange {
|
|
18
|
+
constructor(dexHelper) {
|
|
19
|
+
super(dexHelper, 'compound');
|
|
20
|
+
this.cethInterface = new abi_1.Interface(Compound_CETH_json_1.default);
|
|
21
|
+
}
|
|
22
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
23
|
+
const cToken = data.fromCToken ? srcToken : destToken; // Warning
|
|
24
|
+
const payload = this.abiCoder.encodeParameter({
|
|
25
|
+
ParentStruct: {
|
|
26
|
+
cToken: 'address',
|
|
27
|
+
},
|
|
28
|
+
}, { cToken });
|
|
29
|
+
return {
|
|
30
|
+
// target exchange is not used by the contract
|
|
31
|
+
targetExchange: constants_1.NULL_ADDRESS,
|
|
32
|
+
payload,
|
|
33
|
+
networkFee: '0',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
37
|
+
const cToken = data.fromCToken ? srcToken : destToken;
|
|
38
|
+
const swapData = (0, utils_1.isETHAddress)(srcToken)
|
|
39
|
+
? this.cethInterface.encodeFunctionData(CompoundFunctions.mint)
|
|
40
|
+
: this.erc20Interface.encodeFunctionData(data.fromCToken ? CompoundFunctions.redeem : CompoundFunctions.mint, [srcAmount]);
|
|
41
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, cToken);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.Compound = Compound;
|
|
45
|
+
Compound.dexKeys = ['compound'];
|
|
46
|
+
//# sourceMappingURL=compound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compound.js","sourceRoot":"","sources":["../../src/dex/compound.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAC7D,4CAAsD;AAGtD,uDAAmD;AACnD,mFAA6C,CAAC,WAAW;AACzD,oCAAwC;AAQxC,IAAK,iBAGJ;AAHD,WAAK,iBAAiB;IACpB,sCAAiB,CAAA;IACjB,kCAAa,CAAA;AACf,CAAC,EAHI,iBAAiB,KAAjB,iBAAiB,QAGrB;AAED,MAAa,QACX,SAAQ,gCAAc;IAMtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,eAAS,CAAC,4BAAsB,CAAC,CAAC;IAC7D,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAkB,EAClB,IAAc;QAEd,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU;QAEjE,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAC3C;YACE,YAAY,EAAE;gBACZ,MAAM,EAAE,SAAS;aAClB;SACF,EACD,EAAE,MAAM,EAAE,CACX,CAAC;QAEF,OAAO;YACL,8CAA8C;YAC9C,cAAc,EAAE,wBAAY;YAC5B,OAAO;YACP,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAkB,EAClB,IAAc;QAEd,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;QACtD,MAAM,QAAQ,GAAG,IAAA,oBAAY,EAAC,QAAQ,CAAC;YACrC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,IAAI,CAAC;YAC/D,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,kBAAkB,CACpC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,EACnE,CAAC,SAAS,CAAC,CACZ,CAAC;QAEN,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,MAAM,CACP,CAAC;IACJ,CAAC;;AA/DH,4BAgEC;AA5DQ,gBAAO,GAAG,CAAC,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { SwapSide } from '../constants';
|
|
3
|
+
import { AdapterExchangeParam, Address, ExchangeTxInfo, NumberAsString, PreprocessTransactionOptions, SimpleExchangeParam, Token, TxInfo } from '../types';
|
|
4
|
+
import { IDexTxBuilder } from './idex';
|
|
5
|
+
import { SimpleExchange } from './simple-exchange';
|
|
6
|
+
import { IDexHelper } from '../dex-helper';
|
|
7
|
+
import { Logger } from 'log4js';
|
|
8
|
+
import { OptimalSwapExchange } from '@paraswap/core';
|
|
9
|
+
export declare enum CurveV2SwapType {
|
|
10
|
+
EXCHANGE = 0,
|
|
11
|
+
EXCHANGE_UNDERLYING = 1,
|
|
12
|
+
EXCHANGE_GENERIC_FACTORY_ZAP = 2
|
|
13
|
+
}
|
|
14
|
+
declare type CurveV2Data = {
|
|
15
|
+
i: number;
|
|
16
|
+
j: number;
|
|
17
|
+
exchange: string;
|
|
18
|
+
originalPoolAddress: Address;
|
|
19
|
+
swapType: CurveV2SwapType;
|
|
20
|
+
isApproved?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare type DirectCurveV2Param = [
|
|
23
|
+
fromToken: Address,
|
|
24
|
+
toToken: Address,
|
|
25
|
+
exchange: Address,
|
|
26
|
+
poolAddress: Address,
|
|
27
|
+
fromAmount: NumberAsString,
|
|
28
|
+
toAmount: NumberAsString,
|
|
29
|
+
expectedAmount: NumberAsString,
|
|
30
|
+
feePercent: NumberAsString,
|
|
31
|
+
i: NumberAsString,
|
|
32
|
+
j: NumberAsString,
|
|
33
|
+
partner: Address,
|
|
34
|
+
isApproved: boolean,
|
|
35
|
+
swapType: CurveV2SwapType,
|
|
36
|
+
beneficiary: Address,
|
|
37
|
+
needWrapNative: boolean,
|
|
38
|
+
permit: string,
|
|
39
|
+
uuid: string
|
|
40
|
+
];
|
|
41
|
+
export declare class CurveV2 extends SimpleExchange implements IDexTxBuilder<CurveV2Data, DirectCurveV2Param> {
|
|
42
|
+
readonly dexHelper: IDexHelper;
|
|
43
|
+
static dexKeys: string[];
|
|
44
|
+
exchangeRouterInterface: Interface;
|
|
45
|
+
genericFactoryZapIface: Interface;
|
|
46
|
+
minConversionRate: string;
|
|
47
|
+
needWrapNative: boolean;
|
|
48
|
+
logger: Logger;
|
|
49
|
+
readonly directSwapIface: Interface;
|
|
50
|
+
constructor(dexHelper: IDexHelper);
|
|
51
|
+
getAdapterParam(_0: string, _1: string, _2: string, _3: string, data: CurveV2Data, side: SwapSide): AdapterExchangeParam;
|
|
52
|
+
getTokenFromAddress(address: Address): Token;
|
|
53
|
+
preProcessTransaction(optimalSwapExchange: OptimalSwapExchange<CurveV2Data>, srcToken: Token, _0: Token, _1: SwapSide, options: PreprocessTransactionOptions): Promise<[OptimalSwapExchange<CurveV2Data>, ExchangeTxInfo]>;
|
|
54
|
+
getDirectParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, expectedAmount: NumberAsString, data: CurveV2Data, side: SwapSide, permit: string, uuid: string, feePercent: NumberAsString, _0: NumberAsString, partner: string, beneficiary: string, contractMethod?: string): TxInfo<DirectCurveV2Param>;
|
|
55
|
+
static getDirectFunctionName(): string[];
|
|
56
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: CurveV2Data, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,180 @@
|
|
|
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.CurveV2 = exports.CurveV2SwapType = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const simple_exchange_1 = require("./simple-exchange");
|
|
10
|
+
const GenericFactoryZap_json_1 = __importDefault(require("../abi/curve-v2/GenericFactoryZap.json"));
|
|
11
|
+
const DirectSwap_json_1 = __importDefault(require("../abi/DirectSwap.json"));
|
|
12
|
+
const CurveV2_json_1 = __importDefault(require("../abi/CurveV2.json"));
|
|
13
|
+
const ts_essentials_1 = require("ts-essentials");
|
|
14
|
+
const utils_1 = require("../utils");
|
|
15
|
+
var CurveV2SwapType;
|
|
16
|
+
(function (CurveV2SwapType) {
|
|
17
|
+
CurveV2SwapType[CurveV2SwapType["EXCHANGE"] = 0] = "EXCHANGE";
|
|
18
|
+
CurveV2SwapType[CurveV2SwapType["EXCHANGE_UNDERLYING"] = 1] = "EXCHANGE_UNDERLYING";
|
|
19
|
+
CurveV2SwapType[CurveV2SwapType["EXCHANGE_GENERIC_FACTORY_ZAP"] = 2] = "EXCHANGE_GENERIC_FACTORY_ZAP";
|
|
20
|
+
})(CurveV2SwapType = exports.CurveV2SwapType || (exports.CurveV2SwapType = {}));
|
|
21
|
+
const DIRECT_METHOD_NAME = 'directCurveV2Swap';
|
|
22
|
+
var CurveV2SwapFunctions;
|
|
23
|
+
(function (CurveV2SwapFunctions) {
|
|
24
|
+
CurveV2SwapFunctions["exchange"] = "exchange(uint256 i, uint256 j, uint256 dx, uint256 minDy)";
|
|
25
|
+
CurveV2SwapFunctions["exchange_underlying"] = "exchange_underlying(uint256 i, uint256 j, uint256 dx, uint256 minDy)";
|
|
26
|
+
CurveV2SwapFunctions["exchange_in_generic_factory_zap"] = "exchange(address _pool, uint256 i, uint256 j, uint256 _dx, uint256 _min_dy)";
|
|
27
|
+
})(CurveV2SwapFunctions || (CurveV2SwapFunctions = {}));
|
|
28
|
+
class CurveV2 extends simple_exchange_1.SimpleExchange {
|
|
29
|
+
constructor(dexHelper) {
|
|
30
|
+
super(dexHelper, 'curvev2');
|
|
31
|
+
this.dexHelper = dexHelper;
|
|
32
|
+
this.minConversionRate = '1';
|
|
33
|
+
this.needWrapNative = true;
|
|
34
|
+
this.directSwapIface = new abi_1.Interface(DirectSwap_json_1.default);
|
|
35
|
+
this.exchangeRouterInterface = new abi_1.Interface(CurveV2_json_1.default);
|
|
36
|
+
this.genericFactoryZapIface = new abi_1.Interface(GenericFactoryZap_json_1.default);
|
|
37
|
+
this.logger = dexHelper.getLogger(`CurveV2_${dexHelper.config.data.network}`);
|
|
38
|
+
}
|
|
39
|
+
getAdapterParam(_0, _1, _2, _3, data, side) {
|
|
40
|
+
if (side === constants_1.SwapSide.BUY)
|
|
41
|
+
throw new Error(`Buy not supported`);
|
|
42
|
+
const { i, j, originalPoolAddress, swapType } = data;
|
|
43
|
+
const payload = this.abiCoder.encodeParameter({
|
|
44
|
+
ParentStruct: {
|
|
45
|
+
i: 'uint256',
|
|
46
|
+
j: 'uint256',
|
|
47
|
+
originalPoolAddress: 'address',
|
|
48
|
+
swapType: 'uint8',
|
|
49
|
+
},
|
|
50
|
+
}, {
|
|
51
|
+
i,
|
|
52
|
+
j,
|
|
53
|
+
originalPoolAddress,
|
|
54
|
+
swapType,
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
targetExchange: data.exchange,
|
|
58
|
+
payload,
|
|
59
|
+
networkFee: '0',
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
getTokenFromAddress(address) {
|
|
63
|
+
// In this Dex decimals are not used
|
|
64
|
+
return { address, decimals: 0 };
|
|
65
|
+
}
|
|
66
|
+
async preProcessTransaction(optimalSwapExchange, srcToken, _0, _1, options) {
|
|
67
|
+
if (!options.isDirectMethod) {
|
|
68
|
+
return [
|
|
69
|
+
optimalSwapExchange,
|
|
70
|
+
{
|
|
71
|
+
deadline: BigInt((0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)()),
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
(0, ts_essentials_1.assert)(optimalSwapExchange.data !== undefined, `preProcessTransaction: data field is missing`);
|
|
76
|
+
let isApproved;
|
|
77
|
+
try {
|
|
78
|
+
this.erc20Contract.options.address =
|
|
79
|
+
this.dexHelper.config.wrapETH(srcToken).address;
|
|
80
|
+
const allowance = await this.erc20Contract.methods
|
|
81
|
+
.allowance(this.augustusAddress, optimalSwapExchange.data.exchange)
|
|
82
|
+
.call(undefined, 'latest');
|
|
83
|
+
isApproved =
|
|
84
|
+
BigInt(allowance.toString()) >= BigInt(optimalSwapExchange.srcAmount);
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
this.logger.error(`preProcessTransaction failed to retrieve allowance info: `, e);
|
|
88
|
+
}
|
|
89
|
+
return [
|
|
90
|
+
{
|
|
91
|
+
...optimalSwapExchange,
|
|
92
|
+
data: {
|
|
93
|
+
...optimalSwapExchange.data,
|
|
94
|
+
isApproved,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
deadline: BigInt((0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)()),
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
getDirectParam(srcToken, destToken, srcAmount, destAmount, expectedAmount, data, side, permit, uuid, feePercent, _0, partner, beneficiary, contractMethod) {
|
|
103
|
+
if (contractMethod !== DIRECT_METHOD_NAME) {
|
|
104
|
+
throw new Error(`Invalid contract method ${contractMethod}`);
|
|
105
|
+
}
|
|
106
|
+
(0, ts_essentials_1.assert)(side === constants_1.SwapSide.SELL, 'Buy not supported');
|
|
107
|
+
let isApproved = !!data.isApproved;
|
|
108
|
+
if (data.isApproved === undefined) {
|
|
109
|
+
this.logger.warn(`isApproved is undefined, defaulting to false`);
|
|
110
|
+
}
|
|
111
|
+
const swapParams = [
|
|
112
|
+
srcToken,
|
|
113
|
+
destToken,
|
|
114
|
+
data.exchange,
|
|
115
|
+
data.originalPoolAddress,
|
|
116
|
+
srcAmount,
|
|
117
|
+
destAmount,
|
|
118
|
+
expectedAmount,
|
|
119
|
+
feePercent,
|
|
120
|
+
data.i.toString(),
|
|
121
|
+
data.j.toString(),
|
|
122
|
+
partner,
|
|
123
|
+
isApproved,
|
|
124
|
+
data.swapType,
|
|
125
|
+
beneficiary,
|
|
126
|
+
// For now we always wrap native. We don't support non native trade
|
|
127
|
+
true,
|
|
128
|
+
permit,
|
|
129
|
+
(0, utils_1.uuidToBytes16)(uuid),
|
|
130
|
+
];
|
|
131
|
+
const encoder = (...params) => {
|
|
132
|
+
return this.directSwapIface.encodeFunctionData(DIRECT_METHOD_NAME, [
|
|
133
|
+
params,
|
|
134
|
+
]);
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
params: swapParams,
|
|
138
|
+
encoder,
|
|
139
|
+
networkFee: '0',
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
static getDirectFunctionName() {
|
|
143
|
+
return [DIRECT_METHOD_NAME];
|
|
144
|
+
}
|
|
145
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
146
|
+
if (side === constants_1.SwapSide.BUY)
|
|
147
|
+
throw new Error(`Buy not supported`);
|
|
148
|
+
const { exchange, i, j, originalPoolAddress, swapType } = data;
|
|
149
|
+
const args = swapType === CurveV2SwapType.EXCHANGE_GENERIC_FACTORY_ZAP
|
|
150
|
+
? [
|
|
151
|
+
originalPoolAddress,
|
|
152
|
+
i.toString(),
|
|
153
|
+
j.toString(),
|
|
154
|
+
srcAmount,
|
|
155
|
+
this.minConversionRate,
|
|
156
|
+
]
|
|
157
|
+
: [i.toString(), j.toString(), srcAmount, this.minConversionRate];
|
|
158
|
+
let swapMethod;
|
|
159
|
+
switch (swapType) {
|
|
160
|
+
case CurveV2SwapType.EXCHANGE:
|
|
161
|
+
swapMethod = CurveV2SwapFunctions.exchange;
|
|
162
|
+
break;
|
|
163
|
+
case CurveV2SwapType.EXCHANGE_UNDERLYING:
|
|
164
|
+
swapMethod = CurveV2SwapFunctions.exchange_underlying;
|
|
165
|
+
break;
|
|
166
|
+
case CurveV2SwapType.EXCHANGE_GENERIC_FACTORY_ZAP:
|
|
167
|
+
swapMethod = CurveV2SwapFunctions.exchange_in_generic_factory_zap;
|
|
168
|
+
break;
|
|
169
|
+
default:
|
|
170
|
+
throw new Error(`getSimpleParam: not all cases covered for CurveV2SwapTypes`);
|
|
171
|
+
}
|
|
172
|
+
const swapData = swapMethod === CurveV2SwapFunctions.exchange_in_generic_factory_zap
|
|
173
|
+
? this.genericFactoryZapIface.encodeFunctionData(swapMethod, args)
|
|
174
|
+
: this.exchangeRouterInterface.encodeFunctionData(swapMethod, args);
|
|
175
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, exchange);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.CurveV2 = CurveV2;
|
|
179
|
+
CurveV2.dexKeys = ['curvev2'];
|
|
180
|
+
//# sourceMappingURL=curve-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"curve-v2.js","sourceRoot":"","sources":["../../src/dex/curve-v2.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAC7D,4CAAwC;AAYxC,uDAG2B;AAC3B,oGAA0E;AAC1E,6EAAmD;AACnD,uEAA6C;AAE7C,iDAAuC;AAGvC,oCAAyC;AAEzC,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,6DAAQ,CAAA;IACR,mFAAmB,CAAA;IACnB,qGAA4B,CAAA;AAC9B,CAAC,EAJW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAI1B;AAED,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AA+C/C,IAAK,oBAIJ;AAJD,WAAK,oBAAoB;IACvB,8FAAsE,CAAA;IACtE,oHAA4F,CAAA;IAC5F,uIAA+G,CAAA;AACjH,CAAC,EAJI,oBAAoB,KAApB,oBAAoB,QAIxB;AAED,MAAa,OACX,SAAQ,gCAAc;IAYtB,YAAqB,SAAqB;QACxC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QADT,cAAS,GAAT,SAAS,CAAY;QAN1C,sBAAiB,GAAG,GAAG,CAAC;QACxB,mBAAc,GAAG,IAAI,CAAC;QAGb,oBAAe,GAAG,IAAI,eAAS,CAAC,yBAAa,CAAC,CAAC;QAItD,IAAI,CAAC,uBAAuB,GAAG,IAAI,eAAS,CAAC,sBAA4B,CAAC,CAAC;QAC3E,IAAI,CAAC,sBAAsB,GAAG,IAAI,eAAS,CAAC,gCAAoB,CAAC,CAAC;QAClE,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,SAAS,CAC/B,WAAW,SAAS,CAAC,MAAM,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ACvB;YACH,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEtE,IAAI,UAAkB,CAAC;QACvB,QAAQ,QAAQ,EAAE;YAChB,KAAK,eAAe,CAAC,QAAQ;gBAC3B,UAAU,GAAG,oBAAoB,CAAC,QAAQ,CAAC;gBAC3C,MAAM;YACR,KAAK,eAAe,CAAC,mBAAmB;gBACtC,UAAU,GAAG,oBAAoB,CAAC,mBAAmB,CAAC;gBACtD,MAAM;YACR,KAAK,eAAe,CAAC,4BAA4B;gBAC/C,UAAU,GAAG,oBAAoB,CAAC,+BAA+B,CAAC;gBAClE,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAC;SACL;QAED,MAAM,QAAQ,GACZ,UAAU,KAAK,oBAAoB,CAAC,+BAA+B;YACjE,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC;YAClE,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAExE,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,CACT,CAAC;IACJ,CAAC;;AAvOH,0BAwOC;AApOQ,eAAO,GAAG,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 { NumberAsString } from '@paraswap/core';
|
|
7
|
+
import { IDexHelper } from '../dex-helper';
|
|
8
|
+
export declare type DodoV1Data = {
|
|
9
|
+
fromToken: Address;
|
|
10
|
+
toToken: Address;
|
|
11
|
+
dodoPairs: Address[];
|
|
12
|
+
directions: string;
|
|
13
|
+
isIncentive: boolean;
|
|
14
|
+
deadLine: string;
|
|
15
|
+
};
|
|
16
|
+
declare type DodoV1Param = [
|
|
17
|
+
fromToken: Address,
|
|
18
|
+
toToken: Address,
|
|
19
|
+
fromTokenAmount: NumberAsString,
|
|
20
|
+
minReturnAmount: NumberAsString,
|
|
21
|
+
dodoPairs: Address[],
|
|
22
|
+
directions: NumberAsString,
|
|
23
|
+
isIncentive: boolean,
|
|
24
|
+
deadLine: NumberAsString
|
|
25
|
+
];
|
|
26
|
+
export declare class DodoV1 extends SimpleExchange implements IDexTxBuilder<DodoV1Data, DodoV1Param> {
|
|
27
|
+
static dexKeys: string[];
|
|
28
|
+
dodoV2Proxy: Interface;
|
|
29
|
+
constructor(dexHelper: IDexHelper);
|
|
30
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: DodoV1Data, side: SwapSide): AdapterExchangeParam;
|
|
31
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: DodoV1Data, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
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.DodoV1 = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const simple_exchange_1 = require("./simple-exchange");
|
|
10
|
+
const dodo_v2_proxy_json_1 = __importDefault(require("../abi/dodo-v2-proxy.json"));
|
|
11
|
+
// We use dodo-v2 proxy as the new proxy supports both v1 and v2
|
|
12
|
+
const DODOV2ProxyAddress = {
|
|
13
|
+
1: '0xa356867fdcea8e71aeaf87805808803806231fdc',
|
|
14
|
+
56: '0x8F8Dd7DB1bDA5eD3da8C9daf3bfa471c12d58486',
|
|
15
|
+
42161: '0x88CBf433471A0CD8240D2a12354362988b4593E5',
|
|
16
|
+
};
|
|
17
|
+
const DODOAproveAddress = {
|
|
18
|
+
1: '0xCB859eA579b28e02B87A1FDE08d087ab9dbE5149',
|
|
19
|
+
56: '0xa128Ba44B2738A558A1fdC06d6303d52D3Cef8c1',
|
|
20
|
+
42161: '0xA867241cDC8d3b0C07C85cC06F25a0cD3b5474d8',
|
|
21
|
+
};
|
|
22
|
+
var DodoV1Functions;
|
|
23
|
+
(function (DodoV1Functions) {
|
|
24
|
+
DodoV1Functions["dodoSwapV1"] = "dodoSwapV1";
|
|
25
|
+
})(DodoV1Functions || (DodoV1Functions = {}));
|
|
26
|
+
class DodoV1 extends simple_exchange_1.SimpleExchange {
|
|
27
|
+
constructor(dexHelper) {
|
|
28
|
+
super(dexHelper, 'dodov1');
|
|
29
|
+
this.dodoV2Proxy = new abi_1.Interface(dodo_v2_proxy_json_1.default);
|
|
30
|
+
}
|
|
31
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
32
|
+
const { dodoPairs, directions } = data;
|
|
33
|
+
const payload = this.abiCoder.encodeParameter({
|
|
34
|
+
ParentStruct: {
|
|
35
|
+
dodoPairs: 'address[]',
|
|
36
|
+
directions: 'uint256',
|
|
37
|
+
},
|
|
38
|
+
}, { dodoPairs, directions });
|
|
39
|
+
return {
|
|
40
|
+
targetExchange: DODOV2ProxyAddress[this.network],
|
|
41
|
+
payload,
|
|
42
|
+
networkFee: '0',
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
46
|
+
const swapFunction = DodoV1Functions.dodoSwapV1;
|
|
47
|
+
const swapFunctionParams = [
|
|
48
|
+
srcToken,
|
|
49
|
+
destToken,
|
|
50
|
+
srcAmount,
|
|
51
|
+
destAmount,
|
|
52
|
+
data.dodoPairs,
|
|
53
|
+
data.directions,
|
|
54
|
+
data.isIncentive,
|
|
55
|
+
constants_1.MAX_UINT,
|
|
56
|
+
];
|
|
57
|
+
const swapData = this.dodoV2Proxy.encodeFunctionData(swapFunction, swapFunctionParams);
|
|
58
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, DODOV2ProxyAddress[this.network], DODOAproveAddress[this.network]);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.DodoV1 = DodoV1;
|
|
62
|
+
DodoV1.dexKeys = ['dodov1'];
|
|
63
|
+
//# sourceMappingURL=dodo-v1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dodo-v1.js","sourceRoot":"","sources":["../../src/dex/dodo-v1.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAC7D,4CAAkD;AAGlD,uDAAmD;AACnD,mFAAuD;AAKvD,gEAAgE;AAChE,MAAM,kBAAkB,GAAmC;IACzD,CAAC,EAAE,4CAA4C;IAC/C,EAAE,EAAE,4CAA4C;IAChD,KAAK,EAAE,4CAA4C;CACpD,CAAC;AAEF,MAAM,iBAAiB,GAAmC;IACxD,CAAC,EAAE,4CAA4C;IAC/C,EAAE,EAAE,4CAA4C;IAChD,KAAK,EAAE,4CAA4C;CACpD,CAAC;AAqBF,IAAK,eAEJ;AAFD,WAAK,eAAe;IAClB,4CAAyB,CAAA;AAC3B,CAAC,EAFI,eAAe,KAAf,eAAe,QAEnB;AAED,MAAa,MACX,SAAQ,gCAAc;IAMtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,eAAS,CAAC,4BAAgC,CAAC,CAAC;IACrE,CAAC;IAED,eAAe,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
import { BlockHeader, Log, Logger } from '../../types';
|
|
3
3
|
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
4
4
|
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
5
|
-
import { PoolState } from './types';
|
|
5
|
+
import { PoolConfig, PoolState } from './types';
|
|
6
6
|
import { Interface } from '@ethersproject/abi';
|
|
7
7
|
export declare class InceptionEventPool extends StatefulEventSubscriber<PoolState> {
|
|
8
8
|
protected network: number;
|
|
9
9
|
protected dexHelper: IDexHelper;
|
|
10
|
-
|
|
10
|
+
poolConfig: PoolConfig;
|
|
11
11
|
poolInterface: Interface;
|
|
12
12
|
protected ratioFeedInterface: Interface;
|
|
13
|
-
constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger,
|
|
13
|
+
constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, poolConfig: PoolConfig, poolInterface: Interface);
|
|
14
14
|
protected processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>, blockHeader: Readonly<BlockHeader>): AsyncOrSync<DeepReadonly<PoolState> | null>;
|
|
15
15
|
generateState(blockNumber: number): Promise<Readonly<PoolState>>;
|
|
16
16
|
}
|
|
@@ -11,14 +11,14 @@ const abi_1 = require("@ethersproject/abi");
|
|
|
11
11
|
const inception_ratio_feed_json_1 = __importDefault(require("../../abi/inception/inception-ratio-feed.json"));
|
|
12
12
|
const tokens_1 = require("./tokens");
|
|
13
13
|
class InceptionEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
|
|
14
|
-
constructor(parentName, network, dexHelper, logger,
|
|
15
|
-
super(parentName, ratioFeedAddress, dexHelper, logger);
|
|
14
|
+
constructor(parentName, network, dexHelper, logger, poolConfig, poolInterface) {
|
|
15
|
+
super(parentName, poolConfig.ratioFeedAddress, dexHelper, logger);
|
|
16
16
|
this.network = network;
|
|
17
17
|
this.dexHelper = dexHelper;
|
|
18
|
-
this.
|
|
18
|
+
this.poolConfig = poolConfig;
|
|
19
19
|
this.poolInterface = poolInterface;
|
|
20
20
|
this.ratioFeedInterface = new abi_1.Interface(inception_ratio_feed_json_1.default);
|
|
21
|
-
this.addressesSubscribed = [ratioFeedAddress];
|
|
21
|
+
this.addressesSubscribed = [poolConfig.ratioFeedAddress];
|
|
22
22
|
}
|
|
23
23
|
processLog(state, log, blockHeader) {
|
|
24
24
|
try {
|
|
@@ -27,11 +27,9 @@ class InceptionEventPool extends stateful_event_subscriber_1.StatefulEventSubscr
|
|
|
27
27
|
switch (parsed.name) {
|
|
28
28
|
case 'RatioUpdated': {
|
|
29
29
|
const tokenInfo = (0, tokens_1.getTokenFromAddress)(this.network, parsed.args[0]);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
}
|
|
30
|
+
_state[tokenInfo.symbol.toLowerCase()] = {
|
|
31
|
+
ratio: BigInt(parsed.args[2].toString()),
|
|
32
|
+
};
|
|
35
33
|
return _state;
|
|
36
34
|
}
|
|
37
35
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inception-event-pool.js","sourceRoot":"","sources":["../../../src/dex/inception/inception-event-pool.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAGvB,+EAA0E;AAG1E,mCAA0C;AAC1C,4CAA+C;AAC/C,8GAAiF;AACjF,qCAA+C;AAE/C,MAAa,kBAAmB,SAAQ,mDAAkC;IAExE,YACE,UAAkB,EACR,OAAe,EACf,SAAqB,EAC/B,MAAc,
|
|
1
|
+
{"version":3,"file":"inception-event-pool.js","sourceRoot":"","sources":["../../../src/dex/inception/inception-event-pool.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAGvB,+EAA0E;AAG1E,mCAA0C;AAC1C,4CAA+C;AAC/C,8GAAiF;AACjF,qCAA+C;AAE/C,MAAa,kBAAmB,SAAQ,mDAAkC;IAExE,YACE,UAAkB,EACR,OAAe,EACf,SAAqB,EAC/B,MAAc,EACP,UAAsB,EACtB,aAAwB;QAE/B,KAAK,CAA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AAC,aAAa,EAClB,IAAI,CAAC,OAAO,EACZ,WAAW,CACZ,CAAC;IACJ,CAAC;CACF;AAhDD,gDAgDC"}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { Interface } from '@ethersproject/abi';
|
|
2
2
|
import { AsyncOrSync } from 'ts-essentials';
|
|
3
3
|
import { NumberAsString, SwapSide } from '@paraswap/core';
|
|
4
|
-
import { AdapterExchangeParam, Address, DexExchangeParam, ExchangePrices, Logger, PoolLiquidity, PoolPrices, Token
|
|
4
|
+
import { AdapterExchangeParam, Address, DexExchangeParam, ExchangePrices, Logger, PoolLiquidity, PoolPrices, Token } from '../../types';
|
|
5
5
|
import { Network } from '../../constants';
|
|
6
6
|
import { IDex } from '../../dex/idex';
|
|
7
7
|
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
8
|
-
import { InceptionDexData, PoolState } from './types';
|
|
8
|
+
import { DexParams, InceptionDexData, PoolState } from './types';
|
|
9
9
|
import { SimpleExchange } from '../simple-exchange';
|
|
10
10
|
import { InceptionEventPool } from './inception-event-pool';
|
|
11
11
|
export declare class Inception extends SimpleExchange implements IDex<InceptionDexData> {
|
|
12
12
|
readonly network: Network;
|
|
13
13
|
readonly dexKey: string;
|
|
14
14
|
readonly dexHelper: IDexHelper;
|
|
15
|
-
protected config:
|
|
15
|
+
protected config: DexParams[];
|
|
16
16
|
protected vaultInterface: Interface;
|
|
17
17
|
protected poolInterface: Interface;
|
|
18
18
|
readonly hasConstantPriceLargeAmounts = false;
|
|
19
19
|
readonly needWrapNative = false;
|
|
20
|
-
readonly isFeeOnTransferSupported =
|
|
20
|
+
readonly isFeeOnTransferSupported = false;
|
|
21
21
|
static dexKeysWithNetwork: {
|
|
22
22
|
key: string;
|
|
23
23
|
networks: Network[];
|
|
24
24
|
}[];
|
|
25
25
|
logger: Logger;
|
|
26
26
|
private eventPool;
|
|
27
|
-
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, config?:
|
|
27
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, config?: DexParams[]);
|
|
28
28
|
initializePricing(blockNumber: number): Promise<void>;
|
|
29
29
|
initializeTokens(): Promise<void>;
|
|
30
30
|
getAdapters(side: SwapSide): {
|
|
@@ -33,7 +33,7 @@ export declare class Inception extends SimpleExchange implements IDex<InceptionD
|
|
|
33
33
|
}[] | null;
|
|
34
34
|
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
35
35
|
getPoolState(pool: InceptionEventPool, blockNumber: number): Promise<PoolState>;
|
|
36
|
-
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]
|
|
36
|
+
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<InceptionDexData>>;
|
|
37
37
|
getCalldataGasCost(poolPrices: PoolPrices<InceptionDexData>): number | number[];
|
|
38
38
|
getAdapterParam(): AdapterExchangeParam;
|
|
39
39
|
getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: InceptionDexData, side: SwapSide): DexExchangeParam;
|
|
@@ -39,8 +39,6 @@ const config_1 = require("./config");
|
|
|
39
39
|
const tokens_1 = require("./tokens");
|
|
40
40
|
const utils_2 = require("./utils");
|
|
41
41
|
const inception_event_pool_1 = require("./inception-event-pool");
|
|
42
|
-
const token_transfer_fee_1 = require("../../lib/token-transfer-fee");
|
|
43
|
-
const constants_2 = require("../../executor/constants");
|
|
44
42
|
const DECIMALS = BigInt(1e18);
|
|
45
43
|
class Inception extends simple_exchange_1.SimpleExchange {
|
|
46
44
|
constructor(network, dexKey, dexHelper, config = config_1.InceptionConfig[dexKey][network]) {
|
|
@@ -51,11 +49,14 @@ class Inception extends simple_exchange_1.SimpleExchange {
|
|
|
51
49
|
this.config = config;
|
|
52
50
|
this.hasConstantPriceLargeAmounts = false;
|
|
53
51
|
this.needWrapNative = false;
|
|
54
|
-
this.isFeeOnTransferSupported =
|
|
52
|
+
this.isFeeOnTransferSupported = false;
|
|
55
53
|
this.logger = dexHelper.getLogger(dexKey);
|
|
56
54
|
this.vaultInterface = new abi_1.Interface(inception_vault_json_1.default);
|
|
57
55
|
this.poolInterface = new abi_1.Interface(inception_ineth_pool_json_1.default);
|
|
58
|
-
this.eventPool = new inception_event_pool_1.InceptionEventPool(dexKey, network, dexHelper, this.logger,
|
|
56
|
+
this.eventPool = new inception_event_pool_1.InceptionEventPool(dexKey, network, dexHelper, this.logger, {
|
|
57
|
+
ratioFeedAddress: config_1.InceptionPricePoolConfig[dexKey][network].ratioFeed,
|
|
58
|
+
initState: {},
|
|
59
|
+
}, this.poolInterface);
|
|
59
60
|
}
|
|
60
61
|
async initializePricing(blockNumber) {
|
|
61
62
|
const poolState = await (0, utils_2.getOnChainState)(this.dexHelper.multiContract, this.vaultInterface, this.network, blockNumber);
|
|
@@ -88,46 +89,31 @@ class Inception extends simple_exchange_1.SimpleExchange {
|
|
|
88
89
|
pool.setState(onChainState, blockNumber);
|
|
89
90
|
return onChainState;
|
|
90
91
|
}
|
|
91
|
-
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools
|
|
92
|
-
srcFee: 0,
|
|
93
|
-
destFee: 0,
|
|
94
|
-
srcDexFee: 0,
|
|
95
|
-
destDexFee: 0,
|
|
96
|
-
}) {
|
|
92
|
+
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
97
93
|
if (side === core_1.SwapSide.BUY) {
|
|
98
94
|
return null;
|
|
99
95
|
}
|
|
100
96
|
const src = (0, tokens_1.getTokenFromAddress)(this.network, srcToken.address);
|
|
101
97
|
const dest = (0, tokens_1.getTokenFromAddress)(this.network, destToken.address);
|
|
102
|
-
if (
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
// TODO: Implement in both directions
|
|
106
|
-
// only baseToken -> inception token swaps are supported
|
|
107
|
-
if (src.baseToken.toLowerCase() !== srcToken.address.toLowerCase()) {
|
|
98
|
+
if (src !== dest) {
|
|
108
99
|
return null;
|
|
109
100
|
}
|
|
110
101
|
const poolState = await this.getPoolState(this.eventPool, blockNumber);
|
|
111
102
|
if (!poolState)
|
|
112
103
|
return null;
|
|
113
|
-
const unitPrice = DECIMALS;
|
|
114
|
-
const prices = amounts.map(amount => {
|
|
115
|
-
const ratio = poolState[src.symbol.toLowerCase()].ratio;
|
|
116
|
-
return (ratio * amount) / DECIMALS;
|
|
117
|
-
});
|
|
118
|
-
const [unitPriceWithFee, ...pricesWithFee] = (0, token_transfer_fee_1.applyTransferFee)([unitPrice, ...prices], side, side === core_1.SwapSide.SELL ? transferFees.srcFee : transferFees.destFee, side === core_1.SwapSide.SELL
|
|
119
|
-
? constants_1.SRC_TOKEN_PARASWAP_TRANSFERS
|
|
120
|
-
: constants_1.DEST_TOKEN_PARASWAP_TRANSFERS);
|
|
121
104
|
return [
|
|
122
105
|
{
|
|
123
|
-
prices:
|
|
124
|
-
|
|
106
|
+
prices: amounts.map(amount => {
|
|
107
|
+
const ratio = poolState[src.symbol.toLowerCase()].ratio;
|
|
108
|
+
return (ratio * amount) / DECIMALS;
|
|
109
|
+
}),
|
|
110
|
+
unit: DECIMALS,
|
|
125
111
|
gasCost: 120000,
|
|
126
112
|
exchange: this.dexKey,
|
|
127
113
|
data: {
|
|
128
114
|
exchange: dest.vault,
|
|
129
115
|
},
|
|
130
|
-
poolAddresses: [
|
|
116
|
+
poolAddresses: [src.token.toLowerCase()],
|
|
131
117
|
},
|
|
132
118
|
];
|
|
133
119
|
}
|
|
@@ -143,18 +129,12 @@ class Inception extends simple_exchange_1.SimpleExchange {
|
|
|
143
129
|
}
|
|
144
130
|
getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side) {
|
|
145
131
|
const dexParams = (0, tokens_1.getTokenFromAddress)(this.network, srcToken);
|
|
146
|
-
if (!dexParams) {
|
|
147
|
-
throw new Error('Unknown token');
|
|
148
|
-
}
|
|
149
132
|
const isNative = dexParams.baseTokenSlug === 'ETH';
|
|
150
133
|
let swapData;
|
|
151
134
|
let dexFuncHasRecipient;
|
|
152
|
-
let swappedAmountNotPresentInExchangeData;
|
|
153
|
-
let returnAmountPos = undefined;
|
|
154
135
|
if (isNative) {
|
|
155
136
|
swapData = this.poolInterface.encodeFunctionData('stake()', []);
|
|
156
137
|
dexFuncHasRecipient = false;
|
|
157
|
-
swappedAmountNotPresentInExchangeData = true;
|
|
158
138
|
}
|
|
159
139
|
else {
|
|
160
140
|
swapData = this.vaultInterface.encodeFunctionData('deposit', [
|
|
@@ -162,16 +142,14 @@ class Inception extends simple_exchange_1.SimpleExchange {
|
|
|
162
142
|
recipient,
|
|
163
143
|
]);
|
|
164
144
|
dexFuncHasRecipient = true;
|
|
165
|
-
swappedAmountNotPresentInExchangeData = false;
|
|
166
|
-
returnAmountPos = constants_2.RETURN_AMOUNT_POS_0;
|
|
167
145
|
}
|
|
168
146
|
return {
|
|
169
147
|
needWrapNative: false,
|
|
170
148
|
dexFuncHasRecipient,
|
|
171
149
|
exchangeData: swapData,
|
|
172
150
|
targetExchange: dexParams.vault,
|
|
173
|
-
swappedAmountNotPresentInExchangeData,
|
|
174
|
-
returnAmountPos,
|
|
151
|
+
swappedAmountNotPresentInExchangeData: true,
|
|
152
|
+
returnAmountPos: undefined,
|
|
175
153
|
};
|
|
176
154
|
}
|
|
177
155
|
async updatePoolState() { }
|
|
@@ -186,9 +164,7 @@ class Inception extends simple_exchange_1.SimpleExchange {
|
|
|
186
164
|
address: token.vault,
|
|
187
165
|
connectorTokens: [
|
|
188
166
|
{
|
|
189
|
-
address:
|
|
190
|
-
? token.baseToken
|
|
191
|
-
: token.token,
|
|
167
|
+
address: token.token,
|
|
192
168
|
decimals: 1e18,
|
|
193
169
|
},
|
|
194
170
|
],
|