@paraswap/dex-lib 4.7.5-unified-blacklist.3 → 4.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/abi/BProtocol.json +1155 -0
- package/build/abi/Jarvis.json +1172 -0
- package/build/abi/MStableAsset.json +1545 -0
- package/build/abi/OneInchLp.json +1304 -0
- package/build/abi/Onebit.json +736 -0
- package/build/abi/Shell.json +1294 -0
- package/build/abi/TraderJoeV2Router.json +50 -0
- package/build/abi/wUSDM.json +757 -0
- package/build/abi/zrx.v2.json +1967 -0
- package/build/abi/zrx.v3.json +3454 -0
- package/build/abi/zrx.v4.json +2193 -0
- package/build/dex/OneInchLp.d.ts +24 -0
- package/build/dex/OneInchLp.js +43 -0
- package/build/dex/OneInchLp.js.map +1 -0
- package/build/dex/bProtocol/bProtocol.d.ts +15 -0
- package/build/dex/bProtocol/bProtocol.js +56 -0
- package/build/dex/bProtocol/bProtocol.js.map +1 -0
- package/build/dex/bProtocol/types.d.ts +11 -0
- package/build/dex/bProtocol/types.js +8 -0
- package/build/dex/bProtocol/types.js.map +1 -0
- package/build/dex/balancer-v2/balancer-v2.d.ts +1 -1
- package/build/dex/balancer-v2/balancer-v2.js +39 -37
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/balancer-v2/constants.d.ts +1 -0
- package/build/dex/balancer-v2/constants.js +2 -1
- package/build/dex/balancer-v2/constants.js.map +1 -1
- package/build/dex/bebop/bebop.d.ts +1 -1
- package/build/dex/bebop/bebop.js +27 -16
- package/build/dex/bebop/bebop.js.map +1 -1
- package/build/dex/curve-v1/config.js +21 -21
- package/build/dex/curve-v1/config.js.map +1 -1
- package/build/dex/curve-v1/curve-v1.d.ts +3 -1
- package/build/dex/curve-v1/curve-v1.js +26 -1
- package/build/dex/curve-v1/curve-v1.js.map +1 -1
- package/build/dex/curve-v1/types.d.ts +6 -0
- package/build/dex/dexalot/constants.d.ts +1 -0
- package/build/dex/dexalot/constants.js +2 -1
- package/build/dex/dexalot/constants.js.map +1 -1
- package/build/dex/dexalot/dexalot.js +1 -1
- package/build/dex/dexalot/dexalot.js.map +1 -1
- package/build/dex/generic-rfq/types.d.ts +6 -0
- package/build/dex/generic-rfq/types.js +12 -1
- package/build/dex/generic-rfq/types.js.map +1 -1
- package/build/dex/idle-dao/idle-dao.d.ts +0 -1
- package/build/dex/idle-dao/idle-dao.js +11 -23
- package/build/dex/idle-dao/idle-dao.js.map +1 -1
- package/build/dex/jarvis.d.ts +56 -0
- package/build/dex/jarvis.js +163 -0
- package/build/dex/jarvis.js.map +1 -0
- package/build/dex/mStable.d.ts +44 -0
- package/build/dex/mStable.js +75 -0
- package/build/dex/mStable.js.map +1 -0
- package/build/dex/maker-psm/maker-psm.d.ts +41 -4
- package/build/dex/maker-psm/maker-psm.js +143 -40
- package/build/dex/maker-psm/maker-psm.js.map +1 -1
- package/build/dex/onebit/onebit.d.ts +16 -0
- package/build/dex/onebit/onebit.js +61 -0
- package/build/dex/onebit/onebit.js.map +1 -0
- package/build/dex/onebit/types.d.ts +14 -0
- package/build/dex/onebit/types.js +8 -0
- package/build/dex/onebit/types.js.map +1 -0
- package/build/dex/se-vlr/config.d.ts +3 -0
- package/build/dex/se-vlr/config.js +24 -0
- package/build/dex/se-vlr/config.js.map +1 -0
- package/build/dex/{maker-psm/maker-psm-event-pool.d.ts → se-vlr/se-vlr-pool.d.ts} +11 -15
- package/build/dex/se-vlr/se-vlr-pool.js +70 -0
- package/build/dex/se-vlr/se-vlr-pool.js.map +1 -0
- package/build/dex/se-vlr/se-vlr.d.ts +35 -0
- package/build/dex/se-vlr/se-vlr.js +131 -0
- package/build/dex/se-vlr/se-vlr.js.map +1 -0
- package/build/dex/se-vlr/types.d.ts +6 -0
- package/build/dex/se-vlr/types.js +3 -0
- package/build/dex/se-vlr/types.js.map +1 -0
- package/build/dex/shell.d.ts +25 -0
- package/build/dex/shell.js +41 -0
- package/build/dex/shell.js.map +1 -0
- package/build/dex/simple-exchange-with-restrictions.js +2 -2
- package/build/dex/simple-exchange-with-restrictions.js.map +1 -1
- package/build/dex/trader-joe-v2.d.ts +40 -0
- package/build/dex/trader-joe-v2.js +74 -0
- package/build/dex/trader-joe-v2.js.map +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-new.d.ts +94 -0
- package/build/dex/uniswap-v3/uniswap-v3-new.js +923 -0
- package/build/dex/uniswap-v3/uniswap-v3-new.js.map +1 -0
- package/build/dex/uniswap-v4/contract-math/Position.d.ts +0 -6
- package/build/dex/uniswap-v4/contract-math/Position.js +0 -29
- package/build/dex/uniswap-v4/contract-math/Position.js.map +1 -1
- package/build/dex/uniswap-v4/subgraph.js +6 -0
- package/build/dex/uniswap-v4/subgraph.js.map +1 -1
- package/build/dex/uniswap-v4/types.d.ts +3 -0
- package/build/dex/uniswap-v4/uniswap-v4-pool-manager.d.ts +5 -1
- package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js +86 -0
- package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js.map +1 -1
- package/build/dex/uniswap-v4/uniswap-v4.d.ts +1 -1
- package/build/dex/uniswap-v4/uniswap-v4.js +50 -36
- package/build/dex/uniswap-v4/uniswap-v4.js.map +1 -1
- package/build/dex/usual-bond/config.d.ts +3 -0
- package/build/dex/usual-bond/config.js +13 -0
- package/build/dex/usual-bond/config.js.map +1 -0
- package/build/dex/usual-bond/types.d.ts +7 -0
- package/build/dex/usual-bond/types.js +3 -0
- package/build/dex/usual-bond/types.js.map +1 -0
- package/build/dex/usual-bond/usual-bond.d.ts +35 -0
- package/build/dex/usual-bond/usual-bond.js +176 -0
- package/build/dex/usual-bond/usual-bond.js.map +1 -0
- package/build/dex/wusdm/config.d.ts +3 -0
- package/build/dex/wusdm/config.js +43 -0
- package/build/dex/wusdm/config.js.map +1 -0
- package/build/dex/wusdm/constants.d.ts +2 -0
- package/build/dex/wusdm/constants.js +6 -0
- package/build/dex/wusdm/constants.js.map +1 -0
- package/build/dex/wusdm/types.d.ts +18 -0
- package/build/dex/wusdm/types.js +11 -0
- package/build/dex/wusdm/types.js.map +1 -0
- package/build/dex/wusdm/wusdm-pool.d.ts +21 -0
- package/build/dex/wusdm/wusdm-pool.js +74 -0
- package/build/dex/wusdm/wusdm-pool.js.map +1 -0
- package/build/dex/wusdm/wusdm.d.ts +46 -0
- package/build/dex/wusdm/wusdm.js +243 -0
- package/build/dex/wusdm/wusdm.js.map +1 -0
- package/build/dex/zerox/config.d.ts +2 -0
- package/build/dex/zerox/config.js +33 -0
- package/build/dex/zerox/config.js.map +1 -0
- package/build/dex/zerox/index.d.ts +22 -0
- package/build/dex/zerox/index.js +225 -0
- package/build/dex/zerox/index.js.map +1 -0
- package/build/dex/zerox/order.d.ts +88 -0
- package/build/dex/zerox/order.js +53 -0
- package/build/dex/zerox/order.js.map +1 -0
- package/build/dex/zerox/types.d.ts +73 -0
- package/build/dex/zerox/types.js +21 -0
- package/build/dex/zerox/types.js.map +1 -0
- package/package.json +1 -1
- package/build/dex/maker-psm/maker-psm-event-pool.js +0 -132
- package/build/dex/maker-psm/maker-psm-event-pool.js.map +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AsyncOrSync } from 'ts-essentials';
|
|
2
|
+
import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, PoolLiquidity, Logger } from '../../types';
|
|
3
|
+
import { SwapSide, Network } from '../../constants';
|
|
4
|
+
import { IDex } from '../../dex/idex';
|
|
5
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
6
|
+
import { SeVlrData } from './types';
|
|
7
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
8
|
+
import { SeVlrEventPool } from './se-vlr-pool';
|
|
9
|
+
export declare class SeVlr extends SimpleExchange implements IDex<SeVlrData> {
|
|
10
|
+
readonly network: Network;
|
|
11
|
+
readonly dexKey: string;
|
|
12
|
+
readonly dexHelper: IDexHelper;
|
|
13
|
+
protected eventPools: SeVlrEventPool;
|
|
14
|
+
readonly hasConstantPriceLargeAmounts = false;
|
|
15
|
+
readonly needWrapNative = true;
|
|
16
|
+
readonly isFeeOnTransferSupported = false;
|
|
17
|
+
static dexKeysWithNetwork: {
|
|
18
|
+
key: string;
|
|
19
|
+
networks: Network[];
|
|
20
|
+
}[];
|
|
21
|
+
logger: Logger;
|
|
22
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper);
|
|
23
|
+
initializePricing(blockNumber: number): Promise<void>;
|
|
24
|
+
getAdapters(side: SwapSide): {
|
|
25
|
+
name: string;
|
|
26
|
+
index: number;
|
|
27
|
+
}[] | null;
|
|
28
|
+
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
29
|
+
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<SeVlrData>>;
|
|
30
|
+
getCalldataGasCost(poolPrices: PoolPrices<SeVlrData>): number | number[];
|
|
31
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: SeVlrData, side: SwapSide): AdapterExchangeParam;
|
|
32
|
+
updatePoolState(): Promise<void>;
|
|
33
|
+
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
34
|
+
releaseResources(): AsyncOrSync<void>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SeVlr = void 0;
|
|
37
|
+
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
38
|
+
const utils_1 = require("../../utils");
|
|
39
|
+
const simple_exchange_1 = require("../simple-exchange");
|
|
40
|
+
const config_1 = require("./config");
|
|
41
|
+
const se_vlr_pool_1 = require("./se-vlr-pool");
|
|
42
|
+
class SeVlr extends simple_exchange_1.SimpleExchange {
|
|
43
|
+
network;
|
|
44
|
+
dexKey;
|
|
45
|
+
dexHelper;
|
|
46
|
+
eventPools;
|
|
47
|
+
hasConstantPriceLargeAmounts = false;
|
|
48
|
+
// TODO: set true here if protocols works only with wrapped asset
|
|
49
|
+
needWrapNative = true;
|
|
50
|
+
isFeeOnTransferSupported = false;
|
|
51
|
+
static dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.SeVlrConfig);
|
|
52
|
+
logger;
|
|
53
|
+
constructor(network, dexKey, dexHelper) {
|
|
54
|
+
super(dexHelper, dexKey);
|
|
55
|
+
this.network = network;
|
|
56
|
+
this.dexKey = dexKey;
|
|
57
|
+
this.dexHelper = dexHelper;
|
|
58
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
59
|
+
this.eventPools = new se_vlr_pool_1.SeVlrEventPool(dexKey, network, dexHelper, this.logger);
|
|
60
|
+
}
|
|
61
|
+
// Initialize pricing is called once in the start of
|
|
62
|
+
// pricing service. It is intended to setup the integration
|
|
63
|
+
// for pricing requests. It is optional for a DEX to
|
|
64
|
+
// implement this function
|
|
65
|
+
async initializePricing(blockNumber) {
|
|
66
|
+
// TODO: complete me!
|
|
67
|
+
}
|
|
68
|
+
// Legacy: was only used for V5
|
|
69
|
+
// Returns the list of contract adapters (name and index)
|
|
70
|
+
// for a buy/sell. Return null if there are no adapters.
|
|
71
|
+
getAdapters(side) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
// Returns list of pool identifiers that can be used
|
|
75
|
+
// for a given swap. poolIdentifiers must be unique
|
|
76
|
+
// across DEXes. It is recommended to use
|
|
77
|
+
// ${dexKey}_${poolAddress} as a poolIdentifier
|
|
78
|
+
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
79
|
+
// TODO: complete me!
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
// Returns pool prices for amounts.
|
|
83
|
+
// If limitPools is defined only pools in limitPools
|
|
84
|
+
// should be used. If limitPools is undefined then
|
|
85
|
+
// any pools can be used.
|
|
86
|
+
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
|
|
87
|
+
// TODO: complete me!
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
91
|
+
getCalldataGasCost(poolPrices) {
|
|
92
|
+
// TODO: update if there is any payload in getAdapterParam
|
|
93
|
+
return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
94
|
+
}
|
|
95
|
+
// Encode params required by the exchange adapter
|
|
96
|
+
// V5: Used for multiSwap, buy & megaSwap
|
|
97
|
+
// V6: Not used, can be left blank
|
|
98
|
+
// Hint: abiCoder.encodeParameter() could be useful
|
|
99
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
100
|
+
// TODO: complete me!
|
|
101
|
+
const { exchange } = data;
|
|
102
|
+
// Encode here the payload for adapter
|
|
103
|
+
const payload = '';
|
|
104
|
+
return {
|
|
105
|
+
targetExchange: exchange,
|
|
106
|
+
payload,
|
|
107
|
+
networkFee: '0',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
// This is called once before getTopPoolsForToken is
|
|
111
|
+
// called for multiple tokens. This can be helpful to
|
|
112
|
+
// update common state required for calculating
|
|
113
|
+
// getTopPoolsForToken. It is optional for a DEX
|
|
114
|
+
// to implement this
|
|
115
|
+
async updatePoolState() {
|
|
116
|
+
// TODO: complete me!
|
|
117
|
+
}
|
|
118
|
+
// Returns list of top pools based on liquidity. Max
|
|
119
|
+
// limit number pools should be returned.
|
|
120
|
+
async getTopPoolsForToken(tokenAddress, limit) {
|
|
121
|
+
//TODO: complete me!
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
// This is optional function in case if your implementation has acquired any resources
|
|
125
|
+
// you need to release for graceful shutdown. For example, it may be any interval timer
|
|
126
|
+
releaseResources() {
|
|
127
|
+
// TODO: complete me!
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.SeVlr = SeVlr;
|
|
131
|
+
//# sourceMappingURL=se-vlr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"se-vlr.js","sourceRoot":"","sources":["../../../src/dex/se-vlr/se-vlr.ts"],"names":[],"mappings":";;;;;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AAyB;IACzB,KAAK,CAAC,eAAe,CACnB,QAAe,EACf,SAAgB,EAChB,OAAiB,EACjB,IAAc,EACd,WAAmB,EACnB,UAAqB;QAErB,qBAAqB;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mEAAmE;IACnE,kBAAkB,CAAC,UAAiC;QAClD,0DAA0D;QAC1D,OAAO,iBAAiB,CAAC,cAAc,CAAC;IAC1C,CAAC;IAED,iDAAiD;IACjD,yCAAyC;IACzC,kCAAkC;IAClC,mDAAmD;IACnD,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAe,EACf,IAAc;QAEd,qBAAqB;QACrB,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAE1B,sCAAsC;QACtC,MAAM,OAAO,GAAG,EAAE,CAAC;QAEnB,OAAO;YACL,cAAc,EAAE,QAAQ;YACxB,OAAO;YACP,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,oDAAoD;IACpD,qDAAqD;IACrD,+CAA+C;IAC/C,gDAAgD;IAChD,oBAAoB;IACpB,KAAK,CAAC,eAAe;QACnB,qBAAqB;IACvB,CAAC;IAED,oDAAoD;IACpD,yCAAyC;IACzC,KAAK,CAAC,mBAAmB,CACvB,YAAqB,EACrB,KAAa;QAEb,oBAAoB;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,sFAAsF;IACtF,uFAAuF;IACvF,gBAAgB;QACd,qBAAqB;IACvB,CAAC;;AAhIH,sBAiIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/se-vlr/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { IDexHelper } from '../dex-helper';
|
|
7
|
+
export declare type ShellData = {
|
|
8
|
+
exchange: Address;
|
|
9
|
+
deadline?: number;
|
|
10
|
+
};
|
|
11
|
+
declare type ShellParam = [
|
|
12
|
+
_origin: string,
|
|
13
|
+
_target: string,
|
|
14
|
+
_originAmount: string,
|
|
15
|
+
_minTargetAmount: string,
|
|
16
|
+
_deadline: string
|
|
17
|
+
];
|
|
18
|
+
export declare class Shell extends SimpleExchange implements IDexTxBuilder<ShellData, ShellParam> {
|
|
19
|
+
static dexKeys: string[];
|
|
20
|
+
exchangeRouterInterface: Interface;
|
|
21
|
+
constructor(dexHelper: IDexHelper);
|
|
22
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: ShellData, side: SwapSide): AdapterExchangeParam;
|
|
23
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: ShellData, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
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.Shell = void 0;
|
|
7
|
+
const abi_1 = require("@ethersproject/abi");
|
|
8
|
+
const simple_exchange_1 = require("./simple-exchange");
|
|
9
|
+
const Shell_json_1 = __importDefault(require("../abi/Shell.json"));
|
|
10
|
+
var ShellFunctions;
|
|
11
|
+
(function (ShellFunctions) {
|
|
12
|
+
ShellFunctions["originSwap"] = "originSwap";
|
|
13
|
+
})(ShellFunctions || (ShellFunctions = {}));
|
|
14
|
+
class Shell extends simple_exchange_1.SimpleExchange {
|
|
15
|
+
constructor(dexHelper) {
|
|
16
|
+
super(dexHelper, 'shell');
|
|
17
|
+
this.exchangeRouterInterface = new abi_1.Interface(Shell_json_1.default);
|
|
18
|
+
}
|
|
19
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
20
|
+
return {
|
|
21
|
+
targetExchange: data.exchange,
|
|
22
|
+
payload: '0x',
|
|
23
|
+
networkFee: '0',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
27
|
+
const swapFunction = ShellFunctions.originSwap;
|
|
28
|
+
const swapFunctionParams = [
|
|
29
|
+
srcToken,
|
|
30
|
+
destToken,
|
|
31
|
+
srcAmount,
|
|
32
|
+
destAmount,
|
|
33
|
+
(0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(),
|
|
34
|
+
];
|
|
35
|
+
const swapData = this.exchangeRouterInterface.encodeFunctionData(swapFunction, swapFunctionParams);
|
|
36
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, data.exchange);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.Shell = Shell;
|
|
40
|
+
Shell.dexKeys = ['shell'];
|
|
41
|
+
//# sourceMappingURL=shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/dex/shell.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA6D;AAI7D,uDAG2B;AAC3B,mEAAyC;AAczC,IAAK,cAEJ;AAFD,WAAK,cAAc;IACjB,2CAAyB,CAAA;AAC3B,CAAC,EAFI,cAAc,KAAd,cAAc,QAElB;AAED,MAAa,KACX,SAAQ,gCAAc;IAMtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC1B,IAAI,CAAC,uBAAuB,GAAG,IAAI,eAAS,CAAC,oBAA0B,CAAC,CAAC;IAC3E,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAe,EACf,IAAc;QAEd,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,QAAQ;YAC7B,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAe,EACf,IAAc;QAEd,MAAM,YAAY,GAAG,cAAc,CAAC,UAAU,CAAC;QAC/C,MAAM,kBAAkB,GAAe;YACrC,QAAQ;YACR,SAAS;YACT,SAAS;YACT,UAAU;YACV,IAAA,uDAAqC,GAAE;SACxC,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAC9D,YAAY,EACZ,kBAAkB,CACnB,CAAC;QAEF,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,IAAI,CAAC,QAAQ,CACd,CAAC;IACJ,CAAC;;AAxDH,sBAyDC;AArDQ,aAAO,GAAG,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -42,7 +42,7 @@ class SimpleExchangeWithRestrictions extends simple_exchange_1.SimpleExchange {
|
|
|
42
42
|
}
|
|
43
43
|
async isBlacklisted(address) {
|
|
44
44
|
const cached = await this.dexHelper.cache.rawget(this.getBlacklistedCacheKey(address));
|
|
45
|
-
return cached
|
|
45
|
+
return cached !== null;
|
|
46
46
|
}
|
|
47
47
|
setBlacklist(addresses) {
|
|
48
48
|
this.logger.info(`Blacklisting addresses: ${addresses.length}`);
|
|
@@ -67,7 +67,7 @@ class SimpleExchangeWithRestrictions extends simple_exchange_1.SimpleExchange {
|
|
|
67
67
|
}
|
|
68
68
|
async isRestricted() {
|
|
69
69
|
const cached = await this.dexHelper.cache.rawget(this.getRestrictedCacheKey());
|
|
70
|
-
return cached
|
|
70
|
+
return cached !== null;
|
|
71
71
|
}
|
|
72
72
|
async restrict() {
|
|
73
73
|
const errorsDataRaw = await this.dexHelper.cache.get(this.dexKey, this.network, ERRORS_CACHE_KEY);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple-exchange-with-restrictions.js","sourceRoot":"","sources":["../../src/dex/simple-exchange-with-restrictions.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AAEnD,oCAAiC;AAIjC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAClC,MAAM,0BAA0B,GAAG,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ;AAC1D,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU;AAE1C,MAAM,sBAAsB,GAAG,YAAY,CAAC;AAC5C,MAAM,uBAAuB,GAAG,aAAa,CAAC;AAE9C,MAAM,yBAAyB,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC,UAAU;AACtD,MAAM,8BAA8B,GAAG,KAAK,CAAC;AAe7C,MAAa,8BACX,SAAQ,gCAAc;IAaD;IACZ;IAXU,cAAc,CAAS;IACvB,oBAAoB,CAAU;IAEvC,uBAAuB,CAAS;IAChC,sBAAsB,CAAS;IAC/B,YAAY,CAAS;IAErB,MAAM,CAAS;IAEzB,YACqB,SAAqB,EACjC,MAAc,EACrB,UAAiC,EAAE;QAEnC,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAJN,cAAS,GAAT,SAAS,CAAY;QACjC,WAAM,GAAN,MAAM,CAAQ;QAIrB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,GAAG,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAE/D,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,yBAAyB,CAAC;QAC1E,IAAI,CAAC,oBAAoB;YACvB,OAAO,CAAC,oBAAoB,IA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AAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,EACZ,gBAAgB,EAChB,YAAY,EACZ,aAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CACtB,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAvJD,wEAuJC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SwapSide } from '../constants';
|
|
2
|
+
import { AdapterExchangeParam, Address, SimpleExchangeParam } from '../types';
|
|
3
|
+
import { IDexTxBuilder } from './idex';
|
|
4
|
+
import { IDexHelper } from '../dex-helper';
|
|
5
|
+
import { SimpleExchange } from './simple-exchange';
|
|
6
|
+
import { NumberAsString } from '@paraswap/core';
|
|
7
|
+
import { AsyncOrSync } from 'ts-essentials';
|
|
8
|
+
import { Interface } from '@ethersproject/abi';
|
|
9
|
+
declare type TraderJoeV2RouterSellParams = [
|
|
10
|
+
_amountIn: NumberAsString,
|
|
11
|
+
_amountOutMin: NumberAsString,
|
|
12
|
+
_pairBinSteps: NumberAsString[],
|
|
13
|
+
_tokenPath: Address[],
|
|
14
|
+
to: Address,
|
|
15
|
+
_deadline: number
|
|
16
|
+
];
|
|
17
|
+
declare type TraderJoeV2RouterBuyParams = [
|
|
18
|
+
_amountOut: NumberAsString,
|
|
19
|
+
_amountInMax: NumberAsString,
|
|
20
|
+
_pairBinSteps: NumberAsString[],
|
|
21
|
+
_tokenPath: Address[],
|
|
22
|
+
to: Address,
|
|
23
|
+
_deadline: string
|
|
24
|
+
];
|
|
25
|
+
declare type TraderJoeV2RouterParam = TraderJoeV2RouterSellParams | TraderJoeV2RouterBuyParams;
|
|
26
|
+
export declare type TraderJoeV2Data = {
|
|
27
|
+
tokenIn: string;
|
|
28
|
+
tokenOut: string;
|
|
29
|
+
binStep: string;
|
|
30
|
+
};
|
|
31
|
+
export declare class TraderJoeV2 extends SimpleExchange implements IDexTxBuilder<TraderJoeV2Data, TraderJoeV2RouterParam> {
|
|
32
|
+
static dexKeys: string[];
|
|
33
|
+
protected routerAddress: string;
|
|
34
|
+
exchangeRouterInterface: Interface;
|
|
35
|
+
needWrapNative: boolean;
|
|
36
|
+
constructor(dexHelper: IDexHelper);
|
|
37
|
+
getAdapterParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, data: TraderJoeV2Data, side: SwapSide): AdapterExchangeParam;
|
|
38
|
+
getSimpleParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, data: TraderJoeV2Data, side: SwapSide): AsyncOrSync<SimpleExchangeParam>;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
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.TraderJoeV2 = void 0;
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const simple_exchange_1 = require("./simple-exchange");
|
|
9
|
+
const abi_1 = require("@ethersproject/abi");
|
|
10
|
+
const TraderJoeV2Router_json_1 = __importDefault(require("../abi/TraderJoeV2Router.json"));
|
|
11
|
+
const TRADERJOE_V2_ROUTER_ADDRESS = {
|
|
12
|
+
[constants_1.Network.AVALANCHE]: '0xE3Ffc583dC176575eEA7FD9dF2A7c65F7E23f4C3',
|
|
13
|
+
[constants_1.Network.ARBITRUM]: '0x7BFd7192E76D950832c77BB412aaE841049D8D9B',
|
|
14
|
+
[constants_1.Network.BSC]: '0xb66A2704a0dabC1660941628BE987B4418f7a9E8',
|
|
15
|
+
};
|
|
16
|
+
var TraderJoeV2RouterFunctions;
|
|
17
|
+
(function (TraderJoeV2RouterFunctions) {
|
|
18
|
+
TraderJoeV2RouterFunctions["swapExactTokensForTokens"] = "swapExactTokensForTokens";
|
|
19
|
+
TraderJoeV2RouterFunctions["swapTokensForExactTokens"] = "swapTokensForExactTokens";
|
|
20
|
+
})(TraderJoeV2RouterFunctions || (TraderJoeV2RouterFunctions = {}));
|
|
21
|
+
class TraderJoeV2 extends simple_exchange_1.SimpleExchange {
|
|
22
|
+
constructor(dexHelper) {
|
|
23
|
+
super(dexHelper, 'traderjoev2');
|
|
24
|
+
this.needWrapNative = true;
|
|
25
|
+
this.routerAddress =
|
|
26
|
+
TRADERJOE_V2_ROUTER_ADDRESS[dexHelper.config.data.network];
|
|
27
|
+
this.exchangeRouterInterface = new abi_1.Interface(TraderJoeV2Router_json_1.default);
|
|
28
|
+
}
|
|
29
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
30
|
+
const payload = this.abiCoder.encodeParameter({
|
|
31
|
+
ParentStruct: {
|
|
32
|
+
_pairBinSteps: 'uint256[]',
|
|
33
|
+
_tokenPath: 'address[]',
|
|
34
|
+
_deadline: 'uint256',
|
|
35
|
+
},
|
|
36
|
+
}, {
|
|
37
|
+
_pairBinSteps: [data.binStep],
|
|
38
|
+
_tokenPath: [data.tokenIn, data.tokenOut],
|
|
39
|
+
_deadline: (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(), // FIXME: more gas efficient to pass block.timestamp in adapter
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
targetExchange: this.routerAddress,
|
|
43
|
+
payload,
|
|
44
|
+
networkFee: '0',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
48
|
+
const swapFunction = side === constants_1.SwapSide.SELL
|
|
49
|
+
? TraderJoeV2RouterFunctions.swapExactTokensForTokens
|
|
50
|
+
: TraderJoeV2RouterFunctions.swapTokensForExactTokens;
|
|
51
|
+
const swapFunctionParams = side === constants_1.SwapSide.SELL
|
|
52
|
+
? [
|
|
53
|
+
srcAmount,
|
|
54
|
+
destAmount,
|
|
55
|
+
[data.binStep],
|
|
56
|
+
[srcToken, destToken],
|
|
57
|
+
this.augustusAddress,
|
|
58
|
+
(0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(),
|
|
59
|
+
]
|
|
60
|
+
: [
|
|
61
|
+
destAmount,
|
|
62
|
+
srcAmount,
|
|
63
|
+
[data.binStep],
|
|
64
|
+
[srcToken, destToken],
|
|
65
|
+
this.augustusAddress,
|
|
66
|
+
(0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(),
|
|
67
|
+
];
|
|
68
|
+
const swapData = this.exchangeRouterInterface.encodeFunctionData(swapFunction, swapFunctionParams);
|
|
69
|
+
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, this.routerAddress);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.TraderJoeV2 = TraderJoeV2;
|
|
73
|
+
TraderJoeV2.dexKeys = ['traderjoev2'];
|
|
74
|
+
//# sourceMappingURL=trader-joe-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trader-joe-v2.js","sourceRoot":"","sources":["../../src/dex/trader-joe-v2.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAiD;AAIjD,uDAG2B;AAG3B,4CAA6D;AAC7D,2FAAiE;AAEjE,MAAM,2BAA2B,GAAmC;IAClE,CAAC,mBAAO,CAAC,SAAS,CAAC,EAAE,4CAA4C;IACjE,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE,4CAA4C;IAChE,CAAC,mBAAO,CAAC,GAAG,CAAC,EAAE,4CAA4C;CAC5D,CAAC;AA8BF,IAAK,0BAGJ;AAHD,WAAK,0BAA0B;IAC7B,mFAAqD,CAAA;IACrD,mFAAqD,CAAA;AACvD,CAAC,EAHI,0BAA0B,KAA1B,0BAA0B,QAG9B;AAED,MAAa,WACX,SAAQ,gCAAc;IAQtB,YAAY,SAAqB;QAC/B,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QAHlC,mBAAc,GAAG,IAAI,CAAC;QAKpB,IAAI,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V,SAAS;gBACT,CAAC,IAAI,CAAC,OAAO,CAAC;gBACd,CAAC,QAAQ,EAAE,SAAS,CAAC;gBACrB,IAAI,CAAC,eAAe;gBACpB,IAAA,uDAAqC,GAAE;aACxC,CAAC;QACR,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,kBAAkB,CAC9D,YAAY,EACZ,kBAAkB,CACnB,CAAC;QAEF,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,IAAI,CAAC,aAAa,CACnB,CAAC;IACJ,CAAC;;AA9FH,kCA+FC;AA3FQ,mBAAO,GAAG,CAAC,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { AdapterExchangeParam, Address, DexExchangeParam, ExchangePrices, ExchangeTxInfo, Logger, NumberAsString, PoolLiquidity, PoolPrices, PreprocessTransactionOptions, SimpleExchangeParam, Token, TxInfo } from '../../types';
|
|
3
|
+
import { Network, SwapSide } from '../../constants';
|
|
4
|
+
import { IDex } from '../../dex/idex';
|
|
5
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
6
|
+
import { DexParams, OutputResult, PoolState, UniswapV3Data, UniswapV3Param, UniswapV3ParamsDirect } from './types';
|
|
7
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
8
|
+
import { UniswapV3EventPool } from './uniswap-v3-pool';
|
|
9
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
10
|
+
import { Contract } from 'web3-eth-contract';
|
|
11
|
+
import { OptimalSwapExchange } from '@paraswap/core';
|
|
12
|
+
import { OnPoolCreatedCallback, UniswapV3Factory } from './uniswap-v3-factory';
|
|
13
|
+
export declare const PoolsRegistryHashKey = "dl_poolsRegistry";
|
|
14
|
+
export declare const UNISWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS: number;
|
|
15
|
+
export declare const UNISWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS: number;
|
|
16
|
+
export declare const UNISWAPV3_QUOTE_GASLIMIT = 200000;
|
|
17
|
+
export declare class UniswapV3 extends SimpleExchange implements IDex<UniswapV3Data, UniswapV3Param | UniswapV3ParamsDirect> {
|
|
18
|
+
protected network: Network;
|
|
19
|
+
protected dexHelper: IDexHelper;
|
|
20
|
+
protected adapters: import("../../types").AdapterMappings;
|
|
21
|
+
readonly routerIface: Interface;
|
|
22
|
+
readonly quoterIface: Interface;
|
|
23
|
+
protected config: DexParams;
|
|
24
|
+
protected poolsToPreload: {
|
|
25
|
+
token0: Address;
|
|
26
|
+
token1: Address;
|
|
27
|
+
}[];
|
|
28
|
+
protected readonly factory: UniswapV3Factory;
|
|
29
|
+
readonly isFeeOnTransferSupported: boolean;
|
|
30
|
+
readonly eventPools: Record<string, UniswapV3EventPool | null>;
|
|
31
|
+
readonly hasConstantPriceLargeAmounts = false;
|
|
32
|
+
readonly needWrapNative = true;
|
|
33
|
+
readonly directSwapIface: Interface;
|
|
34
|
+
intervalTask?: NodeJS.Timeout;
|
|
35
|
+
static dexKeysWithNetwork: {
|
|
36
|
+
key: string;
|
|
37
|
+
networks: Network[];
|
|
38
|
+
}[];
|
|
39
|
+
logger: Logger;
|
|
40
|
+
private uniswapMulti;
|
|
41
|
+
protected stateMultiContract: Contract;
|
|
42
|
+
protected notExistingPoolSetKey: string;
|
|
43
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: import("../../types").AdapterMappings, routerIface?: Interface, quoterIface?: Interface, config?: DexParams, poolsToPreload?: {
|
|
44
|
+
token0: Address;
|
|
45
|
+
token1: Address;
|
|
46
|
+
}[]);
|
|
47
|
+
get supportedFees(): bigint[];
|
|
48
|
+
getAdapters(side: SwapSide): {
|
|
49
|
+
name: string;
|
|
50
|
+
index: number;
|
|
51
|
+
}[] | null;
|
|
52
|
+
getPoolIdentifier(srcAddress: Address, destAddress: Address, fee: bigint, tickSpacing?: bigint): string;
|
|
53
|
+
initializePricing(blockNumber: number): Promise<void>;
|
|
54
|
+
protected onPoolCreatedDeleteFromNonExistingSet(): OnPoolCreatedCallback;
|
|
55
|
+
getPool(srcAddress: Address, destAddress: Address, fee: bigint, blockNumber: number, tickSpacing?: bigint): Promise<UniswapV3EventPool | null>;
|
|
56
|
+
protected getPoolInstance(token0: string, token1: string, fee: bigint, tickSpacing?: bigint): UniswapV3EventPool;
|
|
57
|
+
protected getFactoryInstance(): UniswapV3Factory;
|
|
58
|
+
addMasterPool(poolKey: string, blockNumber: number): Promise<boolean>;
|
|
59
|
+
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
60
|
+
protected getPoolsForIdentifiers(srcAddress: string, destAddress: string, blockNumber: number): Promise<(UniswapV3EventPool | null)[]>;
|
|
61
|
+
getPricingFromRpc(from: Token, to: Token, amounts: bigint[], side: SwapSide, pools: UniswapV3EventPool[], states: PoolState[]): Promise<ExchangePrices<UniswapV3Data> | null>;
|
|
62
|
+
protected getSelectedPools(srcAddress: string, destAddress: string, blockNumber: number): Promise<(UniswapV3EventPool | null)[]>;
|
|
63
|
+
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<UniswapV3Data>>;
|
|
64
|
+
protected prepareData(srcAddress: string, destAddress: string, pool: UniswapV3EventPool, state: PoolState): UniswapV3Data;
|
|
65
|
+
getCalldataGasCost(poolPrices: PoolPrices<UniswapV3Data>): number | number[];
|
|
66
|
+
getTokenFromAddress(address: Address): Token;
|
|
67
|
+
preProcessTransaction(optimalSwapExchange: OptimalSwapExchange<UniswapV3Data>, srcToken: Token, _0: Token, _1: SwapSide, options: PreprocessTransactionOptions): Promise<[OptimalSwapExchange<UniswapV3Data>, ExchangeTxInfo]>;
|
|
68
|
+
getDirectParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, expectedAmount: NumberAsString, data: UniswapV3Data, side: SwapSide, permit: string, uuid: string, feePercent: NumberAsString, deadline: NumberAsString, partner: string, beneficiary: string, contractMethod: string): TxInfo<UniswapV3Param>;
|
|
69
|
+
static getDirectFunctionName(): string[];
|
|
70
|
+
getDirectParamV6(srcToken: Address, destToken: Address, fromAmount: NumberAsString, toAmount: NumberAsString, quotedAmount: NumberAsString, data: UniswapV3Data, side: SwapSide, permit: string, uuid: string, partnerAndFee: string, beneficiary: string, blockNumber: number, contractMethod: string): {
|
|
71
|
+
params: UniswapV3ParamsDirect;
|
|
72
|
+
encoder: (...params: (string | UniswapV3ParamsDirect)[]) => string;
|
|
73
|
+
networkFee: string;
|
|
74
|
+
};
|
|
75
|
+
static getDirectFunctionNameV6(): string[];
|
|
76
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: UniswapV3Data, side: SwapSide): AdapterExchangeParam;
|
|
77
|
+
getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: UniswapV3Data, side: SwapSide): DexExchangeParam;
|
|
78
|
+
getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: UniswapV3Data, side: SwapSide): Promise<SimpleExchangeParam>;
|
|
79
|
+
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
80
|
+
private _getPoolsFromIdentifiers;
|
|
81
|
+
protected _getLoweredAddresses(srcToken: Token, destToken: Token): string[];
|
|
82
|
+
protected _sortTokens(srcAddress: Address, destAddress: Address): string[];
|
|
83
|
+
private _toLowerForAllConfigAddresses;
|
|
84
|
+
protected _getOutputs(state: DeepReadonly<PoolState>, amounts: bigint[], zeroForOne: boolean, side: SwapSide, destTokenBalance: bigint): OutputResult | null;
|
|
85
|
+
private _querySubgraph;
|
|
86
|
+
protected _encodePath(path: {
|
|
87
|
+
tokenIn: Address;
|
|
88
|
+
tokenOut: Address;
|
|
89
|
+
fee: NumberAsString;
|
|
90
|
+
}[], side: SwapSide): string;
|
|
91
|
+
private _encodePathV6;
|
|
92
|
+
private _encodePool;
|
|
93
|
+
releaseResources(): void;
|
|
94
|
+
}
|