@paraswap/dex-lib 3.8.12 → 3.8.13
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/concentrator/arUSD.json +568 -0
- package/build/abi/{wombat/pool.json → fx-protocol/FxUSD.json} +541 -603
- package/build/abi/inception/inception-ineth-pool.json +1062 -0
- package/build/abi/inception/inception-ineth.json +609 -0
- package/build/abi/inception/inception-ratio-feed.json +93 -0
- package/build/abi/inception/inception-vault.json +991 -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/oswap/oswap.abi.json +452 -0
- package/build/config.js +6 -6
- package/build/dex/aave-v1/aave-v1.js +0 -1
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/concentrator-arusd/concentrator-arusd.d.ts +38 -0
- package/build/dex/concentrator-arusd/concentrator-arusd.js +184 -0
- package/build/dex/concentrator-arusd/concentrator-arusd.js.map +1 -0
- package/build/dex/concentrator-arusd/config.d.ts +4 -0
- package/build/dex/concentrator-arusd/config.js +18 -0
- package/build/dex/concentrator-arusd/config.js.map +1 -0
- package/build/dex/concentrator-arusd/types.d.ts +10 -0
- package/build/dex/concentrator-arusd/types.js +3 -0
- package/build/dex/concentrator-arusd/types.js.map +1 -0
- package/build/dex/fx-protocol-rusd/config.d.ts +4 -0
- package/build/dex/fx-protocol-rusd/config.js +18 -0
- package/build/dex/fx-protocol-rusd/config.js.map +1 -0
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd.d.ts +39 -0
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd.js +196 -0
- package/build/dex/fx-protocol-rusd/fx-protocol-rusd.js.map +1 -0
- package/build/dex/fx-protocol-rusd/types.d.ts +10 -0
- package/build/dex/fx-protocol-rusd/types.js +3 -0
- package/build/dex/fx-protocol-rusd/types.js.map +1 -0
- package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
- package/build/dex/idle-dao/idle-dao-pool.js +176 -0
- package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
- package/build/dex/idle-dao/scripts.d.ts +9 -0
- package/build/dex/idle-dao/scripts.js +552 -0
- package/build/dex/idle-dao/scripts.js.map +1 -0
- package/build/dex/inception/config.d.ts +5 -0
- package/build/dex/inception/config.js +112 -0
- package/build/dex/inception/config.js.map +1 -0
- package/build/dex/inception/inception-event-pool.d.ts +23 -0
- package/build/dex/inception/inception-event-pool.js +34 -0
- package/build/dex/inception/inception-event-pool.js.map +1 -0
- package/build/dex/inception/inception-native.d.ts +43 -0
- package/build/dex/inception/inception-native.js +131 -0
- package/build/dex/inception/inception-native.js.map +1 -0
- package/build/dex/inception/inception-pool.d.ts +18 -0
- package/build/dex/inception/inception-pool.js +32 -0
- package/build/dex/inception/inception-pool.js.map +1 -0
- package/build/dex/inception/inception-price-feed.d.ts +19 -0
- package/build/dex/inception/inception-price-feed.js +51 -0
- package/build/dex/inception/inception-price-feed.js.map +1 -0
- package/build/dex/inception/inception.d.ts +44 -0
- package/build/dex/inception/inception.js +162 -0
- package/build/dex/inception/inception.js.map +1 -0
- package/build/dex/inception/tokens.d.ts +9 -0
- package/build/dex/inception/tokens.js +28 -0
- package/build/dex/inception/tokens.js.map +1 -0
- package/build/dex/inception/types.d.ts +22 -0
- package/build/dex/inception/types.js +3 -0
- package/build/dex/inception/types.js.map +1 -0
- package/build/dex/inception/utils.d.ts +7 -0
- package/build/dex/inception/utils.js +58 -0
- package/build/dex/inception/utils.js.map +1 -0
- package/build/dex/infusion/config.d.ts +4 -0
- package/build/dex/infusion/config.js +25 -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 +54 -0
- package/build/dex/infusion/infusion.js +532 -0
- package/build/dex/infusion/infusion.js.map +1 -0
- package/build/dex/infusion/types.d.ts +47 -0
- package/build/dex/infusion/types.js +3 -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/oswap/config.d.ts +5 -0
- package/build/dex/oswap/config.js +31 -0
- package/build/dex/oswap/config.js.map +1 -0
- package/build/dex/oswap/oswap-pool.d.ts +51 -0
- package/build/dex/oswap/oswap-pool.js +150 -0
- package/build/dex/oswap/oswap-pool.js.map +1 -0
- package/build/dex/oswap/oswap.d.ts +46 -0
- package/build/dex/oswap/oswap.js +263 -0
- package/build/dex/oswap/oswap.js.map +1 -0
- package/build/dex/oswap/types.d.ts +20 -0
- package/build/dex/oswap/types.js +3 -0
- package/build/dex/oswap/types.js.map +1 -0
- package/build/dex/platypus/platypus.js +3 -17
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/solidly-v3/config.js +39 -0
- package/build/dex/solidly-v3/config.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.js +0 -4
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/implementations/local-paraswap-sdk.d.ts +2 -0
- package/build/implementations/local-paraswap-sdk.js +7 -0
- package/build/implementations/local-paraswap-sdk.js.map +1 -1
- package/package.json +1 -1
- package/src/config.ts +6 -6
- package/src/dex/solidly-v3/config.ts +42 -0
- package/src/dex/solidly-v3/solidly-v3-e2e.test.ts +114 -3
- package/src/implementations/local-paraswap-sdk.ts +8 -0
- package/tests/constants-e2e.ts +1 -1
- package/.vscode/launch.json +0 -53
- package/.vscode/settings.json +0 -2
- package/.vscode/tasks.json +0 -15
- package/build/abi/maverick-v2/MaverickV2Router.json +0 -778
- package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +0 -52
- package/build/dex/aave-v2/tokens-avalanche.json +0 -44
- package/build/dex/aave-v2/tokens-mainnet.json +0 -188
- package/build/dex/aave-v2/tokens-polygon.json +0 -44
- 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/lido.d.ts +0 -19
- package/build/dex/lido.js +0 -42
- package/build/dex/lido.js.map +0 -1
- package/build/dex/maker-psm/scripts/gem.abi.json +0 -136
- package/build/dex/maker-psm/scripts/validate-state.d.ts +0 -0
- package/build/dex/maker-psm/scripts/validate-state.js +0 -185
- package/build/dex/maker-psm/scripts/validate-state.js.map +0 -1
- package/build/dex/maker-psm/scripts/vat.abi.json +0 -243
- 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/smoothy.d.ts +0 -26
- package/build/dex/smoothy.js +0 -48
- package/build/dex/smoothy.js.map +0 -1
- package/build/dex/solidly-v3/scripts/check-event-pool-event.d.ts +0 -1
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js +0 -53
- package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +0 -1
- package/build/dex/stable-pool.d.ts +0 -28
- package/build/dex/stable-pool.js +0 -55
- package/build/dex/stable-pool.js.map +0 -1
- package/build/dex/trader-joe-v2.1/base.d.ts +0 -18
- package/build/dex/trader-joe-v2.1/base.js +0 -99
- package/build/dex/trader-joe-v2.1/base.js.map +0 -1
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +0 -7
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +0 -20
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +0 -1
- package/build/dex/trader-joe-v2.1/trader-joe-v2.2.d.ts +0 -7
- package/build/dex/trader-joe-v2.1/trader-joe-v2.2.js +0 -20
- package/build/dex/trader-joe-v2.1/trader-joe-v2.2.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/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +0 -17
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +0 -64
- package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +0 -1
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +0 -17
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +0 -79
- package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +0 -1
- package/config.ts +0 -1946
- package/src/dex/dexs.txt +0 -58
|
@@ -0,0 +1,532 @@
|
|
|
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.Infusion = exports.InfusionRouterFunctions = void 0;
|
|
7
|
+
const uniswap_v2_1 = require("../uniswap-v2/uniswap-v2");
|
|
8
|
+
const constants_1 = require("../../constants");
|
|
9
|
+
const erc20_json_1 = __importDefault(require("../../abi/erc20.json"));
|
|
10
|
+
const utils_1 = require("../../utils");
|
|
11
|
+
const InfusionFactory_json_1 = __importDefault(require("../../abi/infusion/InfusionFactory.json"));
|
|
12
|
+
const InfusionPair_json_1 = __importDefault(require("../../abi/infusion/InfusionPair.json"));
|
|
13
|
+
const InfusionRouter_json_1 = __importDefault(require("../../abi/infusion/InfusionRouter.json"));
|
|
14
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
15
|
+
const core_1 = require("@paraswap/core");
|
|
16
|
+
const abi_1 = require("@ethersproject/abi");
|
|
17
|
+
const infusion_stable_pool_1 = require("./infusion-stable-pool");
|
|
18
|
+
const uniswap_v2_constant_product_pool_1 = require("../uniswap-v2/uniswap-v2-constant-product-pool");
|
|
19
|
+
const config_1 = require("./config");
|
|
20
|
+
const token_transfer_fee_1 = require("../../lib/token-transfer-fee");
|
|
21
|
+
const isStablePair_1 = require("./utils/isStablePair");
|
|
22
|
+
var InfusionRouterFunctions;
|
|
23
|
+
(function (InfusionRouterFunctions) {
|
|
24
|
+
InfusionRouterFunctions["sellExactEth"] = "swapExactETHForTokens";
|
|
25
|
+
InfusionRouterFunctions["sellExactToken"] = "swapExactTokensForETH";
|
|
26
|
+
InfusionRouterFunctions["swapExactIn"] = "swapExactTokensForTokens";
|
|
27
|
+
})(InfusionRouterFunctions = exports.InfusionRouterFunctions || (exports.InfusionRouterFunctions = {}));
|
|
28
|
+
const VelodromeFactoryABI = [
|
|
29
|
+
{
|
|
30
|
+
inputs: [{ internalType: 'bool', name: '_stable', type: 'bool' }],
|
|
31
|
+
name: 'getFee',
|
|
32
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
33
|
+
stateMutability: 'view',
|
|
34
|
+
type: 'function',
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
const velodromeFactoryIface = new abi_1.Interface(VelodromeFactoryABI);
|
|
38
|
+
const erc20Iface = new abi_1.Interface(erc20_json_1.default);
|
|
39
|
+
const infusionPairIface = new abi_1.Interface(InfusionPair_json_1.default);
|
|
40
|
+
const defaultAbiCoder = new abi_1.AbiCoder();
|
|
41
|
+
function encodePools(pools, feeFactor) {
|
|
42
|
+
return pools.map(({ fee, direction, address }) => {
|
|
43
|
+
return ((BigInt(feeFactor - fee) << 161n) +
|
|
44
|
+
((direction ? 0n : 1n) << 160n) +
|
|
45
|
+
BigInt(address)).toString();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
class Infusion extends uniswap_v2_1.UniswapV2 {
|
|
49
|
+
constructor(network, dexKey, dexHelper, isDynamicFees = true, factoryAddress, subgraphURL, initCode, feeCode, poolGasCost, routerAddress) {
|
|
50
|
+
super(network, dexKey, dexHelper, isDynamicFees, factoryAddress !== undefined
|
|
51
|
+
? factoryAddress
|
|
52
|
+
: config_1.InfusionConfig[dexKey][network].factoryAddress, subgraphURL === ''
|
|
53
|
+
? undefined
|
|
54
|
+
: subgraphURL !== undefined
|
|
55
|
+
? subgraphURL
|
|
56
|
+
: config_1.InfusionConfig[dexKey][network].subgraphURL, initCode !== undefined
|
|
57
|
+
? initCode
|
|
58
|
+
: config_1.InfusionConfig[dexKey][network].initCode, feeCode !== undefined ? feeCode : config_1.InfusionConfig[dexKey][network].feeCode, poolGasCost !== undefined
|
|
59
|
+
? poolGasCost
|
|
60
|
+
: config_1.InfusionConfig[dexKey][network].poolGasCost, infusionPairIface, config_1.Adapters[network] || undefined);
|
|
61
|
+
this.network = network;
|
|
62
|
+
this.dexHelper = dexHelper;
|
|
63
|
+
this.pairs = {};
|
|
64
|
+
this.isFeeOnTransferSupported = true;
|
|
65
|
+
this.SRC_TOKEN_DEX_TRANSFERS = 1;
|
|
66
|
+
this.DEST_TOKEN_DEX_TRANSFERS = 1;
|
|
67
|
+
this.stableFee = config_1.InfusionConfig[dexKey][network].stableFee;
|
|
68
|
+
this.volatileFee = config_1.InfusionConfig[dexKey][network].volatileFee;
|
|
69
|
+
this.factory = new dexHelper.web3Provider.eth.Contract(InfusionFactory_json_1.default, factoryAddress !== undefined
|
|
70
|
+
? factoryAddress
|
|
71
|
+
: config_1.InfusionConfig[dexKey][network].factoryAddress);
|
|
72
|
+
this.router =
|
|
73
|
+
routerAddress !== undefined
|
|
74
|
+
? routerAddress
|
|
75
|
+
: config_1.InfusionConfig[dexKey][network].router || '';
|
|
76
|
+
this.feeFactor =
|
|
77
|
+
config_1.InfusionConfig[dexKey][network].feeFactor || this.feeFactor;
|
|
78
|
+
// this.exchangeRouterInterface = new Interface(infusionRouterABI);
|
|
79
|
+
}
|
|
80
|
+
async findInfusionPair(from, to, stable) {
|
|
81
|
+
if (from.address.toLowerCase() === to.address.toLowerCase())
|
|
82
|
+
return null;
|
|
83
|
+
const [token0, token1] = from.address.toLowerCase() < to.address.toLowerCase()
|
|
84
|
+
? [from, to]
|
|
85
|
+
: [to, from];
|
|
86
|
+
const typePostfix = this.poolPostfix(stable);
|
|
87
|
+
const key = `${token0.address.toLowerCase()}-${token1.address.toLowerCase()}-${typePostfix}`;
|
|
88
|
+
let pair = this.pairs[key];
|
|
89
|
+
if (pair)
|
|
90
|
+
return pair;
|
|
91
|
+
let exchange = await this.factory.methods
|
|
92
|
+
// Infusion has additional boolean parameter "StablePool"
|
|
93
|
+
// At first we look for uniswap-like volatile pool
|
|
94
|
+
.getPair(token0.address, token1.address, stable)
|
|
95
|
+
.call();
|
|
96
|
+
if (exchange === constants_1.NULL_ADDRESS) {
|
|
97
|
+
pair = { token0, token1, stable };
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
pair = { token0, token1, exchange, stable };
|
|
101
|
+
}
|
|
102
|
+
this.pairs[key] = pair;
|
|
103
|
+
return pair;
|
|
104
|
+
}
|
|
105
|
+
async batchCatchUpPairs(pairs, blockNumber) {
|
|
106
|
+
if (!blockNumber)
|
|
107
|
+
return;
|
|
108
|
+
const pairsToFetch = [];
|
|
109
|
+
for (const _pair of pairs) {
|
|
110
|
+
for (const stable of [false, true]) {
|
|
111
|
+
const pair = await this.findInfusionPair(_pair[0], _pair[1], stable);
|
|
112
|
+
if (!(pair && pair.exchange))
|
|
113
|
+
continue;
|
|
114
|
+
if (!pair.pool) {
|
|
115
|
+
pairsToFetch.push(pair);
|
|
116
|
+
}
|
|
117
|
+
else if (!pair.pool.getState(blockNumber)) {
|
|
118
|
+
pairsToFetch.push(pair);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (!pairsToFetch.length)
|
|
123
|
+
return;
|
|
124
|
+
const reserves = await this.getManyPoolReserves(pairsToFetch, blockNumber);
|
|
125
|
+
if (reserves.length !== pairsToFetch.length) {
|
|
126
|
+
this.logger.error(`Error_getManyPoolReserves didn't get any pool reserves`);
|
|
127
|
+
}
|
|
128
|
+
for (let i = 0; i < pairsToFetch.length; i++) {
|
|
129
|
+
const pairState = reserves[i];
|
|
130
|
+
const pair = pairsToFetch[i];
|
|
131
|
+
if (!pair.pool) {
|
|
132
|
+
await this.addPool(pair, pairState.reserves0, pairState.reserves1, pairState.feeCode, blockNumber);
|
|
133
|
+
}
|
|
134
|
+
else
|
|
135
|
+
pair.pool.setState(pairState, blockNumber);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async getManyPoolReserves(pairs, blockNumber) {
|
|
139
|
+
try {
|
|
140
|
+
const multiCallFeeData = pairs.map(pair => this.getFeesMultiCallData(pair));
|
|
141
|
+
const calldata = pairs
|
|
142
|
+
.map((pair, i) => {
|
|
143
|
+
let calldata = [
|
|
144
|
+
{
|
|
145
|
+
target: pair.token0.address,
|
|
146
|
+
callData: erc20Iface.encodeFunctionData('balanceOf', [
|
|
147
|
+
pair.exchange,
|
|
148
|
+
]),
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
target: pair.token1.address,
|
|
152
|
+
callData: erc20Iface.encodeFunctionData('balanceOf', [
|
|
153
|
+
pair.exchange,
|
|
154
|
+
]),
|
|
155
|
+
},
|
|
156
|
+
];
|
|
157
|
+
if (this.isDynamicFees)
|
|
158
|
+
calldata.push(multiCallFeeData[i].callEntry);
|
|
159
|
+
return calldata;
|
|
160
|
+
})
|
|
161
|
+
.flat();
|
|
162
|
+
const data = await this.dexHelper.multiContract.methods
|
|
163
|
+
.aggregate(calldata)
|
|
164
|
+
.call({}, blockNumber);
|
|
165
|
+
const returnData = lodash_1.default.chunk(data.returnData, this.isDynamicFees ? 3 : 2);
|
|
166
|
+
return pairs.map((pair, i) => ({
|
|
167
|
+
reserves0: defaultAbiCoder
|
|
168
|
+
.decode(['uint256'], returnData[i][0])[0]
|
|
169
|
+
.toString(),
|
|
170
|
+
reserves1: defaultAbiCoder
|
|
171
|
+
.decode(['uint256'], returnData[i][1])[0]
|
|
172
|
+
.toString(),
|
|
173
|
+
feeCode: this.isDynamicFees
|
|
174
|
+
? multiCallFeeData[i].callDecoder(returnData[i][2])
|
|
175
|
+
: (pair.stable ? this.stableFee : this.volatileFee) || this.feeCode,
|
|
176
|
+
}));
|
|
177
|
+
}
|
|
178
|
+
catch (e) {
|
|
179
|
+
this.logger.error(`Error_getManyPoolReserves could not get reserves with error:`, e);
|
|
180
|
+
return [];
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async getSellPrice(priceParams, srcAmount) {
|
|
184
|
+
return priceParams.stable
|
|
185
|
+
? infusion_stable_pool_1.InfusionStablePool.getSellPrice(priceParams, srcAmount, this.feeFactor)
|
|
186
|
+
: uniswap_v2_constant_product_pool_1.Uniswapv2ConstantProductPool.getSellPrice(priceParams, srcAmount, this.feeFactor);
|
|
187
|
+
}
|
|
188
|
+
async getBuyPrice(priceParams, srcAmount) {
|
|
189
|
+
if (priceParams.stable)
|
|
190
|
+
throw new Error(`Buy not supported`);
|
|
191
|
+
return uniswap_v2_constant_product_pool_1.Uniswapv2ConstantProductPool.getBuyPrice(priceParams, srcAmount, this.feeFactor);
|
|
192
|
+
}
|
|
193
|
+
async getPricesVolume(_from, _to, amounts, side, blockNumber,
|
|
194
|
+
// list of pool identifiers to use for pricing, if undefined use all pools
|
|
195
|
+
limitPools, transferFees = {
|
|
196
|
+
srcFee: 0,
|
|
197
|
+
destFee: 0,
|
|
198
|
+
srcDexFee: 0,
|
|
199
|
+
destDexFee: 0,
|
|
200
|
+
}) {
|
|
201
|
+
try {
|
|
202
|
+
if (side === core_1.SwapSide.BUY)
|
|
203
|
+
return null; // Buy side not implemented yet
|
|
204
|
+
const from = this.dexHelper.config.wrapETH(_from);
|
|
205
|
+
const to = this.dexHelper.config.wrapETH(_to);
|
|
206
|
+
if (from.address.toLowerCase() === to.address.toLowerCase()) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
const tokenAddress = [
|
|
210
|
+
from.address.toLowerCase(),
|
|
211
|
+
to.address.toLowerCase(),
|
|
212
|
+
]
|
|
213
|
+
.sort((a, b) => (a > b ? 1 : -1))
|
|
214
|
+
.join('_');
|
|
215
|
+
await this.batchCatchUpPairs([[from, to]], blockNumber);
|
|
216
|
+
const resultPromises = [false, true].map(async (stable) => {
|
|
217
|
+
// We don't support fee on transfer for stable pools yet
|
|
218
|
+
if (stable &&
|
|
219
|
+
(transferFees.srcFee !== 0 || transferFees.srcDexFee !== 0)) {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
const poolIdentifier = `${this.dexKey}_${tokenAddress}` + this.poolPostfix(stable);
|
|
223
|
+
if (limitPools && limitPools.every(p => p !== poolIdentifier))
|
|
224
|
+
return null;
|
|
225
|
+
const isSell = side === core_1.SwapSide.SELL;
|
|
226
|
+
const pairParam = await this.getInfusionPairOrderedParams(from, to, blockNumber, stable, transferFees.srcDexFee);
|
|
227
|
+
if (!pairParam)
|
|
228
|
+
return null;
|
|
229
|
+
const unitAmount = (0, utils_1.getBigIntPow)(
|
|
230
|
+
// @ts-expect-error Buy side is not implemented yet
|
|
231
|
+
side === core_1.SwapSide.BUY ? to.decimals : from.decimals);
|
|
232
|
+
const [unitVolumeWithFee, ...amountsWithFee] = (0, token_transfer_fee_1.applyTransferFee)([unitAmount, ...amounts], side, isSell ? transferFees.srcFee : transferFees.destFee, isSell ? constants_1.SRC_TOKEN_PARASWAP_TRANSFERS : constants_1.DEST_TOKEN_PARASWAP_TRANSFERS);
|
|
233
|
+
const unit =
|
|
234
|
+
// @ts-expect-error Buy side is not implemented yet
|
|
235
|
+
side === core_1.SwapSide.BUY
|
|
236
|
+
? await this.getBuyPricePath(unitVolumeWithFee, [pairParam])
|
|
237
|
+
: await this.getSellPricePath(unitVolumeWithFee, [pairParam]);
|
|
238
|
+
const prices =
|
|
239
|
+
// @ts-expect-error Buy side is not implemented yet
|
|
240
|
+
side === core_1.SwapSide.BUY
|
|
241
|
+
? await Promise.all(amountsWithFee.map(amount => amount === 0n
|
|
242
|
+
? 0n
|
|
243
|
+
: this.getBuyPricePath(amount, [pairParam])))
|
|
244
|
+
: await Promise.all(amountsWithFee.map(amount => amount === 0n
|
|
245
|
+
? 0n
|
|
246
|
+
: this.getSellPricePath(amount, [pairParam])));
|
|
247
|
+
const [unitOutWithFee, ...outputsWithFee] = (0, token_transfer_fee_1.applyTransferFee)([unit, ...prices], side,
|
|
248
|
+
// This part is confusing, because we treat differently SELL and BUY fees
|
|
249
|
+
// If Buy, we should apply transfer fee on srcToken on top of dexFee applied earlier
|
|
250
|
+
// But for Sell we should apply only one dexFee
|
|
251
|
+
isSell ? transferFees.destDexFee : transferFees.srcFee, isSell ? this.DEST_TOKEN_DEX_TRANSFERS : constants_1.SRC_TOKEN_PARASWAP_TRANSFERS);
|
|
252
|
+
return {
|
|
253
|
+
prices: outputsWithFee,
|
|
254
|
+
unit: unitOutWithFee,
|
|
255
|
+
data: {
|
|
256
|
+
router: this.router,
|
|
257
|
+
path: [from.address.toLowerCase(), to.address.toLowerCase()],
|
|
258
|
+
factory: this.factoryAddress,
|
|
259
|
+
initCode: this.initCode,
|
|
260
|
+
feeFactor: this.feeFactor,
|
|
261
|
+
isFeeTokenInRoute: Object.values(transferFees).some(f => f !== 0),
|
|
262
|
+
pools: [
|
|
263
|
+
{
|
|
264
|
+
address: pairParam.exchange,
|
|
265
|
+
fee: parseInt(pairParam.fee),
|
|
266
|
+
direction: pairParam.direction,
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
},
|
|
270
|
+
exchange: this.dexKey,
|
|
271
|
+
poolIdentifier,
|
|
272
|
+
gasCost: this.poolGasCost,
|
|
273
|
+
poolAddresses: [pairParam.exchange],
|
|
274
|
+
};
|
|
275
|
+
});
|
|
276
|
+
const resultPools = (await Promise.all(resultPromises));
|
|
277
|
+
const resultPoolsFiltered = resultPools.filter(item => !!item); // filter null elements
|
|
278
|
+
return resultPoolsFiltered.length > 0 ? resultPoolsFiltered : null;
|
|
279
|
+
}
|
|
280
|
+
catch (e) {
|
|
281
|
+
if (blockNumber === 0)
|
|
282
|
+
this.logger.error(`Error_getPricesVolume: Aurelius block manager not yet instantiated`);
|
|
283
|
+
this.logger.error(`Error_getPrices:`, e);
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
async getTopPoolsForToken(tokenAddress, count) {
|
|
288
|
+
if (!this.subgraphURL)
|
|
289
|
+
return [];
|
|
290
|
+
let stableFieldKey = 'isStable';
|
|
291
|
+
// TODO: ?
|
|
292
|
+
// if (this.dexKey.toLowerCase() === 'infusion') {
|
|
293
|
+
// stableFieldKey = 'stable';
|
|
294
|
+
// } else if (this.dexKey.toLowerCase() !== 'infusionv2') {
|
|
295
|
+
// stableFieldKey = 'isStable';
|
|
296
|
+
// }
|
|
297
|
+
const query = `query ($token: Bytes!, $count: Int) {
|
|
298
|
+
pools0: pairs(first: $count, orderBy: reserveUSD, orderDirection: desc, where: {token0: $token, reserve0_gt: 1, reserve1_gt: 1}) {
|
|
299
|
+
id
|
|
300
|
+
${stableFieldKey}
|
|
301
|
+
token0 {
|
|
302
|
+
id
|
|
303
|
+
decimals
|
|
304
|
+
}
|
|
305
|
+
token1 {
|
|
306
|
+
id
|
|
307
|
+
decimals
|
|
308
|
+
}
|
|
309
|
+
reserveUSD
|
|
310
|
+
}
|
|
311
|
+
pools1: pairs(first: $count, orderBy: reserveUSD, orderDirection: desc, where: {token1: $token, reserve0_gt: 1, reserve1_gt: 1}) {
|
|
312
|
+
id
|
|
313
|
+
${stableFieldKey}
|
|
314
|
+
token0 {
|
|
315
|
+
id
|
|
316
|
+
decimals
|
|
317
|
+
}
|
|
318
|
+
token1 {
|
|
319
|
+
id
|
|
320
|
+
decimals
|
|
321
|
+
}
|
|
322
|
+
reserveUSD
|
|
323
|
+
}
|
|
324
|
+
}`;
|
|
325
|
+
const { data } = await this.dexHelper.httpRequest.post(this.subgraphURL, {
|
|
326
|
+
query,
|
|
327
|
+
variables: { token: tokenAddress.toLowerCase(), count },
|
|
328
|
+
}, constants_1.SUBGRAPH_TIMEOUT);
|
|
329
|
+
if (!(data && data.pools0 && data.pools1))
|
|
330
|
+
throw new Error("Couldn't fetch the pools from the subgraph");
|
|
331
|
+
const pools0 = lodash_1.default.map(data.pools0, pool => ({
|
|
332
|
+
exchange: this.dexKey,
|
|
333
|
+
stable: pool[stableFieldKey],
|
|
334
|
+
address: pool.id.toLowerCase(),
|
|
335
|
+
connectorTokens: [
|
|
336
|
+
{
|
|
337
|
+
address: pool.token1.id.toLowerCase(),
|
|
338
|
+
decimals: parseInt(pool.token1.decimals),
|
|
339
|
+
},
|
|
340
|
+
],
|
|
341
|
+
liquidityUSD: parseFloat(pool.reserveUSD),
|
|
342
|
+
}));
|
|
343
|
+
const pools1 = lodash_1.default.map(data.pools1, pool => ({
|
|
344
|
+
exchange: this.dexKey,
|
|
345
|
+
stable: pool[stableFieldKey],
|
|
346
|
+
address: pool.id.toLowerCase(),
|
|
347
|
+
connectorTokens: [
|
|
348
|
+
{
|
|
349
|
+
address: pool.token0.id.toLowerCase(),
|
|
350
|
+
decimals: parseInt(pool.token0.decimals),
|
|
351
|
+
},
|
|
352
|
+
],
|
|
353
|
+
liquidityUSD: parseFloat(pool.reserveUSD),
|
|
354
|
+
}));
|
|
355
|
+
return lodash_1.default.slice(lodash_1.default.sortBy(lodash_1.default.concat(pools0, pools1), [pool => -1 * pool.liquidityUSD]), 0, count);
|
|
356
|
+
}
|
|
357
|
+
// Same as at uniswap-v2-pool.json, but extended with decimals and stable
|
|
358
|
+
async getInfusionPairOrderedParams(from, to, blockNumber, stable, tokenDexTransferFee) {
|
|
359
|
+
const pair = await this.findInfusionPair(from, to, stable);
|
|
360
|
+
if (!(pair && pair.pool && pair.exchange))
|
|
361
|
+
return null;
|
|
362
|
+
const pairState = pair.pool.getState(blockNumber);
|
|
363
|
+
if (!pairState) {
|
|
364
|
+
this.logger.error(`Error_orderPairParams expected reserves, got none (maybe the pool doesn't exist) ${from.symbol || from.address} ${to.symbol || to.address}`);
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
const fee = (pairState.feeCode + tokenDexTransferFee).toString();
|
|
368
|
+
const pairReversed = pair.token1.address.toLowerCase() === from.address.toLowerCase();
|
|
369
|
+
if (pairReversed) {
|
|
370
|
+
return {
|
|
371
|
+
tokenIn: from.address,
|
|
372
|
+
tokenOut: to.address,
|
|
373
|
+
reservesIn: pairState.reserves1,
|
|
374
|
+
reservesOut: pairState.reserves0,
|
|
375
|
+
fee,
|
|
376
|
+
direction: false,
|
|
377
|
+
exchange: pair.exchange,
|
|
378
|
+
decimalsIn: from.decimals,
|
|
379
|
+
decimalsOut: to.decimals,
|
|
380
|
+
stable,
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
return {
|
|
384
|
+
tokenIn: from.address,
|
|
385
|
+
tokenOut: to.address,
|
|
386
|
+
reservesIn: pairState.reserves0,
|
|
387
|
+
reservesOut: pairState.reserves1,
|
|
388
|
+
fee,
|
|
389
|
+
direction: true,
|
|
390
|
+
exchange: pair.exchange,
|
|
391
|
+
decimalsIn: from.decimals,
|
|
392
|
+
decimalsOut: to.decimals,
|
|
393
|
+
stable,
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
async getPoolIdentifiers(_from, _to, side, blockNumber) {
|
|
397
|
+
if (side === core_1.SwapSide.BUY)
|
|
398
|
+
return [];
|
|
399
|
+
const from = this.dexHelper.config.wrapETH(_from);
|
|
400
|
+
const to = this.dexHelper.config.wrapETH(_to);
|
|
401
|
+
if (from.address.toLowerCase() === to.address.toLowerCase()) {
|
|
402
|
+
return [];
|
|
403
|
+
}
|
|
404
|
+
const tokenAddress = [from.address.toLowerCase(), to.address.toLowerCase()]
|
|
405
|
+
.sort((a, b) => (a > b ? 1 : -1))
|
|
406
|
+
.join('_');
|
|
407
|
+
const poolIdentifier = `${this.dexKey}_${tokenAddress}`;
|
|
408
|
+
const poolIdentifierUniswap = poolIdentifier + this.poolPostfix(false);
|
|
409
|
+
const poolIdentifierStable = poolIdentifier + this.poolPostfix(true);
|
|
410
|
+
return [poolIdentifierUniswap, poolIdentifierStable];
|
|
411
|
+
}
|
|
412
|
+
poolPostfix(stable) {
|
|
413
|
+
return stable ? 'S' : 'V';
|
|
414
|
+
}
|
|
415
|
+
async getSimpleParam(src, dest, srcAmount, destAmount, data, side) {
|
|
416
|
+
if (side === core_1.SwapSide.BUY)
|
|
417
|
+
throw new Error(`Buy not supported`);
|
|
418
|
+
let routerMethod;
|
|
419
|
+
let routerArgs;
|
|
420
|
+
const stable = (0, isStablePair_1.isStablePair)(this.network, src, dest);
|
|
421
|
+
const from = (0, utils_1.isETHAddress)(src)
|
|
422
|
+
? this.dexHelper.config.data.wrappedNativeTokenAddress
|
|
423
|
+
: src;
|
|
424
|
+
const to = (0, utils_1.isETHAddress)(dest)
|
|
425
|
+
? this.dexHelper.config.data.wrappedNativeTokenAddress
|
|
426
|
+
: dest;
|
|
427
|
+
routerMethod = (0, utils_1.isETHAddress)(src)
|
|
428
|
+
? InfusionRouterFunctions.sellExactEth
|
|
429
|
+
: InfusionRouterFunctions.swapExactIn;
|
|
430
|
+
routerMethod = (0, utils_1.isETHAddress)(dest)
|
|
431
|
+
? InfusionRouterFunctions.sellExactToken
|
|
432
|
+
: routerMethod;
|
|
433
|
+
routerArgs = (0, utils_1.isETHAddress)(src)
|
|
434
|
+
? [
|
|
435
|
+
destAmount,
|
|
436
|
+
[{ from, to, stable }],
|
|
437
|
+
this.augustusAddress,
|
|
438
|
+
Math.floor(new Date().getTime()) + 120,
|
|
439
|
+
]
|
|
440
|
+
: [
|
|
441
|
+
srcAmount,
|
|
442
|
+
destAmount,
|
|
443
|
+
[{ from, to, stable }],
|
|
444
|
+
this.augustusAddress,
|
|
445
|
+
Math.floor(new Date().getTime()) + 120,
|
|
446
|
+
];
|
|
447
|
+
// console.log('routerMethod', routerMethod, 'routerArgs', routerArgs);
|
|
448
|
+
const swapData = new abi_1.Interface(InfusionRouter_json_1.default).encodeFunctionData(routerMethod, routerArgs);
|
|
449
|
+
return this.buildSimpleParamWithoutWETHConversion(src, srcAmount, dest, destAmount, swapData, data.router);
|
|
450
|
+
}
|
|
451
|
+
getAdapterParam(srcToken, destToken, srcAmount, toAmount, // required for buy case
|
|
452
|
+
data, side) {
|
|
453
|
+
// if (side === SwapSide.BUY) throw new Error(`Buy not supported`);
|
|
454
|
+
// const pools = encodePools(data.pools, this.feeFactor);
|
|
455
|
+
// const weth = this.getWETHAddress(srcToken, destToken, data.wethAddress);
|
|
456
|
+
// const payload = this.abiCoder.encodeParameter(
|
|
457
|
+
// {
|
|
458
|
+
// ParentStruct: {
|
|
459
|
+
// weth: 'address',
|
|
460
|
+
// pools: 'uint256[]',
|
|
461
|
+
// isFeeTokenInRoute: 'bool',
|
|
462
|
+
// },
|
|
463
|
+
// },
|
|
464
|
+
// { weth, pools, isFeeTokenInRoute: data.isFeeTokenInRoute },
|
|
465
|
+
// );
|
|
466
|
+
return {
|
|
467
|
+
targetExchange: data.router,
|
|
468
|
+
payload: '',
|
|
469
|
+
networkFee: '0',
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
getDexParam(src, dest, srcAmount, destAmount, recipient, data, side) {
|
|
473
|
+
if (side === core_1.SwapSide.BUY)
|
|
474
|
+
throw new Error(`Buy not supported`);
|
|
475
|
+
let routerMethod;
|
|
476
|
+
let routerArgs;
|
|
477
|
+
const stable = (0, isStablePair_1.isStablePair)(this.network, src, dest);
|
|
478
|
+
const from = (0, utils_1.isETHAddress)(src)
|
|
479
|
+
? this.dexHelper.config.data.wrappedNativeTokenAddress
|
|
480
|
+
: src;
|
|
481
|
+
const to = (0, utils_1.isETHAddress)(dest)
|
|
482
|
+
? this.dexHelper.config.data.wrappedNativeTokenAddress
|
|
483
|
+
: dest;
|
|
484
|
+
routerMethod = (0, utils_1.isETHAddress)(src)
|
|
485
|
+
? InfusionRouterFunctions.sellExactEth
|
|
486
|
+
: InfusionRouterFunctions.swapExactIn;
|
|
487
|
+
routerMethod = (0, utils_1.isETHAddress)(dest)
|
|
488
|
+
? InfusionRouterFunctions.sellExactToken
|
|
489
|
+
: routerMethod;
|
|
490
|
+
routerArgs = (0, utils_1.isETHAddress)(src)
|
|
491
|
+
? [
|
|
492
|
+
destAmount,
|
|
493
|
+
[{ from, to, stable }],
|
|
494
|
+
recipient,
|
|
495
|
+
Math.floor(new Date().getTime()) + 120,
|
|
496
|
+
]
|
|
497
|
+
: [
|
|
498
|
+
srcAmount,
|
|
499
|
+
destAmount,
|
|
500
|
+
[{ from, to, stable }],
|
|
501
|
+
recipient,
|
|
502
|
+
Math.floor(new Date().getTime()) + 120,
|
|
503
|
+
];
|
|
504
|
+
// console.log('routerMethod', routerMethod, 'routerArgs', routerArgs);
|
|
505
|
+
const exchangeData = new abi_1.Interface(InfusionRouter_json_1.default).encodeFunctionData(routerMethod, routerArgs);
|
|
506
|
+
return {
|
|
507
|
+
needWrapNative: this.needWrapNative,
|
|
508
|
+
dexFuncHasRecipient: true,
|
|
509
|
+
exchangeData,
|
|
510
|
+
targetExchange: data.router,
|
|
511
|
+
returnAmountPos: undefined,
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
getFeesMultiCallData(pair) {
|
|
515
|
+
const callEntry = {
|
|
516
|
+
target: this.factoryAddress,
|
|
517
|
+
callData: velodromeFactoryIface.encodeFunctionData('getFee', [
|
|
518
|
+
pair.stable,
|
|
519
|
+
]),
|
|
520
|
+
};
|
|
521
|
+
const callDecoder = (values) => parseInt(velodromeFactoryIface
|
|
522
|
+
.decodeFunctionResult('getFee', values)[0]
|
|
523
|
+
.toString());
|
|
524
|
+
return {
|
|
525
|
+
callEntry,
|
|
526
|
+
callDecoder,
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
exports.Infusion = Infusion;
|
|
531
|
+
Infusion.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(lodash_1.default.pick(config_1.InfusionConfig, ['Infusion']));
|
|
532
|
+
//# sourceMappingURL=infusion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infusion.js","sourceRoot":"","sources":["../../../src/dex/infusion/infusion.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAqD;AACrD,+CAMyB;AAYzB,sEAA4C;AAE5C,uCAAgF;AAChF,mGAAyE;AACzE,6FAAmE;AACnE,iGAAuE;AACvE,oDAAuB;AACvB,yCAA0D;AAC1D,4CAAyD;AACzD,iEAA4D;AAC5D,qGAA8F;AAS9F,qCAAoD;AACpD,qEAAgE;AAChE,uDAAoD;AAGpD,IAAY,uBAIX;AAJD,WAAY,uBAAuB;IACjC,iEAAsC,CAAA;IACtC,mEAAwC,CAAA;IACxC,mEAAwC,CAAA;AAC1C,CAAC,EAJW,uBAAuB,GAAvB,+BAAuB,KAAvB,+BAAuB,QAIlC;AAOD,MAAM,mBAAmB,GAAG;IAC1B;QACE,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACjE,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QACjE,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;CACF,CAAC;AAE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;SACH,CAAC;QACF,MAAM,WAAW,GAAG,CAAC,MAAa,EAAE,EAAE,CACpC,QAAQ,CACN,qBAAqB;aAClB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;aACzC,QAAQ,EAAE,CACd,CAAC;QAEJ,OAAO;YACL,SAAS;YACT,WAAW;SACZ,CAAC;IACJ,CAAC;;AAtrBH,4BAurBC;AA9qBe,2BAAkB,GAC9B,IAAA,6BAAqB,EAAC,gBAAC,CAAC,IAAI,CAAC,uBAAc,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { UniswapV2Data, UniswapV2PoolOrderedParams, DexParams as UniswapV2DexParams, UniswapPool } from '../uniswap-v2/types';
|
|
2
|
+
import { UniswapV2Pair } from '../uniswap-v2/uniswap-v2';
|
|
3
|
+
export declare type PoolState = {
|
|
4
|
+
reserves0: string;
|
|
5
|
+
reserves1: string;
|
|
6
|
+
feeCode: number;
|
|
7
|
+
};
|
|
8
|
+
export interface InfusionPoolOrderedParams extends UniswapV2PoolOrderedParams {
|
|
9
|
+
decimalsIn: number;
|
|
10
|
+
decimalsOut: number;
|
|
11
|
+
stable: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare type InfusionData = UniswapV2Data & {
|
|
14
|
+
isFeeTokenInRoute: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare type InfusionPool = UniswapPool;
|
|
17
|
+
export interface DexParams extends Omit<UniswapV2DexParams, 'feeCode'> {
|
|
18
|
+
feeCode: number;
|
|
19
|
+
stableFee?: number;
|
|
20
|
+
volatileFee?: number;
|
|
21
|
+
feeFactor?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface InfusionPair extends UniswapV2Pair {
|
|
24
|
+
stable: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare type InfusionParam = SellOnInfusionParam | SellETHOnInfusionParam;
|
|
27
|
+
export declare type SellOnInfusionParam = [
|
|
28
|
+
amountIn: string,
|
|
29
|
+
amountOutMin: string,
|
|
30
|
+
routes: {
|
|
31
|
+
from: string;
|
|
32
|
+
to: string;
|
|
33
|
+
stable: boolean;
|
|
34
|
+
}[],
|
|
35
|
+
to: string,
|
|
36
|
+
deadline: number
|
|
37
|
+
];
|
|
38
|
+
export declare type SellETHOnInfusionParam = [
|
|
39
|
+
amountOutMin: string,
|
|
40
|
+
routes: {
|
|
41
|
+
from: string;
|
|
42
|
+
to: string;
|
|
43
|
+
stable: boolean;
|
|
44
|
+
}[],
|
|
45
|
+
to: string,
|
|
46
|
+
deadline: number
|
|
47
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/infusion/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isStablePair = exports.stablecoins = void 0;
|
|
4
|
+
const constants_1 = require("../../../constants");
|
|
5
|
+
exports.stablecoins = {
|
|
6
|
+
[constants_1.Network.BASE]: [
|
|
7
|
+
'0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'.toLowerCase(),
|
|
8
|
+
'0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA'.toLowerCase(),
|
|
9
|
+
'0xEB466342C4d449BC9f53A865D5Cb90586f405215'.toLowerCase(), // axelar usdc
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
function isStablePair(chainId, tokenA, tokenB) {
|
|
13
|
+
const stables = exports.stablecoins[chainId];
|
|
14
|
+
return (stables.includes(tokenA.toLocaleLowerCase()) &&
|
|
15
|
+
stables.includes(tokenB.toLocaleLowerCase()));
|
|
16
|
+
}
|
|
17
|
+
exports.isStablePair = isStablePair;
|
|
18
|
+
//# sourceMappingURL=isStablePair.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isStablePair.js","sourceRoot":"","sources":["../../../../src/dex/infusion/utils/isStablePair.ts"],"names":[],"mappings":";;;AAAA,kDAA6C;AAEhC,QAAA,WAAW,GAA6B;IACnD,CAAC,mBAAO,CAAC,IAAI,CAAC,EAAE;QACd,4CAA4C,CAAC,WAAW,EAAE;QAC1D,4CAA4C,CAAC,WAAW,EAAE;QAC1D,4CAA4C,CAAC,WAAW,EAAE,EAAE,cAAc;KAC3E;CACF,CAAC;AAEF,SAAgB,YAAY,CAAC,OAAe,EAAE,MAAc,EAAE,MAAc;IAC1E,MAAM,OAAO,GAAG,mBAAW,CAAC,OAAO,CAAC,CAAC;IAErC,OAAO,CACL,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAC7C,CAAC;AACJ,CAAC;AAPD,oCAOC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DexParams } from './types';
|
|
2
|
+
import { DexConfigMap, AdapterMappings } from '../../types';
|
|
3
|
+
export declare const OSWAP_GAS_COST = 80000;
|
|
4
|
+
export declare const OSwapConfig: DexConfigMap<DexParams>;
|
|
5
|
+
export declare const Adapters: Record<number, AdapterMappings>;
|