@curvefi/api 1.6.1 → 1.9.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/README.md +340 -8
- package/lib/boosting.d.ts +3 -0
- package/lib/boosting.js +30 -3
- package/lib/constants/abis/abis-ethereum.js +2 -2
- package/lib/constants/abis/json/registry_exchange.json +0 -37
- package/lib/constants/abis/json/tricrypto2/deposit.json +0 -79
- package/lib/curve.d.ts +1 -0
- package/lib/curve.js +47 -9
- package/lib/index.d.ts +9 -0
- package/lib/index.js +9 -0
- package/lib/pools.d.ts +6 -11
- package/lib/pools.js +413 -343
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +25 -3
- package/package.json +1 -1
- package/lib/constants/abis/json/registry.json +0 -940
package/lib/curve.js
CHANGED
|
@@ -46,6 +46,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
49
58
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
59
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
60
|
};
|
|
@@ -61,6 +70,7 @@ var votingescrow_json_1 = __importDefault(require("./constants/abis/json/votinge
|
|
|
61
70
|
var address_provider_json_1 = __importDefault(require("./constants/abis/json/address_provider.json"));
|
|
62
71
|
var gaugecontroller_json_1 = __importDefault(require("./constants/abis/json/gaugecontroller.json"));
|
|
63
72
|
var router_json_1 = __importDefault(require("./constants/abis/json/router.json"));
|
|
73
|
+
var registry_exchange_json_1 = __importDefault(require("./constants/abis/json/registry_exchange.json"));
|
|
64
74
|
var abis_ethereum_1 = require("./constants/abis/abis-ethereum");
|
|
65
75
|
exports.ALIASES = {
|
|
66
76
|
"crv": "0xD533a949740bb3306d119CC777fa900bA034cd52",
|
|
@@ -72,6 +82,7 @@ exports.ALIASES = {
|
|
|
72
82
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
73
83
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
74
84
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
85
|
+
"registry_exchange": "",
|
|
75
86
|
};
|
|
76
87
|
var cTokens = [
|
|
77
88
|
'0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643',
|
|
@@ -101,6 +112,7 @@ var aTokens = [
|
|
|
101
112
|
"0x3Ed3B47Dd13EC9a98b44e6204A523E766B225811",
|
|
102
113
|
"0x6c5024cd4f8a59110119c56f8933403a539555eb", // sSUSD
|
|
103
114
|
];
|
|
115
|
+
var customAbiTokens = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], cTokens, true), yTokens, true), ycTokens, true), aTokens, true);
|
|
104
116
|
var Curve = /** @class */ (function () {
|
|
105
117
|
function Curve() {
|
|
106
118
|
// @ts-ignore
|
|
@@ -119,9 +131,9 @@ var Curve = /** @class */ (function () {
|
|
|
119
131
|
) {
|
|
120
132
|
if (options === void 0) { options = {}; }
|
|
121
133
|
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
-
var _a, _i, _b, pool, _c, _d, coinAddr, _e, _f, coinAddr;
|
|
123
|
-
return __generator(this, function (
|
|
124
|
-
switch (
|
|
134
|
+
var _a, _i, _b, pool, _c, _d, coinAddr, _e, _f, coinAddr, _g, _h, coinAddr, addressProviderContract, _j;
|
|
135
|
+
return __generator(this, function (_k) {
|
|
136
|
+
switch (_k.label) {
|
|
125
137
|
case 0:
|
|
126
138
|
// JsonRpc provider
|
|
127
139
|
if (providerType.toLowerCase() === 'JsonRpc'.toLowerCase()) {
|
|
@@ -160,20 +172,20 @@ var Curve = /** @class */ (function () {
|
|
|
160
172
|
this.multicallProvider = new ethers_multicall_1.Provider(this.provider);
|
|
161
173
|
return [4 /*yield*/, this.multicallProvider.init()];
|
|
162
174
|
case 2:
|
|
163
|
-
|
|
164
|
-
|
|
175
|
+
_k.sent();
|
|
176
|
+
_k.label = 3;
|
|
165
177
|
case 3:
|
|
166
178
|
if (!this.signer) return [3 /*break*/, 5];
|
|
167
179
|
_a = this;
|
|
168
180
|
return [4 /*yield*/, this.signer.getAddress()];
|
|
169
181
|
case 4:
|
|
170
|
-
_a.signerAddress =
|
|
171
|
-
|
|
182
|
+
_a.signerAddress = _k.sent();
|
|
183
|
+
_k.label = 5;
|
|
172
184
|
case 5:
|
|
173
185
|
this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
|
|
174
186
|
return [4 /*yield*/, this.updateFeeData()];
|
|
175
187
|
case 6:
|
|
176
|
-
|
|
188
|
+
_k.sent();
|
|
177
189
|
// TODO delete toLowerCase()
|
|
178
190
|
for (_i = 0, _b = Object.values(abis_ethereum_1.poolsData); _i < _b.length; _i++) {
|
|
179
191
|
pool = _b[_i];
|
|
@@ -224,9 +236,22 @@ var Curve = /** @class */ (function () {
|
|
|
224
236
|
multicallContract: new ethers_multicall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
225
237
|
};
|
|
226
238
|
}
|
|
227
|
-
// TODO add all coins
|
|
228
239
|
for (_e = 0, _f = pool.coin_addresses; _e < _f.length; _e++) {
|
|
229
240
|
coinAddr = _f[_e];
|
|
241
|
+
if (customAbiTokens.includes(coinAddr))
|
|
242
|
+
continue;
|
|
243
|
+
this.contracts[coinAddr] = {
|
|
244
|
+
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
245
|
+
multicallContract: new ethers_multicall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
246
|
+
};
|
|
247
|
+
this.contracts[coinAddr.toLowerCase()] = {
|
|
248
|
+
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
249
|
+
multicallContract: new ethers_multicall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
// TODO add all coins
|
|
253
|
+
for (_g = 0, _h = pool.coin_addresses; _g < _h.length; _g++) {
|
|
254
|
+
coinAddr = _h[_g];
|
|
230
255
|
if (cTokens.includes(coinAddr)) {
|
|
231
256
|
this.contracts[coinAddr] = {
|
|
232
257
|
contract: new ethers_1.Contract(coinAddr, cERC20_json_1.default, this.signer || this.provider),
|
|
@@ -283,6 +308,19 @@ var Curve = /** @class */ (function () {
|
|
|
283
308
|
contract: new ethers_1.Contract(exports.ALIASES.address_provider, address_provider_json_1.default, this.signer || this.provider),
|
|
284
309
|
multicallContract: new ethers_multicall_1.Contract(exports.ALIASES.address_provider, address_provider_json_1.default),
|
|
285
310
|
};
|
|
311
|
+
addressProviderContract = this.contracts[exports.ALIASES.address_provider].contract;
|
|
312
|
+
_j = exports.ALIASES;
|
|
313
|
+
return [4 /*yield*/, addressProviderContract.get_address(2, this.constantOptions)];
|
|
314
|
+
case 7:
|
|
315
|
+
_j.registry_exchange = _k.sent();
|
|
316
|
+
this.contracts[exports.ALIASES.registry_exchange] = {
|
|
317
|
+
contract: new ethers_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default, this.signer || this.provider),
|
|
318
|
+
multicallContract: new ethers_multicall_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default),
|
|
319
|
+
};
|
|
320
|
+
this.contracts[exports.ALIASES.registry_exchange.toLowerCase()] = {
|
|
321
|
+
contract: new ethers_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default, this.signer || this.provider),
|
|
322
|
+
multicallContract: new ethers_multicall_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default),
|
|
323
|
+
};
|
|
286
324
|
this.contracts[exports.ALIASES.gauge_controller] = {
|
|
287
325
|
contract: new ethers_1.Contract(exports.ALIASES.gauge_controller, gaugecontroller_json_1.default, this.signer || this.provider),
|
|
288
326
|
multicallContract: new ethers_multicall_1.Contract(exports.ALIASES.gauge_controller, gaugecontroller_json_1.default),
|
package/lib/index.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ declare const curve: {
|
|
|
34
34
|
output: string;
|
|
35
35
|
}>;
|
|
36
36
|
exchangeExpected: (inputCoin: string, outputCoin: string, amount: string) => Promise<string>;
|
|
37
|
+
exchangeIsApproved: (inputCoin: string, outputCoin: string, amount: string) => Promise<boolean>;
|
|
38
|
+
exchangeApprove: (inputCoin: string, outputCoin: string, amount: string) => Promise<string[]>;
|
|
37
39
|
exchange: (inputCoin: string, outputCoin: string, amount: string, maxSlippage?: number) => Promise<string>;
|
|
38
40
|
crossAssetExchangeAvailable: (inputCoin: string, outputCoin: string) => Promise<boolean>;
|
|
39
41
|
crossAssetExchangeOutputAndSlippage: (inputCoin: string, outputCoin: string, amount: string) => Promise<{
|
|
@@ -41,10 +43,14 @@ declare const curve: {
|
|
|
41
43
|
output: string;
|
|
42
44
|
}>;
|
|
43
45
|
crossAssetExchangeExpected: (inputCoin: string, outputCoin: string, amount: string) => Promise<string>;
|
|
46
|
+
crossAssetExchangeIsApproved: (inputCoin: string, amount: string) => Promise<boolean>;
|
|
47
|
+
crossAssetExchangeApprove: (inputCoin: string, amount: string) => Promise<string[]>;
|
|
44
48
|
crossAssetExchange: (inputCoin: string, outputCoin: string, amount: string, maxSlippage?: number) => Promise<string>;
|
|
45
49
|
estimateGas: {
|
|
46
50
|
ensureAllowance: (coins: string[], amounts: string[], spender: string) => Promise<number>;
|
|
51
|
+
exchangeApprove: (inputCoin: string, outputCoin: string, amount: string) => Promise<number>;
|
|
47
52
|
exchange: (inputCoin: string, outputCoin: string, amount: string, maxSlippage?: number) => Promise<number>;
|
|
53
|
+
crossAssetExchangeApprove: (inputCoin: string, amount: string) => Promise<number>;
|
|
48
54
|
crossAssetExchange: (inputCoin: string, outputCoin: string, amount: string, maxSlippage?: number) => Promise<number>;
|
|
49
55
|
};
|
|
50
56
|
boosting: {
|
|
@@ -58,11 +64,14 @@ declare const curve: {
|
|
|
58
64
|
}>;
|
|
59
65
|
getVeCrv: (...addresses: string[] | string[][]) => Promise<string | import("./interfaces").DictInterface<string>>;
|
|
60
66
|
getVeCrvPct: (...addresses: string[] | string[][]) => Promise<string | import("./interfaces").DictInterface<string>>;
|
|
67
|
+
isApproved: (amount: string) => Promise<boolean>;
|
|
68
|
+
approve: (amount: string) => Promise<string[]>;
|
|
61
69
|
createLock: (amount: string, days: number) => Promise<string>;
|
|
62
70
|
increaseAmount: (amount: string) => Promise<string>;
|
|
63
71
|
increaseUnlockTime: (days: number) => Promise<string>;
|
|
64
72
|
withdrawLockedCrv: () => Promise<string>;
|
|
65
73
|
estimateGas: {
|
|
74
|
+
approve: (amount: string) => Promise<number>;
|
|
66
75
|
createLock: (amount: string, days: number) => Promise<number>;
|
|
67
76
|
increaseAmount: (amount: string) => Promise<number>;
|
|
68
77
|
increaseUnlockTime: (days: number) => Promise<number>;
|
package/lib/index.js
CHANGED
|
@@ -69,14 +69,20 @@ var curve = {
|
|
|
69
69
|
ensureAllowance: utils_1.ensureAllowance,
|
|
70
70
|
getBestPoolAndOutput: pools_1.getBestPoolAndOutput,
|
|
71
71
|
exchangeExpected: pools_1.exchangeExpected,
|
|
72
|
+
exchangeIsApproved: pools_1.exchangeIsApproved,
|
|
73
|
+
exchangeApprove: pools_1.exchangeApprove,
|
|
72
74
|
exchange: pools_1.exchange,
|
|
73
75
|
crossAssetExchangeAvailable: pools_1.crossAssetExchangeAvailable,
|
|
74
76
|
crossAssetExchangeOutputAndSlippage: pools_1.crossAssetExchangeOutputAndSlippage,
|
|
75
77
|
crossAssetExchangeExpected: pools_1.crossAssetExchangeExpected,
|
|
78
|
+
crossAssetExchangeIsApproved: pools_1.crossAssetExchangeIsApproved,
|
|
79
|
+
crossAssetExchangeApprove: pools_1.crossAssetExchangeApprove,
|
|
76
80
|
crossAssetExchange: pools_1.crossAssetExchange,
|
|
77
81
|
estimateGas: {
|
|
78
82
|
ensureAllowance: utils_1.ensureAllowanceEstimateGas,
|
|
83
|
+
exchangeApprove: pools_1.exchangeApproveEstimateGas,
|
|
79
84
|
exchange: pools_1.exchangeEstimateGas,
|
|
85
|
+
crossAssetExchangeApprove: pools_1.crossAssetExchangeApproveEstimateGas,
|
|
80
86
|
crossAssetExchange: pools_1.crossAssetExchangeEstimateGas,
|
|
81
87
|
},
|
|
82
88
|
boosting: {
|
|
@@ -84,11 +90,14 @@ var curve = {
|
|
|
84
90
|
getLockedAmountAndUnlockTime: boosting_1.getLockedAmountAndUnlockTime,
|
|
85
91
|
getVeCrv: boosting_1.getVeCrv,
|
|
86
92
|
getVeCrvPct: boosting_1.getVeCrvPct,
|
|
93
|
+
isApproved: boosting_1.isApproved,
|
|
94
|
+
approve: boosting_1.approve,
|
|
87
95
|
createLock: boosting_1.createLock,
|
|
88
96
|
increaseAmount: boosting_1.increaseAmount,
|
|
89
97
|
increaseUnlockTime: boosting_1.increaseUnlockTime,
|
|
90
98
|
withdrawLockedCrv: boosting_1.withdrawLockedCrv,
|
|
91
99
|
estimateGas: {
|
|
100
|
+
approve: boosting_1.approveEstimateGas,
|
|
92
101
|
createLock: boosting_1.createLockEstimateGas,
|
|
93
102
|
increaseAmount: boosting_1.increaseAmountEstimateGas,
|
|
94
103
|
increaseUnlockTime: boosting_1.increaseUnlockTimeEstimateGas,
|
package/lib/pools.d.ts
CHANGED
|
@@ -36,8 +36,6 @@ export declare class Pool {
|
|
|
36
36
|
removeLiquidityOneCoinWrapped: (lpTokenAmount: string, coin: string | number) => Promise<number>;
|
|
37
37
|
exchangeApprove: (inputCoin: string | number, amount: string) => Promise<number>;
|
|
38
38
|
exchange: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number) => Promise<number>;
|
|
39
|
-
exchangeTricryptoApprove: (inputCoin: string | number, amount: string, useEth?: boolean) => Promise<number>;
|
|
40
|
-
exchangeTricrypto: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number, useEth?: boolean) => Promise<number>;
|
|
41
39
|
exchangeWrappedApprove: (inputCoin: string | number, amount: string) => Promise<number>;
|
|
42
40
|
exchangeWrapped: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number) => Promise<number>;
|
|
43
41
|
};
|
|
@@ -112,11 +110,6 @@ export declare class Pool {
|
|
|
112
110
|
exchangeApprove: (inputCoin: string | number, amount: string) => Promise<string[]>;
|
|
113
111
|
private exchangeEstimateGas;
|
|
114
112
|
exchange: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage?: number) => Promise<string>;
|
|
115
|
-
exchangeTricryptoIsApproved: (inputCoin: string | number, amount: string, useEth?: boolean) => Promise<boolean>;
|
|
116
|
-
private exchangeTricryptoApproveEstimateGas;
|
|
117
|
-
exchangeTricryptoApprove: (inputCoin: string | number, amount: string, useEth?: boolean) => Promise<string[]>;
|
|
118
|
-
private exchangeTricryptoEstimateGas;
|
|
119
|
-
exchangeTricrypto: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage?: number, useEth?: boolean) => Promise<string>;
|
|
120
113
|
exchangeWrappedExpected: (inputCoin: string | number, outputCoin: string | number, amount: string) => Promise<string>;
|
|
121
114
|
exchangeWrappedIsApproved: (inputCoin: string | number, amount: string) => Promise<boolean>;
|
|
122
115
|
private exchangeWrappedApproveEstimateGas;
|
|
@@ -163,15 +156,14 @@ export declare class Pool {
|
|
|
163
156
|
private _getExchangeOutput;
|
|
164
157
|
private _getExchangeOutputWrapped;
|
|
165
158
|
}
|
|
166
|
-
export declare const _getBestPoolAndOutput: (inputCoinAddress: string, outputCoinAddress: string, inputCoinDecimals: number, amount: string) => Promise<{
|
|
167
|
-
poolAddress: string;
|
|
168
|
-
output: ethers.BigNumber;
|
|
169
|
-
}>;
|
|
170
159
|
export declare const getBestPoolAndOutput: (inputCoin: string, outputCoin: string, amount: string) => Promise<{
|
|
171
160
|
poolAddress: string;
|
|
172
161
|
output: string;
|
|
173
162
|
}>;
|
|
174
163
|
export declare const exchangeExpected: (inputCoin: string, outputCoin: string, amount: string) => Promise<string>;
|
|
164
|
+
export declare const exchangeIsApproved: (inputCoin: string, outputCoin: string, amount: string) => Promise<boolean>;
|
|
165
|
+
export declare const exchangeApproveEstimateGas: (inputCoin: string, outputCoin: string, amount: string) => Promise<number>;
|
|
166
|
+
export declare const exchangeApprove: (inputCoin: string, outputCoin: string, amount: string) => Promise<string[]>;
|
|
175
167
|
export declare const exchangeEstimateGas: (inputCoin: string, outputCoin: string, amount: string, maxSlippage?: number) => Promise<number>;
|
|
176
168
|
export declare const exchange: (inputCoin: string, outputCoin: string, amount: string, maxSlippage?: number) => Promise<string>;
|
|
177
169
|
export declare const crossAssetExchangeAvailable: (inputCoin: string, outputCoin: string) => Promise<boolean>;
|
|
@@ -187,5 +179,8 @@ export declare const crossAssetExchangeOutputAndSlippage: (inputCoin: string, ou
|
|
|
187
179
|
output: string;
|
|
188
180
|
}>;
|
|
189
181
|
export declare const crossAssetExchangeExpected: (inputCoin: string, outputCoin: string, amount: string) => Promise<string>;
|
|
182
|
+
export declare const crossAssetExchangeIsApproved: (inputCoin: string, amount: string) => Promise<boolean>;
|
|
183
|
+
export declare const crossAssetExchangeApproveEstimateGas: (inputCoin: string, amount: string) => Promise<number>;
|
|
184
|
+
export declare const crossAssetExchangeApprove: (inputCoin: string, amount: string) => Promise<string[]>;
|
|
190
185
|
export declare const crossAssetExchangeEstimateGas: (inputCoin: string, outputCoin: string, amount: string, maxSlippage?: number) => Promise<number>;
|
|
191
186
|
export declare const crossAssetExchange: (inputCoin: string, outputCoin: string, amount: string, maxSlippage?: number) => Promise<string>;
|