@curvefi/api 1.14.0 → 1.16.1
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 +77 -18
- package/lib/constants/abis/abis-ethereum.js +173 -16
- package/lib/constants/abis/abis-polygon.js +13 -5
- package/lib/constants/abis/json/aave/rewards.json +107 -0
- package/lib/constants/abis/json/atricrypto3/swap.json +63 -63
- package/lib/constants/abis/json/atricrypto3/zap.json +8 -8
- package/lib/constants/abis/json/crveth/swap.json +61 -61
- package/lib/constants/abis/json/eurt/swap.json +29 -29
- package/lib/constants/abis/json/eurtusd/deposit.json +13 -13
- package/lib/constants/abis/json/eurtusd/swap.json +59 -59
- package/lib/constants/abis/json/gauge.json +1 -1
- package/lib/constants/abis/json/gauge_factory.json +879 -0
- package/lib/constants/abis/json/gauge_rewards_only.json +649 -0
- package/lib/constants/abis/json/gauge_synthetix.json +590 -0
- package/lib/constants/abis/json/gauge_v2.json +942 -0
- package/lib/constants/abis/json/gauge_v3.json +954 -0
- package/lib/constants/abis/json/gauge_v4.json +913 -0
- package/lib/constants/abis/json/minter.json +165 -0
- package/lib/constants/abis/json/ren-polygon/swap.json +46 -46
- package/lib/constants/abis/json/reth/swap.json +38 -38
- package/lib/constants/abis/json/tricrypto2/deposit.json +3 -3
- package/lib/constants/abis/json/tricrypto2/swap.json +60 -60
- package/lib/constants/aliases.d.ts +2 -0
- package/lib/constants/aliases.js +2 -0
- package/lib/constants/coins-ethereum.js +7 -3
- package/lib/constants/coins-polygon.js +3 -2
- package/lib/curve.d.ts +1 -0
- package/lib/curve.js +43 -23
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/interfaces.d.ts +7 -1
- package/lib/pools.d.ts +23 -3
- package/lib/pools.js +458 -97
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +5 -3
- package/package.json +1 -1
package/lib/curve.js
CHANGED
|
@@ -65,7 +65,7 @@ var ethcall_1 = require("ethcall");
|
|
|
65
65
|
var ERC20_json_1 = __importDefault(require("./constants/abis/json/ERC20.json"));
|
|
66
66
|
var cERC20_json_1 = __importDefault(require("./constants/abis/json/cERC20.json"));
|
|
67
67
|
var yERC20_json_1 = __importDefault(require("./constants/abis/json/yERC20.json"));
|
|
68
|
-
var
|
|
68
|
+
var minter_json_1 = __importDefault(require("./constants/abis/json/minter.json"));
|
|
69
69
|
var votingescrow_json_1 = __importDefault(require("./constants/abis/json/votingescrow.json"));
|
|
70
70
|
var address_provider_json_1 = __importDefault(require("./constants/abis/json/address_provider.json"));
|
|
71
71
|
var gaugecontroller_json_1 = __importDefault(require("./constants/abis/json/gaugecontroller.json"));
|
|
@@ -79,6 +79,7 @@ var coins_polygon_1 = require("./constants/coins-polygon");
|
|
|
79
79
|
var aliases_1 = require("./constants/aliases");
|
|
80
80
|
exports.ALIASES = {
|
|
81
81
|
"crv": "0xD533a949740bb3306d119CC777fa900bA034cd52",
|
|
82
|
+
"minter": "0xd061D61a4d941c39E5453435B6345Dc261C2fcE0",
|
|
82
83
|
"voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
|
|
83
84
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
84
85
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
@@ -104,9 +105,9 @@ var Curve = /** @class */ (function () {
|
|
|
104
105
|
) {
|
|
105
106
|
if (options === void 0) { options = {}; }
|
|
106
107
|
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
-
var cTokens, yTokens, ycTokens, aTokens, network, _a, customAbiTokens, _b, _i, _c, pool, _d, _e, coinAddr, _f, _g, coinAddr, _h, _j, coinAddr, addressProviderContract,
|
|
108
|
-
return __generator(this, function (
|
|
109
|
-
switch (
|
|
108
|
+
var cTokens, yTokens, ycTokens, aTokens, network, _a, customAbiTokens, _b, _i, _c, pool, _d, _e, coinAddr, _f, _g, coinAddr, _h, _j, coinAddr, _k, _l, rewardTokenAddr, addressProviderContract, _m;
|
|
109
|
+
return __generator(this, function (_o) {
|
|
110
|
+
switch (_o.label) {
|
|
110
111
|
case 0:
|
|
111
112
|
// JsonRpc provider
|
|
112
113
|
if (providerType.toLowerCase() === 'JsonRpc'.toLowerCase()) {
|
|
@@ -146,8 +147,8 @@ var Curve = /** @class */ (function () {
|
|
|
146
147
|
if (_a) return [3 /*break*/, 2];
|
|
147
148
|
return [4 /*yield*/, this.provider._networkPromise];
|
|
148
149
|
case 1:
|
|
149
|
-
_a = (
|
|
150
|
-
|
|
150
|
+
_a = (_o.sent());
|
|
151
|
+
_o.label = 2;
|
|
151
152
|
case 2:
|
|
152
153
|
network = _a;
|
|
153
154
|
console.log("CURVE-JS IS CONNECTED TO NETWORK:", network);
|
|
@@ -203,21 +204,21 @@ var Curve = /** @class */ (function () {
|
|
|
203
204
|
this.multicallProvider = new ethcall_1.Provider();
|
|
204
205
|
return [4 /*yield*/, this.multicallProvider.init(this.provider)];
|
|
205
206
|
case 3:
|
|
206
|
-
|
|
207
|
+
_o.sent();
|
|
207
208
|
if (!this.signer) return [3 /*break*/, 5];
|
|
208
209
|
_b = this;
|
|
209
210
|
return [4 /*yield*/, this.signer.getAddress()];
|
|
210
211
|
case 4:
|
|
211
|
-
_b.signerAddress =
|
|
212
|
+
_b.signerAddress = _o.sent();
|
|
212
213
|
return [3 /*break*/, 6];
|
|
213
214
|
case 5:
|
|
214
215
|
this.signerAddress = '';
|
|
215
|
-
|
|
216
|
+
_o.label = 6;
|
|
216
217
|
case 6:
|
|
217
218
|
this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
|
|
218
219
|
return [4 /*yield*/, this.updateFeeData()];
|
|
219
220
|
case 7:
|
|
220
|
-
|
|
221
|
+
_o.sent();
|
|
221
222
|
// TODO delete toLowerCase()
|
|
222
223
|
for (_i = 0, _c = Object.values(exports.POOLS_DATA); _i < _c.length; _i++) {
|
|
223
224
|
pool = _c[_i];
|
|
@@ -240,12 +241,12 @@ var Curve = /** @class */ (function () {
|
|
|
240
241
|
};
|
|
241
242
|
}
|
|
242
243
|
this.contracts[pool.gauge_address] = {
|
|
243
|
-
contract: new ethers_1.Contract(pool.gauge_address,
|
|
244
|
-
multicallContract: new ethcall_1.Contract(pool.gauge_address,
|
|
244
|
+
contract: new ethers_1.Contract(pool.gauge_address, pool.gauge_abi, this.signer || this.provider),
|
|
245
|
+
multicallContract: new ethcall_1.Contract(pool.gauge_address, pool.gauge_abi),
|
|
245
246
|
};
|
|
246
247
|
this.contracts[pool.gauge_address.toLowerCase()] = {
|
|
247
|
-
contract: new ethers_1.Contract(pool.gauge_address,
|
|
248
|
-
multicallContract: new ethcall_1.Contract(pool.gauge_address,
|
|
248
|
+
contract: new ethers_1.Contract(pool.gauge_address, pool.gauge_abi, this.signer || this.provider),
|
|
249
|
+
multicallContract: new ethcall_1.Contract(pool.gauge_address, pool.gauge_abi),
|
|
249
250
|
};
|
|
250
251
|
if (pool.deposit_address && this.contracts[pool.deposit_address] === undefined) {
|
|
251
252
|
this.contracts[pool.deposit_address] = {
|
|
@@ -315,14 +316,25 @@ var Curve = /** @class */ (function () {
|
|
|
315
316
|
};
|
|
316
317
|
}
|
|
317
318
|
}
|
|
318
|
-
if (pool.
|
|
319
|
-
this.contracts[pool.
|
|
320
|
-
contract: new ethers_1.Contract(pool.
|
|
321
|
-
multicallContract: new ethcall_1.Contract(pool.
|
|
319
|
+
if (pool.reward_contract) {
|
|
320
|
+
this.contracts[pool.reward_contract] = {
|
|
321
|
+
contract: new ethers_1.Contract(pool.reward_contract, streamer_json_1.default, this.signer || this.provider),
|
|
322
|
+
multicallContract: new ethcall_1.Contract(pool.reward_contract, streamer_json_1.default),
|
|
322
323
|
};
|
|
323
|
-
this.contracts[pool.
|
|
324
|
-
contract: new ethers_1.Contract(pool.
|
|
325
|
-
multicallContract: new ethcall_1.Contract(pool.
|
|
324
|
+
this.contracts[pool.reward_contract.toLowerCase()] = {
|
|
325
|
+
contract: new ethers_1.Contract(pool.reward_contract, streamer_json_1.default, this.signer || this.provider),
|
|
326
|
+
multicallContract: new ethcall_1.Contract(pool.reward_contract, streamer_json_1.default),
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
for (_k = 0, _l = pool.reward_tokens || []; _k < _l.length; _k++) {
|
|
330
|
+
rewardTokenAddr = _l[_k];
|
|
331
|
+
this.contracts[rewardTokenAddr] = {
|
|
332
|
+
contract: new ethers_1.Contract(rewardTokenAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
333
|
+
multicallContract: new ethcall_1.Contract(rewardTokenAddr, ERC20_json_1.default),
|
|
334
|
+
};
|
|
335
|
+
this.contracts[rewardTokenAddr.toLowerCase()] = {
|
|
336
|
+
contract: new ethers_1.Contract(rewardTokenAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
337
|
+
multicallContract: new ethcall_1.Contract(rewardTokenAddr, ERC20_json_1.default),
|
|
326
338
|
};
|
|
327
339
|
}
|
|
328
340
|
}
|
|
@@ -334,6 +346,14 @@ var Curve = /** @class */ (function () {
|
|
|
334
346
|
contract: new ethers_1.Contract(exports.ALIASES.crv, ERC20_json_1.default, this.signer || this.provider),
|
|
335
347
|
multicallContract: new ethcall_1.Contract(exports.ALIASES.crv, ERC20_json_1.default),
|
|
336
348
|
};
|
|
349
|
+
this.contracts[exports.ALIASES.minter] = {
|
|
350
|
+
contract: new ethers_1.Contract(exports.ALIASES.minter, minter_json_1.default, this.signer || this.provider),
|
|
351
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.minter, minter_json_1.default),
|
|
352
|
+
};
|
|
353
|
+
this.contracts[exports.ALIASES.minter.toLowerCase()] = {
|
|
354
|
+
contract: new ethers_1.Contract(exports.ALIASES.minter, minter_json_1.default, this.signer || this.provider),
|
|
355
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.minter, minter_json_1.default),
|
|
356
|
+
};
|
|
337
357
|
this.contracts[exports.ALIASES.voting_escrow] = {
|
|
338
358
|
contract: new ethers_1.Contract(exports.ALIASES.voting_escrow, votingescrow_json_1.default, this.signer || this.provider),
|
|
339
359
|
multicallContract: new ethcall_1.Contract(exports.ALIASES.voting_escrow, votingescrow_json_1.default),
|
|
@@ -351,10 +371,10 @@ var Curve = /** @class */ (function () {
|
|
|
351
371
|
multicallContract: new ethcall_1.Contract(exports.ALIASES.address_provider, address_provider_json_1.default),
|
|
352
372
|
};
|
|
353
373
|
addressProviderContract = this.contracts[exports.ALIASES.address_provider].contract;
|
|
354
|
-
|
|
374
|
+
_m = exports.ALIASES;
|
|
355
375
|
return [4 /*yield*/, addressProviderContract.get_address(2, this.constantOptions)];
|
|
356
376
|
case 8:
|
|
357
|
-
|
|
377
|
+
_m.registry_exchange = _o.sent();
|
|
358
378
|
this.contracts[exports.ALIASES.registry_exchange] = {
|
|
359
379
|
contract: new ethers_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default, this.signer || this.provider),
|
|
360
380
|
multicallContract: new ethcall_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default),
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/lib/interfaces.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export interface PoolDataInterface {
|
|
|
24
24
|
underlying_coin_addresses: string[];
|
|
25
25
|
coin_addresses: string[];
|
|
26
26
|
swap_abi: any;
|
|
27
|
+
gauge_abi: any;
|
|
27
28
|
deposit_abi?: any;
|
|
28
29
|
old_swap_abi?: any;
|
|
29
30
|
is_meta?: boolean;
|
|
@@ -49,5 +50,10 @@ export interface PoolDataInterface {
|
|
|
49
50
|
reward_token?: string;
|
|
50
51
|
reward_tokens?: string[];
|
|
51
52
|
pool_type?: string;
|
|
52
|
-
|
|
53
|
+
reward_contract?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface RewardsApyInterface {
|
|
56
|
+
token: string;
|
|
57
|
+
symbol: string;
|
|
58
|
+
apy: string;
|
|
53
59
|
}
|
package/lib/pools.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
|
-
import { DictInterface } from './interfaces';
|
|
3
|
+
import { DictInterface, RewardsApyInterface } from './interfaces';
|
|
4
4
|
export declare class Pool {
|
|
5
5
|
name: string;
|
|
6
6
|
referenceAsset: string;
|
|
@@ -8,7 +8,7 @@ export declare class Pool {
|
|
|
8
8
|
zap: string | null;
|
|
9
9
|
lpToken: string;
|
|
10
10
|
gauge: string;
|
|
11
|
-
|
|
11
|
+
rewardContract: string | null;
|
|
12
12
|
underlyingCoins: string[];
|
|
13
13
|
coins: string[];
|
|
14
14
|
underlyingCoinAddresses: string[];
|
|
@@ -21,6 +21,7 @@ export declare class Pool {
|
|
|
21
21
|
isCrypto: boolean;
|
|
22
22
|
basePool: string;
|
|
23
23
|
isFactory: boolean;
|
|
24
|
+
rewardTokens: string[];
|
|
24
25
|
estimateGas: {
|
|
25
26
|
addLiquidityApprove: (amounts: string[]) => Promise<number>;
|
|
26
27
|
addLiquidity: (amounts: string[]) => Promise<number>;
|
|
@@ -55,8 +56,14 @@ export declare class Pool {
|
|
|
55
56
|
getPoolWrappedBalances: () => Promise<string[]>;
|
|
56
57
|
getTotalLiquidity: () => Promise<string>;
|
|
57
58
|
getVolume: () => Promise<string>;
|
|
58
|
-
getBaseApy: () => Promise<
|
|
59
|
+
getBaseApy: () => Promise<{
|
|
60
|
+
day: string;
|
|
61
|
+
week: string;
|
|
62
|
+
month: string;
|
|
63
|
+
total: string;
|
|
64
|
+
}>;
|
|
59
65
|
getTokenApy: () => Promise<[baseApy: string, boostedApy: string]>;
|
|
66
|
+
getRewardsApy: () => Promise<RewardsApyInterface[]>;
|
|
60
67
|
};
|
|
61
68
|
constructor(name: string);
|
|
62
69
|
calcLpTokenAmount: (amounts: string[], isDeposit?: boolean) => Promise<string>;
|
|
@@ -68,6 +75,7 @@ export declare class Pool {
|
|
|
68
75
|
private getVolume;
|
|
69
76
|
private getBaseApy;
|
|
70
77
|
private getTokenApy;
|
|
78
|
+
private getRewardsApy;
|
|
71
79
|
addLiquidityExpected: (amounts: string[]) => Promise<string>;
|
|
72
80
|
addLiquiditySlippage: (amounts: string[]) => Promise<string>;
|
|
73
81
|
addLiquidityIsApproved: (amounts: string[]) => Promise<boolean>;
|
|
@@ -122,6 +130,14 @@ export declare class Pool {
|
|
|
122
130
|
gaugeDeposit: (lpTokenAmount: string) => Promise<string>;
|
|
123
131
|
private gaugeWithdrawEstimateGas;
|
|
124
132
|
gaugeWithdraw: (lpTokenAmount: string) => Promise<string>;
|
|
133
|
+
gaugeClaimableTokens: (address?: string) => Promise<string>;
|
|
134
|
+
gaugeClaimTokens: () => Promise<string>;
|
|
135
|
+
gaugeClaimableRewards: (address?: string) => Promise<{
|
|
136
|
+
token: string;
|
|
137
|
+
symbol: string;
|
|
138
|
+
amount: string;
|
|
139
|
+
}[]>;
|
|
140
|
+
gaugeClaimRewards: () => Promise<string>;
|
|
125
141
|
balances: (...addresses: string[] | string[][]) => Promise<DictInterface<DictInterface<string>> | DictInterface<string>>;
|
|
126
142
|
lpTokenBalances: (...addresses: string[] | string[][]) => Promise<DictInterface<DictInterface<string>> | DictInterface<string>>;
|
|
127
143
|
underlyingCoinBalances: (...addresses: string[] | string[][]) => Promise<DictInterface<DictInterface<string>> | DictInterface<string>>;
|
|
@@ -145,7 +161,11 @@ export declare class Pool {
|
|
|
145
161
|
private _getCoinIdx;
|
|
146
162
|
private _getRates;
|
|
147
163
|
private _balances;
|
|
164
|
+
private _underlyingPrices;
|
|
165
|
+
private _wrappedPrices;
|
|
166
|
+
private _addLiquidityCryptoSlippage;
|
|
148
167
|
private _addLiquiditySlippage;
|
|
168
|
+
private _removeLiquidityCryptoSlippage;
|
|
149
169
|
private _removeLiquiditySlippage;
|
|
150
170
|
private _balancedAmounts;
|
|
151
171
|
private _calcLpTokenAmount;
|