@curvefi/api 2.57.4 → 2.58.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/lib/constants/aliases.d.ts +1 -0
- package/lib/constants/aliases.js +20 -0
- package/lib/constants/coins/xlayer.d.ts +6 -0
- package/lib/constants/coins/xlayer.js +9 -0
- package/lib/constants/pools/index.d.ts +3 -2
- package/lib/constants/pools/index.js +3 -2
- package/lib/constants/pools/xlayer.d.ts +2 -0
- package/lib/constants/pools/xlayer.js +2 -0
- package/lib/constants/tricryptoDeployImplementations.d.ts +5 -0
- package/lib/constants/tricryptoDeployImplementations.js +5 -0
- package/lib/constants/volumeNetworks.js +1 -1
- package/lib/curve.js +21 -4
- package/lib/factory/constants.d.ts +5 -0
- package/lib/factory/constants.js +10 -0
- package/lib/interfaces.d.ts +2 -2
- package/lib/router.js +29 -31
- package/lib/utils.js +2 -0
- package/package.json +2 -2
|
@@ -13,3 +13,4 @@ export declare const ALIASES_ZKSYNC: import("../interfaces.js").IDict<string>;
|
|
|
13
13
|
export declare const ALIASES_BASE: import("../interfaces.js").IDict<string>;
|
|
14
14
|
export declare const ALIASES_BSC: import("../interfaces.js").IDict<string>;
|
|
15
15
|
export declare const ALIASES_FRAXTAL: import("../interfaces.js").IDict<string>;
|
|
16
|
+
export declare const ALIASES_XLAYER: import("../interfaces.js").IDict<string>;
|
package/lib/constants/aliases.js
CHANGED
|
@@ -308,6 +308,26 @@ export var ALIASES_FRAXTAL = lowerCaseValues({
|
|
|
308
308
|
"stable_ng_factory": '0xd2002373543Ce3527023C75e7518C274A51ce712',
|
|
309
309
|
"factory_admin": '0x0000000000000000000000000000000000000000',
|
|
310
310
|
});
|
|
311
|
+
export var ALIASES_XLAYER = lowerCaseValues({
|
|
312
|
+
"crv": "0x0000000000000000000000000000000000000000",
|
|
313
|
+
"gauge_factory": "0xeF672bD94913CB6f1d2812a6e18c1fFdEd8eFf5c",
|
|
314
|
+
"voting_escrow": "0x0000000000000000000000000000000000000000",
|
|
315
|
+
"fee_distributor": "0x0000000000000000000000000000000000000000",
|
|
316
|
+
"gauge_controller": "0x0000000000000000000000000000000000000000",
|
|
317
|
+
"address_provider": "0x0000000000000000000000000000000000000000",
|
|
318
|
+
"router": "0x4f37A9d177470499A2dD084621020b023fcffc1F",
|
|
319
|
+
"deposit_and_stake": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
|
|
320
|
+
"stable_calc": "0x0fE38dCC905eC14F6099a83Ac5C93BF2601300CF",
|
|
321
|
+
"crypto_calc": '0x69522fb5337663d3B4dFB0030b881c1A750Adb4f',
|
|
322
|
+
"factory": '0x0000000000000000000000000000000000000000',
|
|
323
|
+
"crvusd_factory": '0x0000000000000000000000000000000000000000',
|
|
324
|
+
"eywa_factory": '0x0000000000000000000000000000000000000000',
|
|
325
|
+
"crypto_factory": '0x0000000000000000000000000000000000000000',
|
|
326
|
+
"twocrypto_factory": '0x0c59d36b23f809f8b6C7cb4c8C590a0AC103baEf',
|
|
327
|
+
"tricrypto_factory": '0xd3B17f862956464ae4403cCF829CE69199856e1e',
|
|
328
|
+
"stable_ng_factory": '0x5eeE3091f747E60a045a2E715a4c71e600e31F6E',
|
|
329
|
+
"factory_admin": '0x0000000000000000000000000000000000000000',
|
|
330
|
+
});
|
|
311
331
|
var registry_exchange_deprecated = {
|
|
312
332
|
'1': '0x99a58482bd75cbab83b27ec03ca68ff489b5788f',
|
|
313
333
|
'10': '0x22d710931f01c1681ca1570ff016ed42eb7b7c2a',
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IDict } from "../../interfaces.js";
|
|
2
|
+
export declare const COINS_XLAYER: IDict<string>;
|
|
3
|
+
export declare const cTokensXLayer: never[];
|
|
4
|
+
export declare const yTokensXLayer: never[];
|
|
5
|
+
export declare const ycTokensXLayer: never[];
|
|
6
|
+
export declare const aTokensXLayer: never[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { lowerCaseValues } from "../utils.js";
|
|
2
|
+
export var COINS_XLAYER = lowerCaseValues({
|
|
3
|
+
crv: '0x3d5320821bfca19fb0b5428f2c79d63bd5246f89',
|
|
4
|
+
okb: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
5
|
+
});
|
|
6
|
+
export var cTokensXLayer = []; //.map((a) => a.toLowerCase());
|
|
7
|
+
export var yTokensXLayer = []; //.map((a) => a.toLowerCase());
|
|
8
|
+
export var ycTokensXLayer = []; //.map((a) => a.toLowerCase());
|
|
9
|
+
export var aTokensXLayer = []; //.map((a) => a.toLowerCase());
|
|
@@ -13,5 +13,6 @@ import { POOLS_DATA_CELO } from "./celo.js";
|
|
|
13
13
|
import { POOLS_DATA_ZKSYNC } from "./zksync.js";
|
|
14
14
|
import { POOLS_DATA_BASE } from "./base.js";
|
|
15
15
|
import { POOLS_DATA_BSC } from "./bsc.js";
|
|
16
|
-
import { POOLS_DATA_FRAXTAL } from "./fraxtal";
|
|
17
|
-
|
|
16
|
+
import { POOLS_DATA_FRAXTAL } from "./fraxtal.js";
|
|
17
|
+
import { POOLS_DATA_XLAYER } from "./xlayer.js";
|
|
18
|
+
export { POOLS_DATA_ETHEREUM, LLAMMAS_DATA_ETHEREUM, POOLS_DATA_POLYGON, POOLS_DATA_FANTOM, POOLS_DATA_AVALANCHE, POOLS_DATA_ARBITRUM, POOLS_DATA_OPTIMISM, POOLS_DATA_XDAI, POOLS_DATA_MOONBEAM, POOLS_DATA_AURORA, POOLS_DATA_KAVA, POOLS_DATA_CELO, POOLS_DATA_ZKSYNC, POOLS_DATA_BASE, POOLS_DATA_BSC, POOLS_DATA_FRAXTAL, POOLS_DATA_XLAYER, };
|
|
@@ -13,5 +13,6 @@ import { POOLS_DATA_CELO } from "./celo.js";
|
|
|
13
13
|
import { POOLS_DATA_ZKSYNC } from "./zksync.js";
|
|
14
14
|
import { POOLS_DATA_BASE } from "./base.js";
|
|
15
15
|
import { POOLS_DATA_BSC } from "./bsc.js";
|
|
16
|
-
import { POOLS_DATA_FRAXTAL } from "./fraxtal";
|
|
17
|
-
|
|
16
|
+
import { POOLS_DATA_FRAXTAL } from "./fraxtal.js";
|
|
17
|
+
import { POOLS_DATA_XLAYER } from "./xlayer.js";
|
|
18
|
+
export { POOLS_DATA_ETHEREUM, LLAMMAS_DATA_ETHEREUM, POOLS_DATA_POLYGON, POOLS_DATA_FANTOM, POOLS_DATA_AVALANCHE, POOLS_DATA_ARBITRUM, POOLS_DATA_OPTIMISM, POOLS_DATA_XDAI, POOLS_DATA_MOONBEAM, POOLS_DATA_AURORA, POOLS_DATA_KAVA, POOLS_DATA_CELO, POOLS_DATA_ZKSYNC, POOLS_DATA_BASE, POOLS_DATA_BSC, POOLS_DATA_FRAXTAL, POOLS_DATA_XLAYER, };
|
|
@@ -24,6 +24,11 @@ export declare const tricryptoDeployImplementations: {
|
|
|
24
24
|
amm_native_transfers_enabled: string;
|
|
25
25
|
implementationIdx: number;
|
|
26
26
|
};
|
|
27
|
+
196: {
|
|
28
|
+
amm_native_transfers_disabled: string;
|
|
29
|
+
amm_native_transfers_enabled: string;
|
|
30
|
+
implementationIdx: number;
|
|
31
|
+
};
|
|
27
32
|
250: {
|
|
28
33
|
amm_native_transfers_disabled: string;
|
|
29
34
|
amm_native_transfers_enabled: string;
|
|
@@ -24,6 +24,11 @@ export var tricryptoDeployImplementations = {
|
|
|
24
24
|
amm_native_transfers_enabled: '0x0c59d36b23f809f8b6C7cb4c8C590a0AC103baEf'.toLowerCase(),
|
|
25
25
|
implementationIdx: 1,
|
|
26
26
|
},
|
|
27
|
+
196: {
|
|
28
|
+
amm_native_transfers_disabled: '0x64379C265Fc6595065D7d835AAaa731c0584dB80'.toLowerCase(),
|
|
29
|
+
amm_native_transfers_enabled: '0x0C9D8c7e486e822C29488Ff51BFf0167B4650953'.toLowerCase(),
|
|
30
|
+
implementationIdx: 1,
|
|
31
|
+
},
|
|
27
32
|
250: {
|
|
28
33
|
amm_native_transfers_disabled: '0xd125E7a0cEddF89c6473412d85835450897be6Dc'.toLowerCase(),
|
|
29
34
|
amm_native_transfers_enabled: '0x76303e4fDcA0AbF28aB3ee42Ce086E6503431F1D'.toLowerCase(),
|
package/lib/curve.js
CHANGED
|
@@ -90,8 +90,8 @@ import gasOracleABI from './constants/abis/gas_oracle_optimism.json' assert { ty
|
|
|
90
90
|
import gasOracleBlobABI from './constants/abis/gas_oracle_optimism_blob.json' assert { type: 'json' };
|
|
91
91
|
import votingProposalABI from './constants/abis/voting_proposal.json' assert { type: 'json' };
|
|
92
92
|
import circulatingSupplyABI from './constants/abis/circulating_supply.json' assert { type: 'json' };
|
|
93
|
-
import { POOLS_DATA_ETHEREUM, LLAMMAS_DATA_ETHEREUM, POOLS_DATA_POLYGON, POOLS_DATA_FANTOM, POOLS_DATA_AVALANCHE, POOLS_DATA_ARBITRUM, POOLS_DATA_OPTIMISM, POOLS_DATA_XDAI, POOLS_DATA_MOONBEAM, POOLS_DATA_AURORA, POOLS_DATA_KAVA, POOLS_DATA_CELO, POOLS_DATA_ZKSYNC, POOLS_DATA_BASE, POOLS_DATA_BSC, POOLS_DATA_FRAXTAL, } from './constants/pools/index.js';
|
|
94
|
-
import { ALIASES_ETHEREUM, ALIASES_OPTIMISM, ALIASES_POLYGON, ALIASES_FANTOM, ALIASES_AVALANCHE, ALIASES_ARBITRUM, ALIASES_XDAI, ALIASES_MOONBEAM, ALIASES_AURORA, ALIASES_KAVA, ALIASES_CELO, ALIASES_ZKSYNC, ALIASES_BASE, ALIASES_BSC, ALIASES_FRAXTAL, } from "./constants/aliases.js";
|
|
93
|
+
import { POOLS_DATA_ETHEREUM, LLAMMAS_DATA_ETHEREUM, POOLS_DATA_POLYGON, POOLS_DATA_FANTOM, POOLS_DATA_AVALANCHE, POOLS_DATA_ARBITRUM, POOLS_DATA_OPTIMISM, POOLS_DATA_XDAI, POOLS_DATA_MOONBEAM, POOLS_DATA_AURORA, POOLS_DATA_KAVA, POOLS_DATA_CELO, POOLS_DATA_ZKSYNC, POOLS_DATA_BASE, POOLS_DATA_BSC, POOLS_DATA_FRAXTAL, POOLS_DATA_XLAYER, } from './constants/pools/index.js';
|
|
94
|
+
import { ALIASES_ETHEREUM, ALIASES_OPTIMISM, ALIASES_POLYGON, ALIASES_FANTOM, ALIASES_AVALANCHE, ALIASES_ARBITRUM, ALIASES_XDAI, ALIASES_MOONBEAM, ALIASES_AURORA, ALIASES_KAVA, ALIASES_CELO, ALIASES_ZKSYNC, ALIASES_BASE, ALIASES_BSC, ALIASES_FRAXTAL, ALIASES_XLAYER, } from "./constants/aliases.js";
|
|
95
95
|
import { COINS_ETHEREUM, cTokensEthereum, yTokensEthereum, ycTokensEthereum, aTokensEthereum } from "./constants/coins/ethereum.js";
|
|
96
96
|
import { COINS_OPTIMISM, cTokensOptimism, yTokensOptimism, ycTokensOptimism, aTokensOptimism } from "./constants/coins/optimism.js";
|
|
97
97
|
import { COINS_POLYGON, cTokensPolygon, yTokensPolygon, ycTokensPolygon, aTokensPolygon } from "./constants/coins/polygon.js";
|
|
@@ -107,10 +107,11 @@ import { COINS_ZKSYNC, cTokensZkSync, yTokensZkSync, ycTokensZkSync, aTokensZkSy
|
|
|
107
107
|
import { COINS_BASE, cTokensBase, yTokensBase, ycTokensBase, aTokensBase } from "./constants/coins/base.js";
|
|
108
108
|
import { COINS_BSC, cTokensBsc, yTokensBsc, ycTokensBsc, aTokensBsc } from "./constants/coins/bsc.js";
|
|
109
109
|
import { COINS_FRAXTAL, cTokensFraxtal, yTokensFraxtal, ycTokensFraxtal, aTokensFraxtal } from "./constants/coins/fraxtal.js";
|
|
110
|
+
import { COINS_XLAYER, cTokensXLayer, yTokensXLayer, ycTokensXLayer, aTokensXLayer } from "./constants/coins/xlayer.js";
|
|
110
111
|
import { lowerCasePoolDataAddresses, extractDecimals, extractGauges } from "./constants/utils.js";
|
|
111
112
|
import { _getAllGauges, _getHiddenPools } from "./external-api.js";
|
|
112
113
|
import { L2Networks } from "./constants/L2Networks.js";
|
|
113
|
-
import { getTwocryptoFactoryPoolData } from "./factory/factory-twocrypto";
|
|
114
|
+
import { getTwocryptoFactoryPoolData } from "./factory/factory-twocrypto.js";
|
|
114
115
|
import { initContract, initMulticallContract } from "./utils.js";
|
|
115
116
|
var _killGauges = function (poolsData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
116
117
|
var gaugeData, isKilled, gaugeStatuses, poolId;
|
|
@@ -169,6 +170,12 @@ export var NATIVE_TOKENS = {
|
|
|
169
170
|
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
170
171
|
wrappedAddress: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270'.toLowerCase(),
|
|
171
172
|
},
|
|
173
|
+
196: {
|
|
174
|
+
symbol: 'OKB',
|
|
175
|
+
wrappedSymbol: 'WOKB',
|
|
176
|
+
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
177
|
+
wrappedAddress: '0xe538905cf8410324e03a5a23c1c177a474d59b2b'.toLowerCase(),
|
|
178
|
+
},
|
|
172
179
|
250: {
|
|
173
180
|
symbol: 'FTM',
|
|
174
181
|
wrappedSymbol: 'WFTM',
|
|
@@ -282,6 +289,16 @@ export var NETWORK_CONSTANTS = {
|
|
|
282
289
|
ycTokens: ycTokensPolygon,
|
|
283
290
|
aTokens: aTokensPolygon,
|
|
284
291
|
},
|
|
292
|
+
196: {
|
|
293
|
+
NAME: 'x-layer',
|
|
294
|
+
ALIASES: ALIASES_XLAYER,
|
|
295
|
+
POOLS_DATA: POOLS_DATA_XLAYER,
|
|
296
|
+
COINS: COINS_XLAYER,
|
|
297
|
+
cTokens: cTokensXLayer,
|
|
298
|
+
yTokens: yTokensXLayer,
|
|
299
|
+
ycTokens: ycTokensXLayer,
|
|
300
|
+
aTokens: aTokensXLayer,
|
|
301
|
+
},
|
|
285
302
|
250: {
|
|
286
303
|
NAME: 'fantom',
|
|
287
304
|
ALIASES: ALIASES_FANTOM,
|
|
@@ -1093,7 +1110,7 @@ var Curve = /** @class */ (function () {
|
|
|
1093
1110
|
this.setContract(this.constants.ALIASES.crypto_calc, cryptoCalcZapABI);
|
|
1094
1111
|
this.setContract(this.constants.ALIASES.stable_calc, StableCalcZapABI);
|
|
1095
1112
|
this.setContract(this.constants.ALIASES.factory, factoryABI);
|
|
1096
|
-
if (!(this.chainId !== 1313161554 && this.chainId !== 252)) return [3 /*break*/, 19];
|
|
1113
|
+
if (!(this.chainId !== 1313161554 && this.chainId !== 252 && this.chainId !== 196)) return [3 /*break*/, 19];
|
|
1097
1114
|
factoryContract = this.contracts[this.constants.ALIASES.factory].contract;
|
|
1098
1115
|
_o = this.constants.ALIASES;
|
|
1099
1116
|
return [4 /*yield*/, factoryContract.admin(this.constantOptions)];
|
|
@@ -13,6 +13,7 @@ export declare const implementationABIDictZkSync: IDict<any>;
|
|
|
13
13
|
export declare const implementationABIDictBase: IDict<any>;
|
|
14
14
|
export declare const implementationABIDictBsc: IDict<any>;
|
|
15
15
|
export declare const implementationABIDictFraxtal: IDict<any>;
|
|
16
|
+
export declare const implementationABIDictXLayer: IDict<any>;
|
|
16
17
|
export declare const basePoolIdZapDictEthereum: IDict<{
|
|
17
18
|
address: string;
|
|
18
19
|
ABI: any;
|
|
@@ -69,6 +70,10 @@ export declare const basePoolIdZapDictFraxtal: IDict<{
|
|
|
69
70
|
address: string;
|
|
70
71
|
ABI: any;
|
|
71
72
|
}>;
|
|
73
|
+
export declare const basePoolIdZapDictXLayer: IDict<{
|
|
74
|
+
address: string;
|
|
75
|
+
ABI: any;
|
|
76
|
+
}>;
|
|
72
77
|
export declare const stableNgBasePoolZap: {
|
|
73
78
|
ABI: any;
|
|
74
79
|
address: string;
|
package/lib/factory/constants.js
CHANGED
|
@@ -348,6 +348,10 @@ export var implementationABIDictFraxtal = lowerCaseKeys({
|
|
|
348
348
|
"0x1764ee18e8B3ccA4787249Ceb249356192594585": PlainStableSwapNGABI,
|
|
349
349
|
"0x5eeE3091f747E60a045a2E715a4c71e600e31F6E": MetaStableSwapNGABI,
|
|
350
350
|
});
|
|
351
|
+
export var implementationABIDictXLayer = lowerCaseKeys({
|
|
352
|
+
"0x87FE17697D0f14A222e8bEf386a0860eCffDD617": PlainStableSwapNGABI,
|
|
353
|
+
"0x1764ee18e8B3ccA4787249Ceb249356192594585": MetaStableSwapNGABI,
|
|
354
|
+
});
|
|
351
355
|
export var basePoolIdZapDictEthereum = {
|
|
352
356
|
'3pool': {
|
|
353
357
|
address: "0xA79828DF1850E8a3A3064576f380D90aECDD3359".toLowerCase(),
|
|
@@ -445,6 +449,7 @@ export var basePoolIdZapDictZkSync = {};
|
|
|
445
449
|
export var basePoolIdZapDictBase = {};
|
|
446
450
|
export var basePoolIdZapDictBsc = {};
|
|
447
451
|
export var basePoolIdZapDictFraxtal = {};
|
|
452
|
+
export var basePoolIdZapDictXLayer = {};
|
|
448
453
|
export var stableNgBasePoolZap = {
|
|
449
454
|
ABI: StableNgBasePoolZapABI,
|
|
450
455
|
address: '0xe07a16358aa878cbda2d49a88e5106871e0db307'.toLowerCase(),
|
|
@@ -475,6 +480,11 @@ export var FACTORY_CONSTANTS = {
|
|
|
475
480
|
basePoolIdZapDict: basePoolIdZapDictPolygon,
|
|
476
481
|
stableNgBasePoolZap: stableNgBasePoolZap,
|
|
477
482
|
},
|
|
483
|
+
196: {
|
|
484
|
+
implementationABIDict: implementationABIDictXLayer,
|
|
485
|
+
basePoolIdZapDict: basePoolIdZapDictXLayer,
|
|
486
|
+
stableNgBasePoolZap: stableNgBasePoolZap,
|
|
487
|
+
},
|
|
478
488
|
250: {
|
|
479
489
|
implementationABIDict: implementationABIDictFantom,
|
|
480
490
|
basePoolIdZapDict: basePoolIdZapDictFantom,
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { Contract as MulticallContract, Provider as MulticallProvider } from "et
|
|
|
3
3
|
export interface IDict<T> {
|
|
4
4
|
[index: string]: T;
|
|
5
5
|
}
|
|
6
|
-
export type INetworkName = "ethereum" | "bsc" | "optimism" | "xdai" | "polygon" | "fantom" | "fraxtal" | "zksync" | "moonbeam" | "kava" | "base" | "arbitrum" | "celo" | "avalanche" | "aurora";
|
|
7
|
-
export type IChainId = 1 | 10 | 56 | 100 | 137 | 250 | 252 | 324 | 1284 | 2222 | 8453 | 42161 | 42220 | 43114 | 1313161554;
|
|
6
|
+
export type INetworkName = "ethereum" | "bsc" | "optimism" | "xdai" | "polygon" | "x-layer" | "fantom" | "fraxtal" | "zksync" | "moonbeam" | "kava" | "base" | "arbitrum" | "celo" | "avalanche" | "aurora";
|
|
7
|
+
export type IChainId = 1 | 10 | 56 | 100 | 137 | 196 | 250 | 252 | 324 | 1284 | 2222 | 8453 | 42161 | 42220 | 43114 | 1313161554;
|
|
8
8
|
export type IFactoryPoolType = "factory" | "factory-crvusd" | "factory-eywa" | "factory-crypto" | "factory-twocrypto" | "factory-tricrypto" | "factory-stable-ng";
|
|
9
9
|
export type IPoolType = "main" | "crypto" | IFactoryPoolType;
|
|
10
10
|
export type ISwapType = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
package/lib/router.js
CHANGED
|
@@ -95,15 +95,6 @@ var _handleSwapType = function (swapType) {
|
|
|
95
95
|
return swapType.toString();
|
|
96
96
|
};
|
|
97
97
|
var SNX = {
|
|
98
|
-
1: {
|
|
99
|
-
swap: "0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F".toLowerCase(),
|
|
100
|
-
coins: [
|
|
101
|
-
"0x57Ab1ec28D129707052df4dF418D58a2D46d5f51",
|
|
102
|
-
"0xD71eCFF9342A5Ced620049e616c5035F1dB98620",
|
|
103
|
-
"0x5e74C9036fb86BD7eCdcb084a0673EFc32eA31cb",
|
|
104
|
-
"0xfE18be6b3Bd88A2D2A7f928d00292E7a9963CfC6", // sBTC
|
|
105
|
-
].map(function (a) { return a.toLowerCase(); }),
|
|
106
|
-
},
|
|
107
98
|
10: {
|
|
108
99
|
swap: "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4".toLowerCase(),
|
|
109
100
|
coins: [
|
|
@@ -708,6 +699,14 @@ var _getOutputForRoute = memoize(function (route, _amount) { return __awaiter(vo
|
|
|
708
699
|
promise: true,
|
|
709
700
|
maxAge: 15 * 1000, // 15s
|
|
710
701
|
});
|
|
702
|
+
var _routesCache = {};
|
|
703
|
+
var _getBestRouteAndOutput = function (inputCoin, outputCoin, amount) {
|
|
704
|
+
var _a = _getCoinAddresses(inputCoin, outputCoin), inputCoinAddress = _a[0], outputCoinAddress = _a[1];
|
|
705
|
+
var key = "".concat(inputCoinAddress, "-").concat(outputCoinAddress, "-").concat(amount);
|
|
706
|
+
if (!(key in _routesCache))
|
|
707
|
+
throw Error("You must call getBestRouteAndOutput first");
|
|
708
|
+
return _routesCache[key];
|
|
709
|
+
};
|
|
711
710
|
export var getBestRouteAndOutput = function (inputCoin, outputCoin, amount) { return __awaiter(void 0, void 0, void 0, function () {
|
|
712
711
|
var _a, inputCoinAddress, outputCoinAddress, _b, inputCoinDecimals, outputCoinDecimals, route, _output;
|
|
713
712
|
return __generator(this, function (_c) {
|
|
@@ -723,6 +722,11 @@ export var getBestRouteAndOutput = function (inputCoin, outputCoin, amount) { re
|
|
|
723
722
|
return [4 /*yield*/, _getOutputForRoute(route, parseUnits(amount, inputCoinDecimals))];
|
|
724
723
|
case 2:
|
|
725
724
|
_output = _c.sent();
|
|
725
|
+
_routesCache["".concat(inputCoinAddress, "-").concat(outputCoinAddress, "-").concat(amount)] = {
|
|
726
|
+
route: route,
|
|
727
|
+
output: curve.formatUnits(_output + BigInt(1), outputCoinDecimals),
|
|
728
|
+
timestamp: Date.now(),
|
|
729
|
+
};
|
|
726
730
|
return [2 /*return*/, { route: route, output: curve.formatUnits(_output + BigInt(1), outputCoinDecimals) }];
|
|
727
731
|
}
|
|
728
732
|
});
|
|
@@ -779,9 +783,7 @@ export var swapPriceImpact = function (inputCoin, outputCoin, amount) { return _
|
|
|
779
783
|
case 0:
|
|
780
784
|
_a = _getCoinAddresses(inputCoin, outputCoin), inputCoinAddress = _a[0], outputCoinAddress = _a[1];
|
|
781
785
|
_b = _getCoinDecimals(inputCoinAddress, outputCoinAddress), inputCoinDecimals = _b[0], outputCoinDecimals = _b[1];
|
|
782
|
-
|
|
783
|
-
case 1:
|
|
784
|
-
_c = _e.sent(), route = _c.route, output = _c.output;
|
|
786
|
+
_c = _getBestRouteAndOutput(inputCoinAddress, outputCoinAddress, amount), route = _c.route, output = _c.output;
|
|
785
787
|
_amount = parseUnits(amount, inputCoinDecimals);
|
|
786
788
|
_output = parseUnits(output, outputCoinDecimals);
|
|
787
789
|
smallAmountIntBN = _get_small_x(_amount, _output, inputCoinDecimals, outputCoinDecimals);
|
|
@@ -791,21 +793,21 @@ export var swapPriceImpact = function (inputCoin, outputCoin, amount) { return _
|
|
|
791
793
|
contract = curve.contracts[curve.constants.ALIASES.router].contract;
|
|
792
794
|
_smallAmount = fromBN(smallAmountIntBN.div(Math.pow(10, inputCoinDecimals)), inputCoinDecimals);
|
|
793
795
|
_d = _getExchangeArgs(route), _route = _d._route, _swapParams = _d._swapParams, _pools = _d._pools;
|
|
794
|
-
_e.label =
|
|
795
|
-
case
|
|
796
|
-
_e.trys.push([
|
|
796
|
+
_e.label = 1;
|
|
797
|
+
case 1:
|
|
798
|
+
_e.trys.push([1, 3, , 5]);
|
|
797
799
|
return [4 /*yield*/, contract.get_dy(_route, _swapParams, _smallAmount, _pools, curve.constantOptions)];
|
|
798
|
-
case
|
|
800
|
+
case 2:
|
|
799
801
|
_smallOutput = _e.sent();
|
|
800
|
-
return [3 /*break*/,
|
|
801
|
-
case
|
|
802
|
+
return [3 /*break*/, 5];
|
|
803
|
+
case 3:
|
|
802
804
|
e_2 = _e.sent();
|
|
803
805
|
_smallAmount = curve.parseUnits("1", inputCoinDecimals); // Dirty hack
|
|
804
806
|
return [4 /*yield*/, contract.get_dy(_route, _swapParams, _smallAmount, _pools, curve.constantOptions)];
|
|
805
|
-
case
|
|
807
|
+
case 4:
|
|
806
808
|
_smallOutput = _e.sent();
|
|
807
|
-
return [3 /*break*/,
|
|
808
|
-
case
|
|
809
|
+
return [3 /*break*/, 5];
|
|
810
|
+
case 5:
|
|
809
811
|
priceImpactBN = _get_price_impact(_amount, _output, _smallAmount, _smallOutput, inputCoinDecimals, outputCoinDecimals);
|
|
810
812
|
return [2 /*return*/, Number(_cutZeros(priceImpactBN.toFixed(4)))];
|
|
811
813
|
}
|
|
@@ -842,14 +844,12 @@ export var swapEstimateGas = function (inputCoin, outputCoin, amount) { return _
|
|
|
842
844
|
case 0:
|
|
843
845
|
_a = _getCoinAddresses(inputCoin, outputCoin), inputCoinAddress = _a[0], outputCoinAddress = _a[1];
|
|
844
846
|
inputCoinDecimals = _getCoinDecimals(inputCoinAddress, outputCoinAddress)[0];
|
|
845
|
-
|
|
846
|
-
case 1:
|
|
847
|
-
route = (_b.sent()).route;
|
|
847
|
+
route = _getBestRouteAndOutput(inputCoinAddress, outputCoinAddress, amount).route;
|
|
848
848
|
if (route.length === 0)
|
|
849
849
|
return [2 /*return*/, 0];
|
|
850
850
|
_amount = parseUnits(amount, inputCoinDecimals);
|
|
851
851
|
return [4 /*yield*/, _estimateGasForDifferentRoutes([route], inputCoinAddress, outputCoinAddress, _amount)];
|
|
852
|
-
case
|
|
852
|
+
case 1:
|
|
853
853
|
gas = (_b.sent())[0];
|
|
854
854
|
return [2 /*return*/, gas];
|
|
855
855
|
}
|
|
@@ -867,9 +867,7 @@ export var swap = function (inputCoin, outputCoin, amount, slippage) {
|
|
|
867
867
|
return [4 /*yield*/, swapApprove(inputCoin, amount)];
|
|
868
868
|
case 1:
|
|
869
869
|
_f.sent();
|
|
870
|
-
|
|
871
|
-
case 2:
|
|
872
|
-
_c = _f.sent(), route = _c.route, output = _c.output;
|
|
870
|
+
_c = _getBestRouteAndOutput(inputCoinAddress, outputCoinAddress, amount), route = _c.route, output = _c.output;
|
|
873
871
|
if (route.length === 0) {
|
|
874
872
|
throw new Error("This pair can't be exchanged");
|
|
875
873
|
}
|
|
@@ -880,14 +878,14 @@ export var swap = function (inputCoin, outputCoin, amount, slippage) {
|
|
|
880
878
|
contract = curve.contracts[curve.constants.ALIASES.router].contract;
|
|
881
879
|
value = isEth(inputCoinAddress) ? _amount : curve.parseUnits("0");
|
|
882
880
|
return [4 /*yield*/, curve.updateFeeData()];
|
|
883
|
-
case
|
|
881
|
+
case 2:
|
|
884
882
|
_f.sent();
|
|
885
883
|
_e = DIGas;
|
|
886
884
|
return [4 /*yield*/, contract.exchange.estimateGas(_route, _swapParams, _amount, _minRecvAmount, _pools, __assign(__assign({}, curve.constantOptions), { value: value }))];
|
|
887
|
-
case
|
|
885
|
+
case 3:
|
|
888
886
|
gasLimit = (_e.apply(void 0, [_f.sent()])) * (curve.chainId === 1 ? curve.parseUnits("130", 0) : curve.parseUnits("160", 0)) / curve.parseUnits("100", 0);
|
|
889
887
|
return [4 /*yield*/, contract.exchange(_route, _swapParams, _amount, _minRecvAmount, _pools, __assign(__assign({}, curve.options), { value: value, gasLimit: gasLimit }))];
|
|
890
|
-
case
|
|
888
|
+
case 4: return [2 /*return*/, _f.sent()];
|
|
891
889
|
}
|
|
892
890
|
});
|
|
893
891
|
});
|
package/lib/utils.js
CHANGED
|
@@ -627,6 +627,7 @@ export var _getUsdRate = function (assetId) { return __awaiter(void 0, void 0, v
|
|
|
627
627
|
56: "binance-smart-chain",
|
|
628
628
|
100: 'xdai',
|
|
629
629
|
137: 'polygon-pos',
|
|
630
|
+
196: 'x-layer',
|
|
630
631
|
250: 'fantom',
|
|
631
632
|
252: 'fraxtal',
|
|
632
633
|
324: 'zksync',
|
|
@@ -644,6 +645,7 @@ export var _getUsdRate = function (assetId) { return __awaiter(void 0, void 0, v
|
|
|
644
645
|
56: 'binancecoin',
|
|
645
646
|
100: 'xdai',
|
|
646
647
|
137: 'matic-network',
|
|
648
|
+
196: 'x-layer',
|
|
647
649
|
250: 'fantom',
|
|
648
650
|
252: 'frax-ether',
|
|
649
651
|
324: 'ethereum',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@curvefi/api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.58.0",
|
|
4
4
|
"description": "JavaScript library for curve.fi",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Macket",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"axios": "^0.21.1",
|
|
36
36
|
"bignumber.js": "^9.0.1",
|
|
37
|
-
"ethcall": "
|
|
37
|
+
"ethcall": "6.0.5",
|
|
38
38
|
"ethers": "^6.11.0",
|
|
39
39
|
"memoizee": "^0.4.15"
|
|
40
40
|
}
|