@curvefi/api 1.9.1 → 1.13.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/abis/abis-ethereum.d.ts +1 -1
- package/lib/constants/abis/abis-ethereum.js +118 -3
- package/lib/constants/abis/abis-polygon.d.ts +4 -0
- package/lib/constants/abis/abis-polygon.js +146 -0
- package/lib/constants/abis/json/atricrypto3/swap.json +1269 -0
- package/lib/constants/abis/json/atricrypto3/zap.json +239 -0
- package/lib/constants/abis/json/crveth/swap.json +1258 -0
- package/lib/constants/abis/json/eurt/swap.json +845 -0
- package/lib/constants/abis/json/eurtusd/deposit.json +257 -0
- package/lib/constants/abis/json/eurtusd/swap.json +1199 -0
- package/lib/constants/abis/json/paave/rewards.json +657 -0
- package/lib/constants/abis/json/ren-polygon/swap.json +1112 -0
- package/lib/constants/aliases.d.ts +16 -0
- package/lib/constants/aliases.js +19 -0
- package/lib/constants/coins-ethereum.d.ts +31 -0
- package/lib/constants/{coins.js → coins-ethereum.js} +51 -15
- package/lib/constants/coins-polygon.d.ts +31 -0
- package/lib/constants/coins-polygon.js +74 -0
- package/lib/curve.d.ts +23 -7
- package/lib/curve.js +122 -91
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -0
- package/lib/interfaces.d.ts +2 -0
- package/lib/pools.d.ts +2 -0
- package/lib/pools.js +264 -114
- package/lib/utils.js +9 -12
- package/package.json +6 -5
- package/lib/constants/coins.d.ts +0 -25
package/lib/utils.js
CHANGED
|
@@ -64,10 +64,7 @@ var axios_1 = __importDefault(require("axios"));
|
|
|
64
64
|
var ethers_1 = require("ethers");
|
|
65
65
|
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
66
66
|
var curve_1 = require("./curve");
|
|
67
|
-
var
|
|
68
|
-
var coins_1 = require("./constants/coins");
|
|
69
|
-
var LP_TOKENS = Object.values(abis_ethereum_1.poolsData).map(function (data) { return data.token_address.toLowerCase(); });
|
|
70
|
-
var GAUGES = Object.values(abis_ethereum_1.poolsData).map(function (data) { return data.gauge_address.toLowerCase(); });
|
|
67
|
+
var curve_2 = require("./curve");
|
|
71
68
|
var ETH_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
72
69
|
exports.MAX_ALLOWANCE = ethers_1.ethers.BigNumber.from(2).pow(ethers_1.ethers.BigNumber.from(256)).sub(ethers_1.ethers.BigNumber.from(1));
|
|
73
70
|
// bignumber.js
|
|
@@ -102,8 +99,8 @@ var _getCoinAddresses = function () {
|
|
|
102
99
|
if (coins.length == 1 && Array.isArray(coins[0]))
|
|
103
100
|
coins = coins[0];
|
|
104
101
|
coins = coins;
|
|
105
|
-
var coinAddresses = coins.map(function (c) { return
|
|
106
|
-
var availableAddresses = __spreadArray(__spreadArray(__spreadArray([], Object.keys(
|
|
102
|
+
var coinAddresses = coins.map(function (c) { return curve_2.COINS[c.toLowerCase()] || c; });
|
|
103
|
+
var availableAddresses = __spreadArray(__spreadArray(__spreadArray([], Object.keys(curve_2.DECIMALS_LOWER_CASE).filter(function (c) { var _a; return c !== ((_a = curve_2.COINS['snx']) === null || _a === void 0 ? void 0 : _a.toLowerCase()); }), true), curve_1.LP_TOKENS, true), curve_1.GAUGES, true);
|
|
107
104
|
for (var _a = 0, coinAddresses_1 = coinAddresses; _a < coinAddresses_1.length; _a++) {
|
|
108
105
|
var coinAddr = coinAddresses_1[_a];
|
|
109
106
|
if (!availableAddresses.includes(coinAddr.toLowerCase()))
|
|
@@ -120,11 +117,11 @@ var _getCoinDecimals = function () {
|
|
|
120
117
|
if (coinAddresses.length == 1 && Array.isArray(coinAddresses[0]))
|
|
121
118
|
coinAddresses = coinAddresses[0];
|
|
122
119
|
coinAddresses = coinAddresses;
|
|
123
|
-
return coinAddresses.map(function (coinAddr) { return
|
|
120
|
+
return coinAddresses.map(function (coinAddr) { return curve_2.DECIMALS_LOWER_CASE[coinAddr.toLowerCase()] || 18; });
|
|
124
121
|
};
|
|
125
122
|
exports._getCoinDecimals = _getCoinDecimals;
|
|
126
123
|
var _getBalances = function (coins, addresses) { return __awaiter(void 0, void 0, void 0, function () {
|
|
127
|
-
var coinAddresses, decimals, ethIndex, contractCalls, _loop_1, _i, coinAddresses_2, coinAddr,
|
|
124
|
+
var coinAddresses, decimals, ethIndex, contractCalls, _loop_1, _i, coinAddresses_2, coinAddr, _response, ethBalances, _a, addresses_1, address, _b, _c, _balances, balances, _d, addresses_2, address;
|
|
128
125
|
return __generator(this, function (_e) {
|
|
129
126
|
switch (_e.label) {
|
|
130
127
|
case 0:
|
|
@@ -144,7 +141,7 @@ var _getBalances = function (coins, addresses) { return __awaiter(void 0, void 0
|
|
|
144
141
|
}
|
|
145
142
|
return [4 /*yield*/, curve_1.curve.multicallProvider.all(contractCalls)];
|
|
146
143
|
case 1:
|
|
147
|
-
|
|
144
|
+
_response = _e.sent();
|
|
148
145
|
if (!(ethIndex !== -1)) return [3 /*break*/, 6];
|
|
149
146
|
ethBalances = [];
|
|
150
147
|
_a = 0, addresses_1 = addresses;
|
|
@@ -161,12 +158,12 @@ var _getBalances = function (coins, addresses) { return __awaiter(void 0, void 0
|
|
|
161
158
|
_a++;
|
|
162
159
|
return [3 /*break*/, 2];
|
|
163
160
|
case 5:
|
|
164
|
-
|
|
161
|
+
_response.splice.apply(_response, __spreadArray([ethIndex * addresses.length, 0], ethBalances, false));
|
|
165
162
|
_e.label = 6;
|
|
166
163
|
case 6:
|
|
167
164
|
_balances = {};
|
|
168
165
|
addresses.forEach(function (address, i) {
|
|
169
|
-
_balances[address] = coins.map(function (_, j) { return
|
|
166
|
+
_balances[address] = coins.map(function (_, j) { return _response[i + (j * addresses.length)]; });
|
|
170
167
|
});
|
|
171
168
|
balances = {};
|
|
172
169
|
for (_d = 0, addresses_2 = addresses; _d < addresses_2.length; _d++) {
|
|
@@ -370,7 +367,7 @@ var ensureAllowance = function (coins, amounts, spender) { return __awaiter(void
|
|
|
370
367
|
}); };
|
|
371
368
|
exports.ensureAllowance = ensureAllowance;
|
|
372
369
|
var getPoolNameBySwapAddress = function (swapAddress) {
|
|
373
|
-
return Object.entries(
|
|
370
|
+
return Object.entries(curve_1.POOLS_DATA).filter(function (_a) {
|
|
374
371
|
var _ = _a[0], poolData = _a[1];
|
|
375
372
|
return poolData.swap_address.toLowerCase() === swapAddress.toLowerCase();
|
|
376
373
|
})[0][0];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@curvefi/api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "JavaScript library for curve.fi",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,18 +12,19 @@
|
|
|
12
12
|
"@types/chai": "^4.2.18",
|
|
13
13
|
"@types/mocha": "^8.2.2",
|
|
14
14
|
"@types/node": "^14.14.37",
|
|
15
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
15
|
+
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
16
16
|
"@typescript-eslint/parser": "^4.20.0",
|
|
17
17
|
"babel-eslint": "^10.1.0",
|
|
18
18
|
"chai": "^4.3.4",
|
|
19
|
-
"eslint": "^7.
|
|
19
|
+
"eslint": "^7.32.0",
|
|
20
20
|
"mocha": "^8.4.0",
|
|
21
|
+
"typescript": "^4.5.2",
|
|
21
22
|
"vue-eslint-parser": "^7.6.0"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
25
|
"axios": "^0.21.1",
|
|
25
26
|
"bignumber.js": "^9.0.1",
|
|
26
|
-
"
|
|
27
|
-
"ethers
|
|
27
|
+
"ethcall": "^4.2.5",
|
|
28
|
+
"ethers": "^5.4.6"
|
|
28
29
|
}
|
|
29
30
|
}
|
package/lib/constants/coins.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export declare const BTC_COINS: {
|
|
2
|
-
[index: string]: string;
|
|
3
|
-
};
|
|
4
|
-
export declare const BTC_COINS_LOWER_CASE: any;
|
|
5
|
-
export declare const ETH_COINS: {
|
|
6
|
-
[index: string]: string;
|
|
7
|
-
};
|
|
8
|
-
export declare const ETH_COINS_LOWER_CASE: any;
|
|
9
|
-
export declare const LINK_COINS: {
|
|
10
|
-
[index: string]: string;
|
|
11
|
-
};
|
|
12
|
-
export declare const LINK_COINS_LOWER_CASE: any;
|
|
13
|
-
export declare const EUR_COINS: {
|
|
14
|
-
[index: string]: string;
|
|
15
|
-
};
|
|
16
|
-
export declare const USD_COINS: {
|
|
17
|
-
[index: string]: string;
|
|
18
|
-
};
|
|
19
|
-
export declare const COINS: {
|
|
20
|
-
[index: string]: string;
|
|
21
|
-
};
|
|
22
|
-
export declare const DECIMALS: {
|
|
23
|
-
[index: string]: number;
|
|
24
|
-
};
|
|
25
|
-
export declare const LOWER_CASE_DECIMALS: any;
|