@paraswap/dex-lib 2.18.6-thenav1 → 2.19.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/DirectSwap.json +1008 -0
- package/package.json +1 -1
- package/src/dex/solidly/solidly-e2e.test.ts +6 -28
- package/.idea/aws.xml +0 -17
- package/.idea/codeStyles/Project.xml +0 -19
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/paraswap-dex-lib.iml +0 -9
- package/.idea/vcs.xml +0 -6
- package/build/abi/swaap-v2/vault.json +0 -918
- package/build/dex/aave-v3/tokens/arbitrum.json +0 -50
- package/build/dex/aave-v3/tokens/avalanche.json +0 -74
- package/build/dex/aave-v3/tokens/fantom.json +0 -62
- package/build/dex/aave-v3/tokens/optimism.json +0 -50
- package/build/dex/aave-v3/tokens/polygon.json +0 -116
- package/build/dex/pancakeswap-v3/types.d.ts +0 -14
- package/build/dex/pancakeswap-v3/types.js +0 -3
- package/build/dex/pancakeswap-v3/types.js.map +0 -1
- package/build/dex/swaap-v2/config.d.ts +0 -4
- package/build/dex/swaap-v2/config.js +0 -25
- package/build/dex/swaap-v2/config.js.map +0 -1
- package/build/dex/swaap-v2/constants.d.ts +0 -9
- package/build/dex/swaap-v2/constants.js +0 -13
- package/build/dex/swaap-v2/constants.js.map +0 -1
- package/build/dex/swaap-v2/rate-fetcher.d.ts +0 -16
- package/build/dex/swaap-v2/rate-fetcher.js +0 -100
- package/build/dex/swaap-v2/rate-fetcher.js.map +0 -1
- package/build/dex/swaap-v2/swaap-v2.d.ts +0 -55
- package/build/dex/swaap-v2/swaap-v2.js +0 -465
- package/build/dex/swaap-v2/swaap-v2.js.map +0 -1
- package/build/dex/swaap-v2/types.d.ts +0 -64
- package/build/dex/swaap-v2/types.js +0 -7
- package/build/dex/swaap-v2/types.js.map +0 -1
- package/build/dex/swaap-v2/utils.d.ts +0 -7
- package/build/dex/swaap-v2/utils.js +0 -34
- package/build/dex/swaap-v2/utils.js.map +0 -1
- package/build/dex/swaap-v2/validators.d.ts +0 -5
- package/build/dex/swaap-v2/validators.js +0 -120
- package/build/dex/swaap-v2/validators.js.map +0 -1
|
@@ -1,465 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.SwaapV2 = void 0;
|
|
30
|
-
const constants_1 = require("../../constants");
|
|
31
|
-
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
32
|
-
const utils_1 = require("../../utils");
|
|
33
|
-
const types_1 = require("./types");
|
|
34
|
-
const simple_exchange_1 = require("../simple-exchange");
|
|
35
|
-
const config_1 = require("./config");
|
|
36
|
-
const rate_fetcher_1 = require("./rate-fetcher");
|
|
37
|
-
const vault_json_1 = __importDefault(require("../../abi/swaap-v2/vault.json"));
|
|
38
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
39
|
-
const bignumber_constants_1 = require("../../bignumber-constants");
|
|
40
|
-
const utils_2 = require("ethers/lib/utils");
|
|
41
|
-
const ts_essentials_1 = require("ts-essentials");
|
|
42
|
-
const constants_2 = require("./constants");
|
|
43
|
-
const utils_3 = require("./utils");
|
|
44
|
-
class SwaapV2 extends simple_exchange_1.SimpleExchange {
|
|
45
|
-
constructor(network, dexKey, dexHelper, adapters = config_1.Adapters[network] || {}, routerAddressPlaceholder = config_1.SwaapV2Config['SwaapV2'][network].routerAddress, routerInterface = new utils_2.Interface(vault_json_1.default)) {
|
|
46
|
-
super(dexHelper, dexKey);
|
|
47
|
-
this.network = network;
|
|
48
|
-
this.dexKey = dexKey;
|
|
49
|
-
this.dexHelper = dexHelper;
|
|
50
|
-
this.adapters = adapters;
|
|
51
|
-
this.routerAddressPlaceholder = routerAddressPlaceholder;
|
|
52
|
-
this.routerInterface = routerInterface;
|
|
53
|
-
this.isStatePollingDex = true;
|
|
54
|
-
this.hasConstantPriceLargeAmounts = false;
|
|
55
|
-
this.needWrapNative = false;
|
|
56
|
-
this.isFeeOnTransferSupported = false;
|
|
57
|
-
this.computeMaxLiquidity = (levels, tokenAddress) => {
|
|
58
|
-
if (tokenAddress === levels.base) {
|
|
59
|
-
return ((levels.asks[levels.asks.length - 1]?.level ?? 0) *
|
|
60
|
-
levels.asks[0]?.price);
|
|
61
|
-
}
|
|
62
|
-
return ((levels.asks[levels.bids.length - 1]?.level ?? 0) * levels.asks[0]?.price);
|
|
63
|
-
};
|
|
64
|
-
this.logger = dexHelper.getLogger(dexKey);
|
|
65
|
-
const token = dexHelper.config.data.swaapV2AuthToken;
|
|
66
|
-
(0, ts_essentials_1.assert)(token !== undefined, 'SwaapV2 auth token is not specified with env variable');
|
|
67
|
-
this.swaapV2AuthToken = token;
|
|
68
|
-
this.rateFetcher = new rate_fetcher_1.RateFetcher(this.dexHelper, this.dexKey, this.logger, {
|
|
69
|
-
rateConfig: {
|
|
70
|
-
pricesIntervalMs: constants_2.SWAAP_RFQ_API_PRICES_POLLING_INTERVAL_MS,
|
|
71
|
-
pricesReqParams: this.getPriceLevelsReqParams(),
|
|
72
|
-
pricesCacheTTLSecs: constants_2.SWAAP_RFQ_PRICES_CACHES_TTL_S,
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
async initializePricing(blockNumber) {
|
|
77
|
-
if (!this.dexHelper.config.isSlave) {
|
|
78
|
-
await this.rateFetcher.start();
|
|
79
|
-
}
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
getAdapters(side) {
|
|
83
|
-
return this.adapters[side] ? this.adapters[side] : null;
|
|
84
|
-
}
|
|
85
|
-
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
86
|
-
const normalizedSrcToken = this.normalizeToken(srcToken);
|
|
87
|
-
const normalizedDestToken = this.normalizeToken(destToken);
|
|
88
|
-
if (normalizedSrcToken.address === normalizedDestToken.address) {
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
const poolIdentifier = (0, utils_3.getPoolIdentifier)(this.dexKey, normalizedSrcToken.address, normalizedDestToken.address);
|
|
92
|
-
const levels = await this.getCachedLevels();
|
|
93
|
-
if (levels === null) {
|
|
94
|
-
return [];
|
|
95
|
-
}
|
|
96
|
-
return Object.keys(levels)
|
|
97
|
-
.map((pair) => {
|
|
98
|
-
return (0, utils_3.getPoolIdentifier)(this.dexKey, levels[pair].base, levels[pair].quote);
|
|
99
|
-
})
|
|
100
|
-
.filter((pi) => pi === poolIdentifier);
|
|
101
|
-
}
|
|
102
|
-
computePricesFromLevelsBis(amounts, asksAndBids, srcToken, destToken, side) {
|
|
103
|
-
let levels = [];
|
|
104
|
-
if (side === constants_1.SwapSide.BUY) {
|
|
105
|
-
if (destToken.address === asksAndBids.base) {
|
|
106
|
-
levels = asksAndBids.asks;
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
levels = this.invertPrices(asksAndBids.bids);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
if (srcToken.address === asksAndBids.base) {
|
|
114
|
-
levels = asksAndBids.bids;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
levels = this.invertPrices(asksAndBids.asks);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return this.computeLevelsQuote(amounts, levels, srcToken, destToken, side);
|
|
121
|
-
}
|
|
122
|
-
inversePrice(priceLevel) {
|
|
123
|
-
return {
|
|
124
|
-
level: priceLevel.level * priceLevel.price,
|
|
125
|
-
price: 1 / priceLevel.price,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
invertPrices(levels) {
|
|
129
|
-
return levels.map(pl => this.inversePrice(pl));
|
|
130
|
-
}
|
|
131
|
-
computeLevelsQuote(amounts, levels, srcToken, destToken, side) {
|
|
132
|
-
const size = levels.length;
|
|
133
|
-
if (size === 0) {
|
|
134
|
-
return amounts.map(_ => BigInt(0));
|
|
135
|
-
}
|
|
136
|
-
return amounts.map((amount) => {
|
|
137
|
-
if (amount.isZero() || amount.lt((0, bignumber_js_1.default)(levels[0].level))) {
|
|
138
|
-
return BigInt(0);
|
|
139
|
-
}
|
|
140
|
-
let i = 0;
|
|
141
|
-
let output = bignumber_constants_1.BN_0;
|
|
142
|
-
let previousLevel = bignumber_constants_1.BN_0;
|
|
143
|
-
let remaininig = (0, bignumber_js_1.default)(amount);
|
|
144
|
-
let enoughLiquidity = false;
|
|
145
|
-
while (i < size) {
|
|
146
|
-
const levelDelta = (0, bignumber_js_1.default)(levels[i].level).minus(previousLevel);
|
|
147
|
-
if (levelDelta.lte(remaininig)) {
|
|
148
|
-
output = output.plus(levelDelta.times(levels[i].price));
|
|
149
|
-
remaininig = remaininig.minus(levelDelta);
|
|
150
|
-
previousLevel = (0, bignumber_js_1.default)(levels[i].level);
|
|
151
|
-
i += 1;
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
output = output.plus(remaininig.times(levels[i].price));
|
|
155
|
-
enoughLiquidity = true;
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
if (enoughLiquidity) {
|
|
160
|
-
return BigInt(output
|
|
161
|
-
.multipliedBy((0, bignumber_constants_1.getBigNumberPow)(side === constants_1.SwapSide.BUY ? srcToken.decimals : destToken.decimals))
|
|
162
|
-
.toFixed(0));
|
|
163
|
-
}
|
|
164
|
-
return BigInt(0); // not enough liquidity
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
async getCachedLevels() {
|
|
168
|
-
const cachedLevels = await this.dexHelper.cache.get(this.dexKey, this.network, (0, utils_3.getPriceLevelsCacheKey)(this.dexKey));
|
|
169
|
-
if (cachedLevels) {
|
|
170
|
-
return JSON.parse(cachedLevels);
|
|
171
|
-
}
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
normalizeToken(token) {
|
|
175
|
-
return {
|
|
176
|
-
address: (0, utils_3.normalizeTokenAddress)(token.address),
|
|
177
|
-
decimals: token.decimals,
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
181
|
-
const normalizedSrcToken = this.normalizeToken(srcToken);
|
|
182
|
-
const normalizedDestToken = this.normalizeToken(destToken);
|
|
183
|
-
const requestedPoolIdentifier = (0, utils_3.getPoolIdentifier)(this.dexKey, normalizedSrcToken.address, normalizedDestToken.address);
|
|
184
|
-
if (normalizedSrcToken.address === normalizedDestToken.address) {
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
|
-
const pools = limitPools ??
|
|
188
|
-
(await this.getPoolIdentifiers(srcToken, destToken, side, blockNumber));
|
|
189
|
-
const levels = await this.getCachedLevels();
|
|
190
|
-
if (levels === null) {
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
|
-
const levelEntries = Object.keys(levels)
|
|
194
|
-
.map((pair) => {
|
|
195
|
-
if (pools.includes((0, utils_3.getPoolIdentifier)(this.dexKey, normalizedSrcToken.address, normalizedDestToken.address))) {
|
|
196
|
-
return levels[pair];
|
|
197
|
-
}
|
|
198
|
-
return undefined;
|
|
199
|
-
})
|
|
200
|
-
.filter(o => o !== undefined)
|
|
201
|
-
.map(o => o);
|
|
202
|
-
const prices = levelEntries.map((askAndBids) => {
|
|
203
|
-
const divider = (0, bignumber_constants_1.getBigNumberPow)((side === constants_1.SwapSide.SELL ? normalizedSrcToken : normalizedDestToken)
|
|
204
|
-
.decimals);
|
|
205
|
-
const amountsFloat = amounts.map(a => new bignumber_js_1.default(a.toString()).dividedBy(divider));
|
|
206
|
-
const unitPrice = this.computePricesFromLevelsBis([bignumber_constants_1.BN_1], askAndBids, normalizedSrcToken, normalizedDestToken, side)[0];
|
|
207
|
-
const prices = this.computePricesFromLevelsBis(amountsFloat, askAndBids, normalizedSrcToken, normalizedDestToken, side);
|
|
208
|
-
return {
|
|
209
|
-
gasCost: constants_2.GAS_COST_ESTIMATION,
|
|
210
|
-
exchange: this.dexKey,
|
|
211
|
-
data: {},
|
|
212
|
-
prices,
|
|
213
|
-
unit: unitPrice,
|
|
214
|
-
poolIdentifier: requestedPoolIdentifier,
|
|
215
|
-
poolAddresses: [this.routerAddressPlaceholder],
|
|
216
|
-
};
|
|
217
|
-
});
|
|
218
|
-
return prices;
|
|
219
|
-
}
|
|
220
|
-
getBaseToken(poolIdentifier) {
|
|
221
|
-
return poolIdentifier.split('_')[1];
|
|
222
|
-
}
|
|
223
|
-
getLevels(askAndBids, side, poolIdentifier) {
|
|
224
|
-
const baseToken = this.getBaseToken(poolIdentifier);
|
|
225
|
-
if (side === constants_1.SwapSide.SELL) {
|
|
226
|
-
return askAndBids.asks;
|
|
227
|
-
}
|
|
228
|
-
return askAndBids.asks;
|
|
229
|
-
}
|
|
230
|
-
async preProcessTransaction(optimalSwapExchange, srcToken, destToken, side, options) {
|
|
231
|
-
const isSell = side === constants_1.SwapSide.SELL;
|
|
232
|
-
const normalizedSrcToken = this.normalizeToken(srcToken);
|
|
233
|
-
const normalizedDestToken = this.normalizeToken(destToken);
|
|
234
|
-
const tolerance = (options.slippageFactor > bignumber_constants_1.BN_1
|
|
235
|
-
? options.slippageFactor.minus(bignumber_constants_1.BN_1)
|
|
236
|
-
: bignumber_constants_1.BN_1.minus(options.slippageFactor)).toNumber();
|
|
237
|
-
const quote = await this.rateFetcher.getQuote(this.network, normalizedSrcToken, normalizedDestToken, isSell ? optimalSwapExchange.srcAmount : optimalSwapExchange.destAmount, isSell ? 1 : 2, options.txOrigin, this.augustusAddress, tolerance, this.getQuoteReqParams());
|
|
238
|
-
if (!quote.success) {
|
|
239
|
-
const message = `${this.dexKey}-${this.network}: Failed to fetch RFQ for ${(0, utils_3.getPairName)(normalizedSrcToken.address, normalizedDestToken.address)}: ${JSON.stringify(quote)}`;
|
|
240
|
-
this.logger.warn(message);
|
|
241
|
-
throw new types_1.SwaapV2QuoteError(message);
|
|
242
|
-
}
|
|
243
|
-
else if (!quote.calldata) {
|
|
244
|
-
const message = `${this.dexKey}-${this.network}: Failed to fetch RFQ for ${(0, utils_3.getPairName)(normalizedSrcToken.address, normalizedDestToken.address)}. Missing quote data`;
|
|
245
|
-
this.logger.warn(message);
|
|
246
|
-
throw new types_1.SwaapV2QuoteError(message);
|
|
247
|
-
}
|
|
248
|
-
else if (!quote.router) {
|
|
249
|
-
const message = `${this.dexKey}-${this.network}: Failed to fetch RFQ for ${(0, utils_3.getPairName)(normalizedSrcToken.address, normalizedDestToken.address)}. Missing router address`;
|
|
250
|
-
this.logger.warn(message);
|
|
251
|
-
throw new types_1.SwaapV2QuoteError(message);
|
|
252
|
-
}
|
|
253
|
-
return [
|
|
254
|
-
{
|
|
255
|
-
...optimalSwapExchange,
|
|
256
|
-
data: {
|
|
257
|
-
router: quote.router,
|
|
258
|
-
callData: quote.calldata,
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
{ deadline: BigInt((0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)()) },
|
|
262
|
-
];
|
|
263
|
-
}
|
|
264
|
-
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
265
|
-
getCalldataGasCost(poolPrices) {
|
|
266
|
-
return (CALLDATA_GAS_COST.DEX_OVERHEAD +
|
|
267
|
-
CALLDATA_GAS_COST.LENGTH_LARGE +
|
|
268
|
-
// ParentStruct header
|
|
269
|
-
CALLDATA_GAS_COST.OFFSET_SMALL +
|
|
270
|
-
// ParentStruct -> swaps[] header
|
|
271
|
-
CALLDATA_GAS_COST.OFFSET_LARGE +
|
|
272
|
-
// ParentStruct -> assets[] header
|
|
273
|
-
CALLDATA_GAS_COST.OFFSET_LARGE +
|
|
274
|
-
// ParentStruct -> funds
|
|
275
|
-
CALLDATA_GAS_COST.ADDRESS +
|
|
276
|
-
CALLDATA_GAS_COST.BOOL +
|
|
277
|
-
CALLDATA_GAS_COST.ADDRESS +
|
|
278
|
-
CALLDATA_GAS_COST.BOOL +
|
|
279
|
-
// ParentStruct -> limits[] header
|
|
280
|
-
CALLDATA_GAS_COST.OFFSET_LARGE +
|
|
281
|
-
// ParentStruct -> deadline
|
|
282
|
-
CALLDATA_GAS_COST.TIMESTAMP +
|
|
283
|
-
// ParentStruct -> swaps[]
|
|
284
|
-
CALLDATA_GAS_COST.LENGTH_SMALL +
|
|
285
|
-
// ParentStruct -> swaps[0] header
|
|
286
|
-
CALLDATA_GAS_COST.OFFSET_SMALL +
|
|
287
|
-
// ParentStruct -> swaps[0] -> poolId
|
|
288
|
-
CALLDATA_GAS_COST.FULL_WORD +
|
|
289
|
-
// ParentStruct -> swaps[0] -> assetInIndex
|
|
290
|
-
CALLDATA_GAS_COST.INDEX +
|
|
291
|
-
// ParentStruct -> swaps[0] -> assetOutIndex
|
|
292
|
-
CALLDATA_GAS_COST.INDEX +
|
|
293
|
-
// ParentStruct -> swaps[0] -> amount
|
|
294
|
-
CALLDATA_GAS_COST.AMOUNT +
|
|
295
|
-
// ParentStruct -> swaps[0] -> userData header
|
|
296
|
-
CALLDATA_GAS_COST.OFFSET_SMALL +
|
|
297
|
-
// ParentStruct -> swaps[0] -> userData
|
|
298
|
-
CALLDATA_GAS_COST.ZERO +
|
|
299
|
-
// ParentStruct -> assets[]
|
|
300
|
-
CALLDATA_GAS_COST.LENGTH_SMALL +
|
|
301
|
-
// ParentStruct -> assets[0:2]
|
|
302
|
-
CALLDATA_GAS_COST.ADDRESS * 2 +
|
|
303
|
-
// ParentStruct -> limits[]
|
|
304
|
-
CALLDATA_GAS_COST.LENGTH_SMALL +
|
|
305
|
-
// ParentStruct -> limits[0:2]
|
|
306
|
-
CALLDATA_GAS_COST.FULL_WORD * 2 +
|
|
307
|
-
// Bool -> IsBatchSwap
|
|
308
|
-
CALLDATA_GAS_COST.BOOL);
|
|
309
|
-
}
|
|
310
|
-
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
311
|
-
const { router, callData } = data;
|
|
312
|
-
(0, ts_essentials_1.assert)(router !== undefined, `${this.dexKey}-${this.network}: router undefined`);
|
|
313
|
-
(0, ts_essentials_1.assert)(callData !== undefined, `${this.dexKey}-${this.network}: callData undefined`);
|
|
314
|
-
let payload;
|
|
315
|
-
const truncatedCalldata = '0x' + callData.slice(10); // droping the function selector
|
|
316
|
-
const isBatchSwap = callData.slice(0, 10) === constants_2.BATCH_SWAP_SELECTOR;
|
|
317
|
-
if (isBatchSwap) {
|
|
318
|
-
const batchswapAbi = vault_json_1.default.filter(abi => abi.name === 'batchSwap');
|
|
319
|
-
const callDataStruct = this.abiCoder.decodeParameters(batchswapAbi[0].inputs, truncatedCalldata);
|
|
320
|
-
const callerSlots = Array(callDataStruct.swaps.length).fill(160);
|
|
321
|
-
payload = this.abiCoder.encodeParameters([
|
|
322
|
-
'bool',
|
|
323
|
-
'uint256[]',
|
|
324
|
-
{
|
|
325
|
-
ParentStruct: {
|
|
326
|
-
'swaps[]': {
|
|
327
|
-
poolId: 'bytes32',
|
|
328
|
-
assetInIndex: 'uint256',
|
|
329
|
-
assetOutIndex: 'uint256',
|
|
330
|
-
amount: 'uint256',
|
|
331
|
-
userData: 'bytes',
|
|
332
|
-
},
|
|
333
|
-
assets: 'address[]',
|
|
334
|
-
funds: {
|
|
335
|
-
sender: 'address',
|
|
336
|
-
fromInternalBalance: 'bool',
|
|
337
|
-
recipient: 'address',
|
|
338
|
-
toInternalBalance: 'bool',
|
|
339
|
-
},
|
|
340
|
-
limits: 'int256[]',
|
|
341
|
-
},
|
|
342
|
-
},
|
|
343
|
-
], [
|
|
344
|
-
isBatchSwap,
|
|
345
|
-
callerSlots,
|
|
346
|
-
{
|
|
347
|
-
swaps: callDataStruct.swaps,
|
|
348
|
-
assets: callDataStruct.assets,
|
|
349
|
-
funds: callDataStruct.funds,
|
|
350
|
-
limits: callDataStruct.limits.map((_) => constants_1.MAX_INT),
|
|
351
|
-
},
|
|
352
|
-
]);
|
|
353
|
-
}
|
|
354
|
-
else {
|
|
355
|
-
const swapAbi = vault_json_1.default.filter(abi => abi.name === 'swap');
|
|
356
|
-
const callDataStruct = this.abiCoder.decodeParameters(swapAbi[0].inputs, truncatedCalldata);
|
|
357
|
-
const callerSlot = constants_2.CALLER_SLOT;
|
|
358
|
-
payload = this.abiCoder.encodeParameters([
|
|
359
|
-
'bool',
|
|
360
|
-
'uint256',
|
|
361
|
-
{
|
|
362
|
-
ParentStruct: {
|
|
363
|
-
swap: {
|
|
364
|
-
poolId: 'bytes32',
|
|
365
|
-
kind: 'uint8',
|
|
366
|
-
assetIn: 'address',
|
|
367
|
-
assetOut: 'address',
|
|
368
|
-
amount: 'uint256',
|
|
369
|
-
userData: 'bytes',
|
|
370
|
-
},
|
|
371
|
-
funds: {
|
|
372
|
-
sender: 'address',
|
|
373
|
-
fromInternalBalance: 'bool',
|
|
374
|
-
recipient: 'address',
|
|
375
|
-
toInternalBalance: 'bool',
|
|
376
|
-
},
|
|
377
|
-
limit: 'uint256',
|
|
378
|
-
},
|
|
379
|
-
},
|
|
380
|
-
], [
|
|
381
|
-
isBatchSwap,
|
|
382
|
-
callerSlot,
|
|
383
|
-
{
|
|
384
|
-
swap: {
|
|
385
|
-
poolId: callDataStruct.singleSwap.poolId,
|
|
386
|
-
kind: callDataStruct.singleSwap.kind,
|
|
387
|
-
assetIn: callDataStruct.singleSwap.assetIn,
|
|
388
|
-
assetOut: callDataStruct.singleSwap.assetOut,
|
|
389
|
-
amount: callDataStruct.singleSwap.amount,
|
|
390
|
-
userData: callDataStruct.singleSwap.userData,
|
|
391
|
-
},
|
|
392
|
-
funds: {
|
|
393
|
-
sender: callDataStruct.funds.sender,
|
|
394
|
-
fromInternalBalance: callDataStruct.funds.fromInternalBalance,
|
|
395
|
-
recipient: callDataStruct.funds.recipient,
|
|
396
|
-
toInternalBalance: callDataStruct.funds.toInternalBalance,
|
|
397
|
-
},
|
|
398
|
-
limit: side === constants_1.SwapSide.BUY ? constants_1.MAX_UINT : '0',
|
|
399
|
-
},
|
|
400
|
-
]);
|
|
401
|
-
}
|
|
402
|
-
return {
|
|
403
|
-
targetExchange: router,
|
|
404
|
-
payload: payload,
|
|
405
|
-
networkFee: '0',
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
409
|
-
const { router, callData } = data;
|
|
410
|
-
(0, ts_essentials_1.assert)(router !== undefined, `${this.dexKey}-${this.network}: router undefined`);
|
|
411
|
-
(0, ts_essentials_1.assert)(callData !== undefined, `${this.dexKey}-${this.network}: callData undefined`);
|
|
412
|
-
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, callData, router);
|
|
413
|
-
}
|
|
414
|
-
async getTopPoolsForToken(tokenAddress, limit) {
|
|
415
|
-
const normalizedTokenAddress = (0, utils_3.normalizeTokenAddress)(tokenAddress);
|
|
416
|
-
const pLevels = await this.getCachedLevels();
|
|
417
|
-
if (pLevels === null) {
|
|
418
|
-
return [];
|
|
419
|
-
}
|
|
420
|
-
return Object.keys(pLevels)
|
|
421
|
-
.filter((pair) => {
|
|
422
|
-
return (normalizedTokenAddress === pLevels[pair].base ||
|
|
423
|
-
normalizedTokenAddress === pLevels[pair].quote);
|
|
424
|
-
})
|
|
425
|
-
.map((pair) => {
|
|
426
|
-
return {
|
|
427
|
-
exchange: this.dexKey,
|
|
428
|
-
address: this.routerAddressPlaceholder,
|
|
429
|
-
connectorTokens: [this.getTokenFromAddress(pLevels[pair].quote)],
|
|
430
|
-
liquidityUSD: this.computeMaxLiquidity(pLevels[pair], tokenAddress),
|
|
431
|
-
};
|
|
432
|
-
})
|
|
433
|
-
.sort((pl) => {
|
|
434
|
-
return -pl.liquidityUSD;
|
|
435
|
-
})
|
|
436
|
-
.slice(0, limit);
|
|
437
|
-
}
|
|
438
|
-
getTokenFromAddress(address) {
|
|
439
|
-
return { address, decimals: 0 };
|
|
440
|
-
}
|
|
441
|
-
releaseResources() {
|
|
442
|
-
if (this.rateFetcher) {
|
|
443
|
-
this.rateFetcher.stop();
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
getPriceLevelsReqParams() {
|
|
447
|
-
return this.geAPIReqParams(constants_2.SWAAP_RFQ_PRICES_ENDPOINT, 'GET');
|
|
448
|
-
}
|
|
449
|
-
getQuoteReqParams() {
|
|
450
|
-
return this.geAPIReqParams(constants_2.SWAAP_RFQ_QUOTE_ENDPOINT, 'POST');
|
|
451
|
-
}
|
|
452
|
-
geAPIReqParams(endpoint, method) {
|
|
453
|
-
return {
|
|
454
|
-
url: `${constants_2.SWAAP_RFQ_API_URL}/${endpoint}`,
|
|
455
|
-
params: {
|
|
456
|
-
networkId: this.network,
|
|
457
|
-
},
|
|
458
|
-
headers: { 'x-api-key': this.swaapV2AuthToken },
|
|
459
|
-
method: method,
|
|
460
|
-
};
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
exports.SwaapV2 = SwaapV2;
|
|
464
|
-
SwaapV2.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.SwaapV2Config);
|
|
465
|
-
//# sourceMappingURL=swaap-v2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"swaap-v2.js","sourceRoot":"","sources":["../../../src/dex/swaap-v2/swaap-v2.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,+CAAuE;AACvE,2EAA6D;AAC7D,uCAAoD;AAGpD,mCAMiB;AACjB,wDAA2F;AAC3F,qCAAmD;AACnD,iDAA6C;AAC7C,+EAAsD;AACtD,gEAAqC;AACrC,mEAAwE;AACxE,4CAA6C;AAC7C,iDAAuC;AACvC,2CASqB;AACrB,mCAKiB;AAGjB,MAAa,OAAQ,SAAQ,gCAAc;IAazC,YACW,OAAgB,EAChB,MAAc,EACd,SAAqB,EACpB,WAAW,iBAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EACnC,2BAAmC,sBAAa,CAAC,SAAS,CAAC,CAClE,OAAO,CACR,CAAC,aAAa,EACL,kBAAkB,IAAI,iBAAS,CAAC,oBAAS,CAAC;QAEpD,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAThB,YAAO,GAAP,OAAO,CAAS;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAY;QACpB,aAAQ,GAAR,QAAQ,CAA0B;QACnC,6BAAwB,GAAxB,wBAAwB,CAElB;QACL,oBAAe,GAAf,eAAe,CAA2B;QApB7C,sBAAiB,GAAG,IAAI,CAAC;QACzB,iCAA4B,GAAG,K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QACrB,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,EAAiB,EAAE,EAAE;YAC1B,OAAO,CAAC,EAAE,CAAC,YAAY,CAAC;QAC1B,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACrB,CAAC;IAED,mBAAmB,CAAC,OAAgB;QAClC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IAClC,CAAC;IAED,gBAAgB;QACd,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;SACzB;IACH,CAAC;IAED,uBAAuB;QACrB,OAAO,IAAI,CAAC,cAAc,CAAC,qCAAyB,EAAE,KAAK,CAAC,CAAC;IAC/D,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,cAAc,CAAC,oCAAwB,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;IAED,cAAc,CAAC,QAAgB,EAAE,MAAc;QAC7C,OAAO;YACL,GAAG,EAAE,GAAG,6BAAiB,IAAI,QAAQ,EAAE;YACvC,MAAM,EAAE;gBACN,SAAS,EAAE,IAAI,CAAC,OAAO;aACxB;YACD,OAAO,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,gBAAgB,EAAE;YAC/C,MAAM,EAAE,MAAM;SACf,CAAC;IACJ,CAAC;;AAppBH,0BAqpBC;AA7oBe,0BAAkB,GAC9B,IAAA,6BAAqB,EAAC,sBAAa,CAAC,CAAC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { RequestHeaders } from '../../dex-helper';
|
|
2
|
-
import { Method } from '../../dex-helper/irequest-wrapper';
|
|
3
|
-
export declare type SwaapV2Data = {
|
|
4
|
-
router: string;
|
|
5
|
-
callData: string;
|
|
6
|
-
};
|
|
7
|
-
export declare type DexParams = {
|
|
8
|
-
routerAddress: string;
|
|
9
|
-
};
|
|
10
|
-
export declare class SwaapV2QuoteError extends Error {
|
|
11
|
-
}
|
|
12
|
-
export interface SwaapV2PriceLevel {
|
|
13
|
-
level: number;
|
|
14
|
-
price: number;
|
|
15
|
-
}
|
|
16
|
-
export declare type SwaapV2PriceLevels = {
|
|
17
|
-
bids: Array<SwaapV2PriceLevel>;
|
|
18
|
-
asks: Array<SwaapV2PriceLevel>;
|
|
19
|
-
quote: string;
|
|
20
|
-
base: string;
|
|
21
|
-
};
|
|
22
|
-
export declare type SwaapV2PriceLevelsResponse = {
|
|
23
|
-
levels: Record<string, SwaapV2PriceLevels>;
|
|
24
|
-
success: boolean;
|
|
25
|
-
};
|
|
26
|
-
export declare type SwaapV2RateFetcherConfig = {
|
|
27
|
-
rateConfig: {
|
|
28
|
-
pricesReqParams: SwaapV2APIParameters;
|
|
29
|
-
pricesIntervalMs: number;
|
|
30
|
-
pricesCacheTTLSecs: number;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
export declare type SwaapV2QuoteResponse = {
|
|
34
|
-
id: string;
|
|
35
|
-
calldata: string;
|
|
36
|
-
router: string;
|
|
37
|
-
expiration: number;
|
|
38
|
-
amount: string;
|
|
39
|
-
recipient: string;
|
|
40
|
-
guaranteed_price: number;
|
|
41
|
-
success: boolean;
|
|
42
|
-
};
|
|
43
|
-
export declare enum SwaapV2OrderType {
|
|
44
|
-
SELL = 1,
|
|
45
|
-
BUY = 2
|
|
46
|
-
}
|
|
47
|
-
export declare type SwaapV2QuoteRequest = {
|
|
48
|
-
network_id: number;
|
|
49
|
-
origin: string;
|
|
50
|
-
sender: string;
|
|
51
|
-
recipient: string;
|
|
52
|
-
timestamp: number;
|
|
53
|
-
order_type: SwaapV2OrderType;
|
|
54
|
-
token_in: string;
|
|
55
|
-
token_out: string;
|
|
56
|
-
amount: string;
|
|
57
|
-
tolerance: number;
|
|
58
|
-
};
|
|
59
|
-
export declare type SwaapV2APIParameters = {
|
|
60
|
-
url: string;
|
|
61
|
-
headers?: RequestHeaders;
|
|
62
|
-
params?: any;
|
|
63
|
-
method?: Method;
|
|
64
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/swaap-v2/types.ts"],"names":[],"mappings":";;;AAYA,MAAa,iBAAkB,SAAQ,KAAK;CAAG;AAA/C,8CAA+C"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Address } from '../../types';
|
|
2
|
-
export declare const getIdentifierPrefix: (dexKey: string, srcAddress: Address, destAddress: Address) => string;
|
|
3
|
-
export declare const getPairName: (srcAddress: Address, destAddress: Address) => string;
|
|
4
|
-
export declare const getCacheKey: (dexKey: string, cacheType: string) => string;
|
|
5
|
-
export declare const getPriceLevelsCacheKey: (dexKey: string) => string;
|
|
6
|
-
export declare const getPoolIdentifier: (dexKey: string, srcAddress: Address, destAddress: Address) => string;
|
|
7
|
-
export declare const normalizeTokenAddress: (address: string) => string;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeTokenAddress = exports.getPoolIdentifier = exports.getPriceLevelsCacheKey = exports.getCacheKey = exports.getPairName = exports.getIdentifierPrefix = void 0;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
5
|
-
const getIdentifierPrefix = (dexKey, srcAddress, destAddress) => {
|
|
6
|
-
return `${dexKey}_${(0, exports.getPairName)(srcAddress, destAddress)}`.toLowerCase();
|
|
7
|
-
};
|
|
8
|
-
exports.getIdentifierPrefix = getIdentifierPrefix;
|
|
9
|
-
const getPairName = (srcAddress, destAddress) => {
|
|
10
|
-
const sortedAddresses = srcAddress < destAddress
|
|
11
|
-
? [srcAddress, destAddress]
|
|
12
|
-
: [destAddress, srcAddress];
|
|
13
|
-
return `${sortedAddresses[0]}_${sortedAddresses[1]}`.toLowerCase();
|
|
14
|
-
};
|
|
15
|
-
exports.getPairName = getPairName;
|
|
16
|
-
const getCacheKey = (dexKey, cacheType) => {
|
|
17
|
-
return `${constants_1.CACHE_PREFIX}_${dexKey}_${cacheType}`.toLowerCase();
|
|
18
|
-
};
|
|
19
|
-
exports.getCacheKey = getCacheKey;
|
|
20
|
-
const getPriceLevelsCacheKey = (dexKey) => {
|
|
21
|
-
return (0, exports.getCacheKey)(dexKey, 'price_levels');
|
|
22
|
-
};
|
|
23
|
-
exports.getPriceLevelsCacheKey = getPriceLevelsCacheKey;
|
|
24
|
-
const getPoolIdentifier = (dexKey, srcAddress, destAddress) => {
|
|
25
|
-
return `${(0, exports.getIdentifierPrefix)(dexKey, srcAddress, destAddress)}`.toLowerCase();
|
|
26
|
-
};
|
|
27
|
-
exports.getPoolIdentifier = getPoolIdentifier;
|
|
28
|
-
const normalizeTokenAddress = (address) => {
|
|
29
|
-
return address.toLowerCase() === constants_1.ETHER_ADDRESS
|
|
30
|
-
? constants_1.NULL_ADDRESS
|
|
31
|
-
: address.toLowerCase();
|
|
32
|
-
};
|
|
33
|
-
exports.normalizeTokenAddress = normalizeTokenAddress;
|
|
34
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/swaap-v2/utils.ts"],"names":[],"mappings":";;;AACA,+CAA4E;AAErE,MAAM,mBAAmB,GAAG,CACjC,MAAc,EACd,UAAmB,EACnB,WAAoB,EACpB,EAAE;IACF,OAAO,GAAG,MAAM,IAAI,IAAA,mBAAW,EAAC,UAAU,EAAE,WAAW,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;AAC3E,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B;AAEK,MAAM,WAAW,GAAG,CAAC,UAAmB,EAAE,WAAoB,EAAE,EAAE;IACvE,MAAM,eAAe,GACrB,UAAU,GAAG,WAAW;QACtB,CAAC,CAAC,CAAC,UAAU,EAAE,WAAW,CAAC;QAC3B,CAAC,CAAC,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAC9B,OAAO,GAAG,eAAe,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;AACrE,CAAC,CAAA;AANY,QAAA,WAAW,eAMvB;AAEM,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,SAAiB,EAAE,EAAE;IAC/D,OAAO,GAAG,wBAAY,IAAI,MAAM,IAAI,SAAS,EAAE,CAAC,WAAW,EAAE,CAAC;AAChE,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB;AAEK,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAE,EAAE;IACvD,OAAO,IAAA,mBAAW,EAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAC7C,CAAC,CAAC;AAFW,QAAA,sBAAsB,0BAEjC;AAEK,MAAM,iBAAiB,GAAG,CAC/B,MAAc,EACd,UAAmB,EACnB,WAAoB,EACpB,EAAE;IACF,OAAO,GAAG,IAAA,2BAAmB,EAC3B,MAAM,EACN,UAAU,EACV,WAAW,CACZ,EAAE,CAAC,WAAW,EAAE,CAAC;AACpB,CAAC,CAAC;AAVW,QAAA,iBAAiB,qBAU5B;AAEK,MAAM,qBAAqB,GAAG,CAAC,OAAe,EAAU,EAAE;IAC/D,OAAO,OAAO,CAAC,WAAW,EAAE,KAAK,yBAAa;QAC5C,CAAC,CAAC,wBAAY;QACd,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;AAC5B,CAAC,CAAC;AAJW,QAAA,qBAAqB,yBAIhC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import joi from 'joi';
|
|
2
|
-
export declare const priceLevelsResponseValidator: joi.ObjectSchema<any>;
|
|
3
|
-
export declare const addressSchema: joi.StringSchema<string>;
|
|
4
|
-
export declare const blacklistResponseValidator: joi.ObjectSchema<any>;
|
|
5
|
-
export declare const getQuoteResponseValidator: joi.ObjectSchema<any>;
|