@curvefi/api 2.58.9 → 2.58.11
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/curve.js
CHANGED
|
@@ -112,7 +112,7 @@ import { lowerCasePoolDataAddresses, extractDecimals, extractGauges } from "./co
|
|
|
112
112
|
import { _getAllGauges, _getHiddenPools } from "./external-api.js";
|
|
113
113
|
import { L2Networks } from "./constants/L2Networks.js";
|
|
114
114
|
import { getTwocryptoFactoryPoolData } from "./factory/factory-twocrypto.js";
|
|
115
|
-
import {
|
|
115
|
+
import { memoizedContract, memoizedMulticallContract } from "./utils.js";
|
|
116
116
|
var _killGauges = function (poolsData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
117
117
|
var gaugeData, isKilled, gaugeStatuses, poolId;
|
|
118
118
|
return __generator(this, function (_a) {
|
|
@@ -412,7 +412,7 @@ var Curve = /** @class */ (function () {
|
|
|
412
412
|
return __generator(this, function (_h) {
|
|
413
413
|
switch (_h.label) {
|
|
414
414
|
case 0:
|
|
415
|
-
if ([252, 1313161554].includes(this.chainId))
|
|
415
|
+
if ([196, 252, 1313161554].includes(this.chainId))
|
|
416
416
|
return [2 /*return*/];
|
|
417
417
|
if (!useApi) return [3 /*break*/, 2];
|
|
418
418
|
_a = this.constants;
|
|
@@ -679,7 +679,7 @@ var Curve = /** @class */ (function () {
|
|
|
679
679
|
return __generator(this, function (_b) {
|
|
680
680
|
switch (_b.label) {
|
|
681
681
|
case 0:
|
|
682
|
-
if ([252, 1313161554].includes(this.chainId))
|
|
682
|
+
if ([196, 252, 1313161554].includes(this.chainId))
|
|
683
683
|
return [2 /*return*/, []];
|
|
684
684
|
currentPoolIds = Object.keys(this.constants.FACTORY_POOLS_DATA);
|
|
685
685
|
lastPoolIdx = currentPoolIds.length === 0 ? -1 : Number(currentPoolIds[currentPoolIds.length - 1].split("-")[2]);
|
|
@@ -772,7 +772,7 @@ var Curve = /** @class */ (function () {
|
|
|
772
772
|
return __generator(this, function (_b) {
|
|
773
773
|
switch (_b.label) {
|
|
774
774
|
case 0:
|
|
775
|
-
if ([252, 1313161554].includes(this.chainId))
|
|
775
|
+
if ([196, 252, 1313161554].includes(this.chainId))
|
|
776
776
|
return [2 /*return*/, ''];
|
|
777
777
|
_a = lowerCasePoolDataAddresses;
|
|
778
778
|
return [4 /*yield*/, getFactoryPoolData.call(this, 0, poolAddress)];
|
|
@@ -903,9 +903,9 @@ var Curve = /** @class */ (function () {
|
|
|
903
903
|
var _a;
|
|
904
904
|
if (options === void 0) { options = {}; }
|
|
905
905
|
return __awaiter(this, void 0, void 0, function () {
|
|
906
|
-
var jsonRpcApiProviderOptions, _b, e_1, _c, network, poolId, _d, cTokens, yTokens, ycTokens, aTokens, customAbiTokens, _e, err_1,
|
|
907
|
-
return __generator(this, function (
|
|
908
|
-
switch (
|
|
906
|
+
var jsonRpcApiProviderOptions, _b, e_1, _c, network, poolId, _d, cTokens, yTokens, ycTokens, aTokens, customAbiTokens, _e, err_1, _i, _f, pool, _g, _h, coinAddr, _j, _k, coinAddr, _l, _m, coinAddr, _gaugeFactoryABI, factoryContract, _o, curveInstance_1, originalEstimate_1, oldEstimate, newEstimate;
|
|
907
|
+
return __generator(this, function (_p) {
|
|
908
|
+
switch (_p.label) {
|
|
909
909
|
case 0:
|
|
910
910
|
// @ts-ignore
|
|
911
911
|
this.provider = null;
|
|
@@ -960,16 +960,16 @@ var Curve = /** @class */ (function () {
|
|
|
960
960
|
return [3 /*break*/, 5];
|
|
961
961
|
case 1:
|
|
962
962
|
if (!!((_a = providerSettings.url) === null || _a === void 0 ? void 0 : _a.startsWith("https://rpc.gnosischain.com"))) return [3 /*break*/, 5];
|
|
963
|
-
|
|
963
|
+
_p.label = 2;
|
|
964
964
|
case 2:
|
|
965
|
-
|
|
965
|
+
_p.trys.push([2, 4, , 5]);
|
|
966
966
|
_b = this;
|
|
967
967
|
return [4 /*yield*/, this.provider.getSigner()];
|
|
968
968
|
case 3:
|
|
969
|
-
_b.signer =
|
|
969
|
+
_b.signer = _p.sent();
|
|
970
970
|
return [3 /*break*/, 5];
|
|
971
971
|
case 4:
|
|
972
|
-
e_1 =
|
|
972
|
+
e_1 = _p.sent();
|
|
973
973
|
this.signer = null;
|
|
974
974
|
return [3 /*break*/, 5];
|
|
975
975
|
case 5: return [3 /*break*/, 9];
|
|
@@ -980,7 +980,7 @@ var Curve = /** @class */ (function () {
|
|
|
980
980
|
_c = this;
|
|
981
981
|
return [4 /*yield*/, this.provider.getSigner()];
|
|
982
982
|
case 7:
|
|
983
|
-
_c.signer =
|
|
983
|
+
_c.signer = _p.sent();
|
|
984
984
|
return [3 /*break*/, 9];
|
|
985
985
|
case 8:
|
|
986
986
|
if (providerType.toLowerCase() === 'Infura'.toLowerCase()) {
|
|
@@ -997,10 +997,10 @@ var Curve = /** @class */ (function () {
|
|
|
997
997
|
else {
|
|
998
998
|
throw Error('Wrong providerType');
|
|
999
999
|
}
|
|
1000
|
-
|
|
1000
|
+
_p.label = 9;
|
|
1001
1001
|
case 9: return [4 /*yield*/, this.provider.getNetwork()];
|
|
1002
1002
|
case 10:
|
|
1003
|
-
network =
|
|
1003
|
+
network = _p.sent();
|
|
1004
1004
|
console.log("CURVE-JS IS CONNECTED TO NETWORK:", { name: network.name.toUpperCase(), chainId: Number(network.chainId) });
|
|
1005
1005
|
this.chainId = Number(network.chainId) === 133 || Number(network.chainId) === 31337 ? 1 : Number(network.chainId);
|
|
1006
1006
|
this.constants.NATIVE_TOKEN = NATIVE_TOKENS[this.chainId];
|
|
@@ -1027,35 +1027,29 @@ var Curve = /** @class */ (function () {
|
|
|
1027
1027
|
customAbiTokens = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], cTokens, true), yTokens, true), ycTokens, true), aTokens, true);
|
|
1028
1028
|
this.multicallProvider = new MulticallProvider(this.chainId, this.provider);
|
|
1029
1029
|
if (!this.signer) return [3 /*break*/, 15];
|
|
1030
|
-
|
|
1030
|
+
_p.label = 11;
|
|
1031
1031
|
case 11:
|
|
1032
|
-
|
|
1032
|
+
_p.trys.push([11, 13, , 14]);
|
|
1033
1033
|
_e = this;
|
|
1034
1034
|
return [4 /*yield*/, this.signer.getAddress()];
|
|
1035
1035
|
case 12:
|
|
1036
|
-
_e.signerAddress =
|
|
1036
|
+
_e.signerAddress = _p.sent();
|
|
1037
1037
|
return [3 /*break*/, 14];
|
|
1038
1038
|
case 13:
|
|
1039
|
-
err_1 =
|
|
1039
|
+
err_1 = _p.sent();
|
|
1040
1040
|
this.signer = null;
|
|
1041
1041
|
return [3 /*break*/, 14];
|
|
1042
1042
|
case 14: return [3 /*break*/, 16];
|
|
1043
1043
|
case 15:
|
|
1044
1044
|
this.signerAddress = '';
|
|
1045
|
-
|
|
1045
|
+
_p.label = 16;
|
|
1046
1046
|
case 16:
|
|
1047
1047
|
this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
|
|
1048
|
-
|
|
1049
|
-
_f = this.setCustomFeeData;
|
|
1050
|
-
return [4 /*yield*/, getGasInfoForL2()];
|
|
1048
|
+
return [4 /*yield*/, this.updateFeeData()];
|
|
1051
1049
|
case 17:
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
case 19:
|
|
1056
|
-
_q.sent();
|
|
1057
|
-
for (_i = 0, _g = Object.values(__assign(__assign({}, this.constants.POOLS_DATA), this.constants.LLAMMAS_DATA)); _i < _g.length; _i++) {
|
|
1058
|
-
pool = _g[_i];
|
|
1050
|
+
_p.sent();
|
|
1051
|
+
for (_i = 0, _f = Object.values(__assign(__assign({}, this.constants.POOLS_DATA), this.constants.LLAMMAS_DATA)); _i < _f.length; _i++) {
|
|
1052
|
+
pool = _f[_i];
|
|
1059
1053
|
this.setContract(pool.swap_address, pool.swap_abi);
|
|
1060
1054
|
if (pool.token_address !== pool.swap_address) {
|
|
1061
1055
|
this.setContract(pool.token_address, ERC20Abi);
|
|
@@ -1066,12 +1060,12 @@ var Curve = /** @class */ (function () {
|
|
|
1066
1060
|
if (pool.deposit_address && !this.contracts[pool.deposit_address]) {
|
|
1067
1061
|
this.setContract(pool.deposit_address, pool.deposit_abi);
|
|
1068
1062
|
}
|
|
1069
|
-
for (
|
|
1070
|
-
coinAddr =
|
|
1063
|
+
for (_g = 0, _h = pool.underlying_coin_addresses; _g < _h.length; _g++) {
|
|
1064
|
+
coinAddr = _h[_g];
|
|
1071
1065
|
this.setContract(coinAddr, ERC20Abi);
|
|
1072
1066
|
}
|
|
1073
|
-
for (
|
|
1074
|
-
coinAddr =
|
|
1067
|
+
for (_j = 0, _k = pool.wrapped_coin_addresses; _j < _k.length; _j++) {
|
|
1068
|
+
coinAddr = _k[_j];
|
|
1075
1069
|
if (customAbiTokens.includes(coinAddr))
|
|
1076
1070
|
continue;
|
|
1077
1071
|
if (coinAddr in this.contracts)
|
|
@@ -1079,8 +1073,8 @@ var Curve = /** @class */ (function () {
|
|
|
1079
1073
|
this.setContract(coinAddr, ERC20Abi);
|
|
1080
1074
|
}
|
|
1081
1075
|
// TODO add all coins
|
|
1082
|
-
for (
|
|
1083
|
-
coinAddr =
|
|
1076
|
+
for (_l = 0, _m = pool.wrapped_coin_addresses; _l < _m.length; _l++) {
|
|
1077
|
+
coinAddr = _m[_l];
|
|
1084
1078
|
if (cTokens.includes(coinAddr)) {
|
|
1085
1079
|
this.setContract(coinAddr, cERC20Abi);
|
|
1086
1080
|
}
|
|
@@ -1120,15 +1114,15 @@ var Curve = /** @class */ (function () {
|
|
|
1120
1114
|
this.setContract(this.constants.ALIASES.crypto_calc, cryptoCalcZapABI);
|
|
1121
1115
|
this.setContract(this.constants.ALIASES.stable_calc, StableCalcZapABI);
|
|
1122
1116
|
this.setContract(this.constants.ALIASES.factory, factoryABI);
|
|
1123
|
-
if (!(this.chainId !== 1313161554 && this.chainId !== 252 && this.chainId !== 196)) return [3 /*break*/,
|
|
1117
|
+
if (!(this.chainId !== 1313161554 && this.chainId !== 252 && this.chainId !== 196)) return [3 /*break*/, 19];
|
|
1124
1118
|
factoryContract = this.contracts[this.constants.ALIASES.factory].contract;
|
|
1125
|
-
|
|
1119
|
+
_o = this.constants.ALIASES;
|
|
1126
1120
|
return [4 /*yield*/, factoryContract.admin(this.constantOptions)];
|
|
1127
|
-
case
|
|
1128
|
-
|
|
1121
|
+
case 18:
|
|
1122
|
+
_o.factory_admin = (_p.sent()).toLowerCase();
|
|
1129
1123
|
this.setContract(this.constants.ALIASES.factory_admin, factoryAdminABI);
|
|
1130
|
-
|
|
1131
|
-
case
|
|
1124
|
+
_p.label = 19;
|
|
1125
|
+
case 19:
|
|
1132
1126
|
this.setContract(this.constants.ALIASES.crvusd_factory, factoryABI);
|
|
1133
1127
|
this.setContract(this.constants.ALIASES.eywa_factory, factoryEywaABI);
|
|
1134
1128
|
this.setContract(this.constants.ALIASES.crypto_factory, cryptoFactoryABI);
|
|
@@ -13,6 +13,7 @@ export declare const lpTokenBasePoolIdDictZkSync: IDict<string>;
|
|
|
13
13
|
export declare const lpTokenBasePoolIdDictBase: IDict<string>;
|
|
14
14
|
export declare const lpTokenBasePoolIdDictBsc: IDict<string>;
|
|
15
15
|
export declare const lpTokenBasePoolIdDictFraxtal: IDict<string>;
|
|
16
|
+
export declare const lpTokenBasePoolIdDictXLayer: IDict<string>;
|
|
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 CRYPTO_FACTORY_CONSTANTS: {
|
|
73
78
|
[index: number]: {
|
|
74
79
|
lpTokenBasePoolIdDict: IDict<string>;
|
|
@@ -22,6 +22,7 @@ export var lpTokenBasePoolIdDictZkSync = lowerCaseKeys({});
|
|
|
22
22
|
export var lpTokenBasePoolIdDictBase = lowerCaseKeys({});
|
|
23
23
|
export var lpTokenBasePoolIdDictBsc = lowerCaseKeys({});
|
|
24
24
|
export var lpTokenBasePoolIdDictFraxtal = lowerCaseKeys({});
|
|
25
|
+
export var lpTokenBasePoolIdDictXLayer = lowerCaseKeys({});
|
|
25
26
|
export var basePoolIdZapDictEthereum = {
|
|
26
27
|
'3pool': {
|
|
27
28
|
address: "0x97aDC08FA1D849D2C48C5dcC1DaB568B169b0267".toLowerCase(),
|
|
@@ -50,6 +51,7 @@ export var basePoolIdZapDictZkSync = {};
|
|
|
50
51
|
export var basePoolIdZapDictBase = {};
|
|
51
52
|
export var basePoolIdZapDictBsc = {};
|
|
52
53
|
export var basePoolIdZapDictFraxtal = {};
|
|
54
|
+
export var basePoolIdZapDictXLayer = {};
|
|
53
55
|
export var CRYPTO_FACTORY_CONSTANTS = {
|
|
54
56
|
1: {
|
|
55
57
|
lpTokenBasePoolIdDict: lpTokenBasePoolIdDictEthereum,
|
|
@@ -71,6 +73,10 @@ export var CRYPTO_FACTORY_CONSTANTS = {
|
|
|
71
73
|
lpTokenBasePoolIdDict: lpTokenBasePoolIdDictPolygon,
|
|
72
74
|
basePoolIdZapDict: basePoolIdZapDictPolygon,
|
|
73
75
|
},
|
|
76
|
+
196: {
|
|
77
|
+
lpTokenBasePoolIdDict: lpTokenBasePoolIdDictXLayer,
|
|
78
|
+
basePoolIdZapDict: basePoolIdZapDictXLayer,
|
|
79
|
+
},
|
|
74
80
|
250: {
|
|
75
81
|
lpTokenBasePoolIdDict: lpTokenBasePoolIdDictFantom,
|
|
76
82
|
basePoolIdZapDict: basePoolIdZapDictFantom,
|