@curvefi/api 2.11.0 → 2.12.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 +14 -2
- package/lib/constants/coins/kava.d.ts +7 -0
- package/lib/constants/coins/kava.js +16 -0
- package/lib/constants/pools/index.d.ts +2 -1
- package/lib/constants/pools/index.js +3 -1
- package/lib/constants/pools/kava.d.ts +4 -0
- package/lib/constants/pools/kava.js +5 -0
- package/lib/curve.d.ts +14 -0
- package/lib/curve.js +77 -1
- package/lib/external-api.d.ts +2 -2
- package/lib/external-api.js +8 -4
- package/lib/factory/constants.d.ts +6 -8
- package/lib/factory/constants.js +23 -50
- package/lib/factory/factory-api.js +6 -5
- package/lib/factory/factory-crypto.js +13 -12
- package/lib/factory/factory.js +13 -10
- package/lib/interfaces.d.ts +6 -0
- package/lib/pools/PoolTemplate.js +4 -4
- package/lib/router.d.ts +0 -8
- package/lib/router.js +5 -54
- package/lib/utils.js +3 -0
- package/package.json +2 -2
|
@@ -7,3 +7,4 @@ export declare const ALIASES_OPTIMISM: import("../interfaces").IDict<string>;
|
|
|
7
7
|
export declare const ALIASES_XDAI: import("../interfaces").IDict<string>;
|
|
8
8
|
export declare const ALIASES_MOONBEAM: import("../interfaces").IDict<string>;
|
|
9
9
|
export declare const ALIASES_AURORA: import("../interfaces").IDict<string>;
|
|
10
|
+
export declare const ALIASES_KAVA: import("../interfaces").IDict<string>;
|
package/lib/constants/aliases.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ALIASES_AURORA = exports.ALIASES_MOONBEAM = exports.ALIASES_XDAI = exports.ALIASES_OPTIMISM = exports.ALIASES_ARBITRUM = exports.ALIASES_AVALANCHE = exports.ALIASES_FANTOM = exports.ALIASES_POLYGON = exports.ALIASES_ETHEREUM = void 0;
|
|
3
|
+
exports.ALIASES_KAVA = exports.ALIASES_AURORA = exports.ALIASES_MOONBEAM = exports.ALIASES_XDAI = exports.ALIASES_OPTIMISM = exports.ALIASES_ARBITRUM = exports.ALIASES_AVALANCHE = exports.ALIASES_FANTOM = exports.ALIASES_POLYGON = exports.ALIASES_ETHEREUM = void 0;
|
|
4
4
|
var utils_1 = require("./utils");
|
|
5
5
|
exports.ALIASES_ETHEREUM = (0, utils_1.lowerCaseValues)({
|
|
6
6
|
"crv": "0xD533a949740bb3306d119CC777fa900bA034cd52",
|
|
@@ -105,8 +105,20 @@ exports.ALIASES_AURORA = (0, utils_1.lowerCaseValues)({
|
|
|
105
105
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
106
106
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
107
107
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
108
|
-
"deposit_and_stake": "
|
|
108
|
+
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
109
109
|
"factory": '0xb9fc157394af804a3578134a6585c0dc9cc990d4',
|
|
110
110
|
"crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
|
|
111
111
|
"registry_exchange": "",
|
|
112
112
|
});
|
|
113
|
+
exports.ALIASES_KAVA = (0, utils_1.lowerCaseValues)({
|
|
114
|
+
"crv": "0x64D5BaF5ac030e2b7c435aDD967f787ae94D0205",
|
|
115
|
+
"minter": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
116
|
+
"voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
|
|
117
|
+
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
118
|
+
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
119
|
+
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
120
|
+
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
121
|
+
"factory": '0x40bc62805471eF53DdD5C5cF99ed3d9e5aa81b48',
|
|
122
|
+
"crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
|
|
123
|
+
"registry_exchange": "",
|
|
124
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.aTokensKava = exports.ycTokensKava = exports.yTokensKava = exports.cTokensKava = exports.COINS_KAVA = void 0;
|
|
4
|
+
var utils_1 = require("../utils");
|
|
5
|
+
exports.COINS_KAVA = (0, utils_1.lowerCaseValues)({
|
|
6
|
+
'crv': '0x64D5BaF5ac030e2b7c435aDD967f787ae94D0205',
|
|
7
|
+
// --- USD ---
|
|
8
|
+
'dai': '0x765277EebeCA2e31912C9946eAe1021199B39C61',
|
|
9
|
+
'usdc': '0xfA9343C3897324496A05fC75abeD6bAC29f8A40f',
|
|
10
|
+
'usdt': '0xB44a9B6905aF7c801311e8F4E76932ee959c663C',
|
|
11
|
+
'3crv': '0x7A0e3b70b1dB0D6CA63Cac240895b2D21444A7b9',
|
|
12
|
+
});
|
|
13
|
+
exports.cTokensKava = []; //.map((a) => a.toLowerCase());
|
|
14
|
+
exports.yTokensKava = []; //.map((a) => a.toLowerCase());
|
|
15
|
+
exports.ycTokensKava = []; //.map((a) => a.toLowerCase());
|
|
16
|
+
exports.aTokensKava = []; //.map((a) => a.toLowerCase());
|
|
@@ -7,4 +7,5 @@ import { POOLS_DATA_OPTIMISM } from "./optimism";
|
|
|
7
7
|
import { POOLS_DATA_XDAI } from "./xdai";
|
|
8
8
|
import { POOLS_DATA_MOONBEAM } from "./moonbeam";
|
|
9
9
|
import { POOLS_DATA_AURORA } from "./aurora";
|
|
10
|
-
|
|
10
|
+
import { POOLS_DATA_KAVA } from "./kava";
|
|
11
|
+
export { POOLS_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, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.POOLS_DATA_AURORA = exports.POOLS_DATA_MOONBEAM = exports.POOLS_DATA_XDAI = exports.POOLS_DATA_OPTIMISM = exports.POOLS_DATA_ARBITRUM = exports.POOLS_DATA_AVALANCHE = exports.POOLS_DATA_FANTOM = exports.POOLS_DATA_POLYGON = exports.POOLS_DATA_ETHEREUM = void 0;
|
|
3
|
+
exports.POOLS_DATA_KAVA = exports.POOLS_DATA_AURORA = exports.POOLS_DATA_MOONBEAM = exports.POOLS_DATA_XDAI = exports.POOLS_DATA_OPTIMISM = exports.POOLS_DATA_ARBITRUM = exports.POOLS_DATA_AVALANCHE = exports.POOLS_DATA_FANTOM = exports.POOLS_DATA_POLYGON = exports.POOLS_DATA_ETHEREUM = void 0;
|
|
4
4
|
var ethereum_1 = require("./ethereum");
|
|
5
5
|
Object.defineProperty(exports, "POOLS_DATA_ETHEREUM", { enumerable: true, get: function () { return ethereum_1.POOLS_DATA_ETHEREUM; } });
|
|
6
6
|
var polygon_1 = require("./polygon");
|
|
@@ -19,3 +19,5 @@ var moonbeam_1 = require("./moonbeam");
|
|
|
19
19
|
Object.defineProperty(exports, "POOLS_DATA_MOONBEAM", { enumerable: true, get: function () { return moonbeam_1.POOLS_DATA_MOONBEAM; } });
|
|
20
20
|
var aurora_1 = require("./aurora");
|
|
21
21
|
Object.defineProperty(exports, "POOLS_DATA_AURORA", { enumerable: true, get: function () { return aurora_1.POOLS_DATA_AURORA; } });
|
|
22
|
+
var kava_1 = require("./kava");
|
|
23
|
+
Object.defineProperty(exports, "POOLS_DATA_KAVA", { enumerable: true, get: function () { return kava_1.POOLS_DATA_KAVA; } });
|
package/lib/curve.d.ts
CHANGED
|
@@ -2,6 +2,14 @@ import { ethers, Contract } from "ethers";
|
|
|
2
2
|
import { Networkish } from "@ethersproject/networks";
|
|
3
3
|
import { Provider as MulticallProvider, Contract as MulticallContract } from 'ethcall';
|
|
4
4
|
import { IPoolData, IDict, ICurve, INetworkName } from "./interfaces";
|
|
5
|
+
export declare const NATIVE_TOKENS: {
|
|
6
|
+
[index: number]: {
|
|
7
|
+
symbol: string;
|
|
8
|
+
wrappedSymbol: string;
|
|
9
|
+
address: string;
|
|
10
|
+
wrappedAddress: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
5
13
|
export declare const NETWORK_CONSTANTS: {
|
|
6
14
|
[index: number]: any;
|
|
7
15
|
};
|
|
@@ -31,6 +39,12 @@ declare class Curve implements ICurve {
|
|
|
31
39
|
maxPriorityFeePerGas?: number | ethers.BigNumber;
|
|
32
40
|
};
|
|
33
41
|
constants: {
|
|
42
|
+
NATIVE_TOKEN: {
|
|
43
|
+
symbol: string;
|
|
44
|
+
wrappedSymbol: string;
|
|
45
|
+
address: string;
|
|
46
|
+
wrappedAddress: string;
|
|
47
|
+
};
|
|
34
48
|
NETWORK_NAME: INetworkName;
|
|
35
49
|
ALIASES: IDict<string>;
|
|
36
50
|
POOLS_DATA: IDict<IPoolData>;
|
package/lib/curve.js
CHANGED
|
@@ -59,7 +59,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
59
59
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
60
|
};
|
|
61
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
exports.curve = exports.NETWORK_CONSTANTS = void 0;
|
|
62
|
+
exports.curve = exports.NETWORK_CONSTANTS = exports.NATIVE_TOKENS = void 0;
|
|
63
63
|
var ethers_1 = require("ethers");
|
|
64
64
|
var ethcall_1 = require("ethcall");
|
|
65
65
|
var factory_1 = require("./factory/factory");
|
|
@@ -90,7 +90,70 @@ var arbitrum_1 = require("./constants/coins/arbitrum");
|
|
|
90
90
|
var xdai_1 = require("./constants/coins/xdai");
|
|
91
91
|
var moonbeam_1 = require("./constants/coins/moonbeam");
|
|
92
92
|
var aurora_1 = require("./constants/coins/aurora");
|
|
93
|
+
var kava_1 = require("./constants/coins/kava");
|
|
93
94
|
var utils_1 = require("./constants/utils");
|
|
95
|
+
exports.NATIVE_TOKENS = {
|
|
96
|
+
1: {
|
|
97
|
+
symbol: 'ETH',
|
|
98
|
+
wrappedSymbol: 'WETH',
|
|
99
|
+
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
100
|
+
wrappedAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'.toLowerCase(),
|
|
101
|
+
},
|
|
102
|
+
10: {
|
|
103
|
+
symbol: 'ETH',
|
|
104
|
+
wrappedSymbol: 'WETH',
|
|
105
|
+
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
106
|
+
wrappedAddress: '0x4200000000000000000000000000000000000006'.toLowerCase(),
|
|
107
|
+
},
|
|
108
|
+
100: {
|
|
109
|
+
symbol: 'XDAi',
|
|
110
|
+
wrappedSymbol: 'WXDAI',
|
|
111
|
+
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
112
|
+
wrappedAddress: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d'.toLowerCase(),
|
|
113
|
+
},
|
|
114
|
+
137: {
|
|
115
|
+
symbol: 'MATIC',
|
|
116
|
+
wrappedSymbol: 'WMATIC',
|
|
117
|
+
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
118
|
+
wrappedAddress: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270'.toLowerCase(),
|
|
119
|
+
},
|
|
120
|
+
250: {
|
|
121
|
+
symbol: 'FTM',
|
|
122
|
+
wrappedSymbol: 'WFTM',
|
|
123
|
+
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
124
|
+
wrappedAddress: '0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83'.toLowerCase(),
|
|
125
|
+
},
|
|
126
|
+
1284: {
|
|
127
|
+
symbol: 'GLMR',
|
|
128
|
+
wrappedSymbol: 'WGLMR',
|
|
129
|
+
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
130
|
+
wrappedAddress: '0xAcc15dC74880C9944775448304B263D191c6077F'.toLowerCase(),
|
|
131
|
+
},
|
|
132
|
+
2222: {
|
|
133
|
+
symbol: 'KAVA',
|
|
134
|
+
wrappedSymbol: 'WKAVA',
|
|
135
|
+
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
136
|
+
wrappedAddress: '0xc86c7C0eFbd6A49B35E8714C5f59D99De09A225b'.toLowerCase(),
|
|
137
|
+
},
|
|
138
|
+
43114: {
|
|
139
|
+
symbol: 'AVAX',
|
|
140
|
+
wrappedSymbol: 'WAVAX',
|
|
141
|
+
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
142
|
+
wrappedAddress: '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7'.toLowerCase(),
|
|
143
|
+
},
|
|
144
|
+
42161: {
|
|
145
|
+
symbol: 'ETH',
|
|
146
|
+
wrappedSymbol: 'WETH',
|
|
147
|
+
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
148
|
+
wrappedAddress: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1'.toLowerCase(),
|
|
149
|
+
},
|
|
150
|
+
1313161554: {
|
|
151
|
+
symbol: 'ETH',
|
|
152
|
+
wrappedSymbol: 'WETH',
|
|
153
|
+
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
154
|
+
wrappedAddress: '0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB'.toLowerCase(),
|
|
155
|
+
},
|
|
156
|
+
};
|
|
94
157
|
exports.NETWORK_CONSTANTS = {
|
|
95
158
|
1: {
|
|
96
159
|
NAME: 'ethereum',
|
|
@@ -152,6 +215,16 @@ exports.NETWORK_CONSTANTS = {
|
|
|
152
215
|
ycTokens: moonbeam_1.ycTokensMoonbeam,
|
|
153
216
|
aTokens: moonbeam_1.aTokensMoonbeam,
|
|
154
217
|
},
|
|
218
|
+
2222: {
|
|
219
|
+
NAME: 'kava',
|
|
220
|
+
ALIASES: aliases_1.ALIASES_KAVA,
|
|
221
|
+
POOLS_DATA: pools_1.POOLS_DATA_KAVA,
|
|
222
|
+
COINS: kava_1.COINS_KAVA,
|
|
223
|
+
cTokens: kava_1.cTokensKava,
|
|
224
|
+
yTokens: kava_1.yTokensKava,
|
|
225
|
+
ycTokens: kava_1.ycTokensKava,
|
|
226
|
+
aTokens: kava_1.aTokensKava,
|
|
227
|
+
},
|
|
155
228
|
43114: {
|
|
156
229
|
NAME: 'avalanche',
|
|
157
230
|
ALIASES: aliases_1.ALIASES_AVALANCHE,
|
|
@@ -198,6 +271,7 @@ var Curve = /** @class */ (function () {
|
|
|
198
271
|
this.constantOptions = { gasLimit: 12000000 };
|
|
199
272
|
this.options = {};
|
|
200
273
|
this.constants = {
|
|
274
|
+
NATIVE_TOKEN: exports.NATIVE_TOKENS[1],
|
|
201
275
|
NETWORK_NAME: 'ethereum',
|
|
202
276
|
ALIASES: {},
|
|
203
277
|
POOLS_DATA: {},
|
|
@@ -230,6 +304,7 @@ var Curve = /** @class */ (function () {
|
|
|
230
304
|
this.constantOptions = { gasLimit: 12000000 };
|
|
231
305
|
this.options = {};
|
|
232
306
|
this.constants = {
|
|
307
|
+
NATIVE_TOKEN: exports.NATIVE_TOKENS[1],
|
|
233
308
|
NETWORK_NAME: 'ethereum',
|
|
234
309
|
ALIASES: {},
|
|
235
310
|
POOLS_DATA: {},
|
|
@@ -286,6 +361,7 @@ var Curve = /** @class */ (function () {
|
|
|
286
361
|
network = _b;
|
|
287
362
|
console.log("CURVE-JS IS CONNECTED TO NETWORK:", network);
|
|
288
363
|
this.chainId = network.chainId === 1337 ? 1 : network.chainId;
|
|
364
|
+
this.constants.NATIVE_TOKEN = exports.NATIVE_TOKENS[this.chainId];
|
|
289
365
|
this.constants.NETWORK_NAME = exports.NETWORK_CONSTANTS[this.chainId].NAME;
|
|
290
366
|
this.constants.ALIASES = exports.NETWORK_CONSTANTS[this.chainId].ALIASES;
|
|
291
367
|
this.constants.POOLS_DATA = exports.NETWORK_CONSTANTS[this.chainId].POOLS_DATA;
|
package/lib/external-api.d.ts
CHANGED
|
@@ -16,11 +16,11 @@ export declare const _getLegacyAPYsAndVolumes: ((network: string) => Promise<IDi
|
|
|
16
16
|
};
|
|
17
17
|
volume: number;
|
|
18
18
|
}>>>;
|
|
19
|
-
export declare const
|
|
19
|
+
export declare const _getFactoryAPYsAndVolumes: ((network: string) => Promise<{
|
|
20
20
|
poolAddress: string;
|
|
21
21
|
apy: number;
|
|
22
22
|
volume: number;
|
|
23
|
-
}[]>) & memoize.Memoized<() => Promise<{
|
|
23
|
+
}[]>) & memoize.Memoized<(network: string) => Promise<{
|
|
24
24
|
poolAddress: string;
|
|
25
25
|
apy: number;
|
|
26
26
|
volume: number;
|
package/lib/external-api.js
CHANGED
|
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.
|
|
42
|
+
exports._getFactoryAPYsAndVolumes = exports._getLegacyAPYsAndVolumes = exports._getMainPoolsGaugeRewards = exports._getSubgraphData = exports._getPoolsFromApi = void 0;
|
|
43
43
|
var axios_1 = __importDefault(require("axios"));
|
|
44
44
|
var memoizee_1 = __importDefault(require("memoizee"));
|
|
45
45
|
var curve_1 = require("./curve");
|
|
@@ -93,11 +93,14 @@ exports._getMainPoolsGaugeRewards = (0, memoizee_1.default)(function () { return
|
|
|
93
93
|
promise: true,
|
|
94
94
|
maxAge: 5 * 60 * 1000, // 5m
|
|
95
95
|
});
|
|
96
|
+
// Moonbeam and Aurora only
|
|
96
97
|
exports._getLegacyAPYsAndVolumes = (0, memoizee_1.default)(function (network) { return __awaiter(void 0, void 0, void 0, function () {
|
|
97
98
|
var url, data, result;
|
|
98
99
|
return __generator(this, function (_a) {
|
|
99
100
|
switch (_a.label) {
|
|
100
101
|
case 0:
|
|
102
|
+
if (curve_1.curve.chainId === 2222)
|
|
103
|
+
return [2 /*return*/, {}]; // Exclude Kava
|
|
101
104
|
url = "https://stats.curve.fi/raw-stats-".concat(network, "/apys.json");
|
|
102
105
|
return [4 /*yield*/, axios_1.default.get(url, { validateStatus: function () { return true; } })];
|
|
103
106
|
case 1:
|
|
@@ -116,15 +119,16 @@ exports._getLegacyAPYsAndVolumes = (0, memoizee_1.default)(function (network) {
|
|
|
116
119
|
promise: true,
|
|
117
120
|
maxAge: 5 * 60 * 1000, // 5m
|
|
118
121
|
});
|
|
119
|
-
|
|
122
|
+
// Moonbeam and Kava only
|
|
123
|
+
exports._getFactoryAPYsAndVolumes = (0, memoizee_1.default)(function (network) { return __awaiter(void 0, void 0, void 0, function () {
|
|
120
124
|
var url, response;
|
|
121
125
|
var _a;
|
|
122
126
|
return __generator(this, function (_b) {
|
|
123
127
|
switch (_b.label) {
|
|
124
128
|
case 0:
|
|
125
|
-
if (curve_1.curve.chainId !== 1284)
|
|
129
|
+
if (curve_1.curve.chainId !== 1284 && curve_1.curve.chainId !== 2222)
|
|
126
130
|
return [2 /*return*/, []];
|
|
127
|
-
url = "https://api.curve.fi/api/getFactoryAPYs-
|
|
131
|
+
url = "https://api.curve.fi/api/getFactoryAPYs-".concat(network);
|
|
128
132
|
return [4 /*yield*/, axios_1.default.get(url, { validateStatus: function () { return true; } })];
|
|
129
133
|
case 1:
|
|
130
134
|
response = _b.sent();
|
|
@@ -7,6 +7,7 @@ export declare const implementationABIDictArbitrum: IDict<any>;
|
|
|
7
7
|
export declare const implementationABIDictOptimism: IDict<any>;
|
|
8
8
|
export declare const implementationABIDictXDai: IDict<any>;
|
|
9
9
|
export declare const implementationABIDictMoonbeam: IDict<any>;
|
|
10
|
+
export declare const implementationABIDictKava: IDict<any>;
|
|
10
11
|
export declare const implementationBasePoolIdDictEthereum: IDict<string>;
|
|
11
12
|
export declare const implementationBasePoolIdDictPolygon: IDict<string>;
|
|
12
13
|
export declare const implementationBasePoolIdDictFantom: IDict<string>;
|
|
@@ -15,6 +16,7 @@ export declare const implementationBasePoolIdDictArbitrum: IDict<string>;
|
|
|
15
16
|
export declare const implementationBasePoolIdDictOptimism: IDict<string>;
|
|
16
17
|
export declare const implementationBasePoolIdDictXDai: IDict<string>;
|
|
17
18
|
export declare const implementationBasePoolIdDictMoonbeam: IDict<string>;
|
|
19
|
+
export declare const implementationBasePoolIdDictKava: IDict<string>;
|
|
18
20
|
export declare const basePoolIdZapDictEthereum: IDict<{
|
|
19
21
|
address: string;
|
|
20
22
|
ABI: any;
|
|
@@ -47,14 +49,10 @@ export declare const basePoolIdZapDictMoonbeam: IDict<{
|
|
|
47
49
|
address: string;
|
|
48
50
|
ABI: any;
|
|
49
51
|
}>;
|
|
50
|
-
export declare const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
wrappedSymbol: string;
|
|
55
|
-
wrappedAddress: string;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
52
|
+
export declare const basePoolIdZapDictKava: IDict<{
|
|
53
|
+
address: string;
|
|
54
|
+
ABI: any;
|
|
55
|
+
}>;
|
|
58
56
|
export declare const FACTORY_CONSTANTS: {
|
|
59
57
|
[index: number]: {
|
|
60
58
|
implementationABIDict: IDict<any>;
|
package/lib/factory/constants.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.FACTORY_CONSTANTS = exports.
|
|
6
|
+
exports.FACTORY_CONSTANTS = exports.basePoolIdZapDictKava = exports.basePoolIdZapDictMoonbeam = exports.basePoolIdZapDictXDai = exports.basePoolIdZapDictOptimism = exports.basePoolIdZapDictArbitrum = exports.basePoolIdZapDictAvalanche = exports.basePoolIdZapDictFantom = exports.basePoolIdZapDictPolygon = exports.basePoolIdZapDictEthereum = exports.implementationBasePoolIdDictKava = exports.implementationBasePoolIdDictMoonbeam = exports.implementationBasePoolIdDictXDai = exports.implementationBasePoolIdDictOptimism = exports.implementationBasePoolIdDictArbitrum = exports.implementationBasePoolIdDictAvalanche = exports.implementationBasePoolIdDictFantom = exports.implementationBasePoolIdDictPolygon = exports.implementationBasePoolIdDictEthereum = exports.implementationABIDictKava = exports.implementationABIDictMoonbeam = exports.implementationABIDictXDai = exports.implementationABIDictOptimism = exports.implementationABIDictArbitrum = exports.implementationABIDictAvalanche = exports.implementationABIDictFantom = exports.implementationABIDictPolygon = exports.implementationABIDictEthereum = void 0;
|
|
7
7
|
var swap_json_1 = __importDefault(require("../constants/abis/factoryPools/swap.json"));
|
|
8
8
|
var MetaUSD_json_1 = __importDefault(require("../constants/abis/factory-v2/MetaUSD.json"));
|
|
9
9
|
var MetaUSDBalances_json_1 = __importDefault(require("../constants/abis/factory-v2/MetaUSDBalances.json"));
|
|
@@ -180,6 +180,21 @@ exports.implementationABIDictMoonbeam = {
|
|
|
180
180
|
"0xec9cEBE650E181079576C1b6d0d2e092B1EdfF13": Plain4ETH_json_1.default,
|
|
181
181
|
"0xe8269B33E47761f552E1a3070119560d5fa8bBD6": Plain4Optimized_json_1.default,
|
|
182
182
|
};
|
|
183
|
+
exports.implementationABIDictKava = {
|
|
184
|
+
"0x2632679f5ca396a1bd2647092d9dbf7ec5d7b263": Plain2Basic_json_1.default,
|
|
185
|
+
"0x12f196251efcaca0fd73d5b58132b16760ba96a8": Plain2Balances_json_1.default,
|
|
186
|
+
"0xafdab4f8f6e6992b16e3906295fba390aab59ca5": Plain2ETH_json_1.default,
|
|
187
|
+
"0x50d7a3e0d5350d52e9e08a1b58eefd1db8759d7d": Plain2Optimized_json_1.default,
|
|
188
|
+
"0xc8913d486a42459e6b34db33f0c660fca61306b9": Plain3Basic_json_1.default,
|
|
189
|
+
"0xc8913D486a42459e6B34db33F0C660FCa61306b9": Plain3Basic_json_1.default,
|
|
190
|
+
"0xc5ec776a55ea062fa3173c6c76703e9c9fa91c47": Plain3Balances_json_1.default,
|
|
191
|
+
"0xed2c5f2c4cab6e82630d5615ea15dd47d8b29983": Plain3ETH_json_1.default,
|
|
192
|
+
"0xe7d5293c01685a414ddde527eb5effbf92b52648": Plain3Optimized_json_1.default,
|
|
193
|
+
"0x77016d2de65de15a3c36bebbddc90804f670d2d0": Plain4Basic_json_1.default,
|
|
194
|
+
"0xd59c875dccb6cdcb3a75b91b58a363b5e4b0ca9a": Plain4Balances_json_1.default,
|
|
195
|
+
"0x6378dd741b24bd884f3590d7bc7555fdb2f5b003": Plain4ETH_json_1.default,
|
|
196
|
+
"0x509495dfeec3a53acb2f60669985d868131ad9a5": Plain4Optimized_json_1.default,
|
|
197
|
+
};
|
|
183
198
|
exports.implementationBasePoolIdDictEthereum = {
|
|
184
199
|
"0x5F890841f657d90E081bAbdB532A05996Af79Fe6": "3pool",
|
|
185
200
|
"0x213be373FDff327658139C7df330817DAD2d5bBE": "3pool",
|
|
@@ -230,6 +245,7 @@ exports.implementationBasePoolIdDictXDai = {
|
|
|
230
245
|
"0x0B4dc7A945695D11FD83e40B2DfC2B896A02395F": "3pool",
|
|
231
246
|
};
|
|
232
247
|
exports.implementationBasePoolIdDictMoonbeam = {};
|
|
248
|
+
exports.implementationBasePoolIdDictKava = {};
|
|
233
249
|
exports.basePoolIdZapDictEthereum = {
|
|
234
250
|
'3pool': {
|
|
235
251
|
address: "0xA79828DF1850E8a3A3064576f380D90aECDD3359".toLowerCase(),
|
|
@@ -313,55 +329,7 @@ exports.basePoolIdZapDictXDai = {
|
|
|
313
329
|
},
|
|
314
330
|
};
|
|
315
331
|
exports.basePoolIdZapDictMoonbeam = {};
|
|
316
|
-
|
|
317
|
-
exports.NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
318
|
-
exports.NATIVE_TOKENS = {
|
|
319
|
-
1: {
|
|
320
|
-
symbol: 'ETH',
|
|
321
|
-
wrappedSymbol: 'WETH',
|
|
322
|
-
wrappedAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'.toLowerCase(),
|
|
323
|
-
},
|
|
324
|
-
10: {
|
|
325
|
-
symbol: 'ETH',
|
|
326
|
-
wrappedSymbol: 'WETH',
|
|
327
|
-
wrappedAddress: '0x4200000000000000000000000000000000000006'.toLowerCase(),
|
|
328
|
-
},
|
|
329
|
-
100: {
|
|
330
|
-
symbol: 'XDAi',
|
|
331
|
-
wrappedSymbol: 'WXDAI',
|
|
332
|
-
wrappedAddress: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d'.toLowerCase(),
|
|
333
|
-
},
|
|
334
|
-
137: {
|
|
335
|
-
symbol: 'MATIC',
|
|
336
|
-
wrappedSymbol: 'WMATIC',
|
|
337
|
-
wrappedAddress: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270'.toLowerCase(),
|
|
338
|
-
},
|
|
339
|
-
250: {
|
|
340
|
-
symbol: 'FTM',
|
|
341
|
-
wrappedSymbol: 'WFTM',
|
|
342
|
-
wrappedAddress: '0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83'.toLowerCase(),
|
|
343
|
-
},
|
|
344
|
-
1284: {
|
|
345
|
-
symbol: 'GLMR',
|
|
346
|
-
wrappedSymbol: 'WGLMR',
|
|
347
|
-
wrappedAddress: '0xAcc15dC74880C9944775448304B263D191c6077F'.toLowerCase(),
|
|
348
|
-
},
|
|
349
|
-
43114: {
|
|
350
|
-
symbol: 'AVAX',
|
|
351
|
-
wrappedSymbol: 'WAVAX',
|
|
352
|
-
wrappedAddress: '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7'.toLowerCase(),
|
|
353
|
-
},
|
|
354
|
-
42161: {
|
|
355
|
-
symbol: 'ETH',
|
|
356
|
-
wrappedSymbol: 'WETH',
|
|
357
|
-
wrappedAddress: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1'.toLowerCase(),
|
|
358
|
-
},
|
|
359
|
-
1313161554: {
|
|
360
|
-
symbol: 'ETH',
|
|
361
|
-
wrappedSymbol: 'WETH',
|
|
362
|
-
wrappedAddress: '0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB'.toLowerCase(),
|
|
363
|
-
},
|
|
364
|
-
};
|
|
332
|
+
exports.basePoolIdZapDictKava = {};
|
|
365
333
|
exports.FACTORY_CONSTANTS = {
|
|
366
334
|
1: {
|
|
367
335
|
implementationABIDict: exports.implementationABIDictEthereum,
|
|
@@ -393,6 +361,11 @@ exports.FACTORY_CONSTANTS = {
|
|
|
393
361
|
implementationBasePoolIdDict: exports.implementationBasePoolIdDictMoonbeam,
|
|
394
362
|
basePoolIdZapDict: exports.basePoolIdZapDictMoonbeam,
|
|
395
363
|
},
|
|
364
|
+
2222: {
|
|
365
|
+
implementationABIDict: exports.implementationABIDictKava,
|
|
366
|
+
implementationBasePoolIdDict: exports.implementationBasePoolIdDictKava,
|
|
367
|
+
basePoolIdZapDict: exports.basePoolIdZapDictKava,
|
|
368
|
+
},
|
|
396
369
|
43114: {
|
|
397
370
|
implementationABIDict: exports.implementationABIDictAvalanche,
|
|
398
371
|
implementationBasePoolIdDict: exports.implementationBasePoolIdDictAvalanche,
|
|
@@ -65,6 +65,7 @@ var ethers_1 = require("ethers");
|
|
|
65
65
|
var ethcall_1 = require("ethcall");
|
|
66
66
|
var gauge_factory_json_1 = __importDefault(require("../constants/abis/gauge_factory.json"));
|
|
67
67
|
var gauge_child_json_1 = __importDefault(require("../constants/abis/gauge_child.json"));
|
|
68
|
+
var gauge_rewards_only_json_1 = __importDefault(require("../constants/abis/gauge_rewards_only.json"));
|
|
68
69
|
var deposit_json_1 = __importDefault(require("../constants/abis/factoryPools/deposit.json"));
|
|
69
70
|
var ERC20_json_1 = __importDefault(require("../constants/abis/ERC20.json"));
|
|
70
71
|
var factory_crypto_pool_2_json_1 = __importDefault(require("../constants/abis/factory-crypto/factory-crypto-pool-2.json"));
|
|
@@ -109,8 +110,8 @@ function setFactoryGaugeContracts(rawPoolList) {
|
|
|
109
110
|
if (pool.gaugeAddress) {
|
|
110
111
|
var addr = pool.gaugeAddress.toLowerCase();
|
|
111
112
|
_this.contracts[addr] = {
|
|
112
|
-
contract: new ethers_1.Contract(addr, _this.chainId === 1 ? gauge_factory_json_1.default : gauge_child_json_1.default, _this.signer || _this.provider),
|
|
113
|
-
multicallContract: new ethcall_1.Contract(addr, _this.chainId === 1 ? gauge_factory_json_1.default : gauge_child_json_1.default),
|
|
113
|
+
contract: new ethers_1.Contract(addr, _this.chainId === 1 ? gauge_factory_json_1.default : _this.chainId === 2222 ? gauge_rewards_only_json_1.default : gauge_child_json_1.default, _this.signer || _this.provider),
|
|
114
|
+
multicallContract: new ethcall_1.Contract(addr, _this.chainId === 1 ? gauge_factory_json_1.default : _this.chainId === 2222 ? gauge_rewards_only_json_1.default : gauge_child_json_1.default),
|
|
114
115
|
};
|
|
115
116
|
}
|
|
116
117
|
});
|
|
@@ -193,11 +194,11 @@ function getFactoryPoolsDataFromApi(isCrypto) {
|
|
|
193
194
|
var coinAddresses = pool.coins.map(function (c) { return c.address.toLowerCase(); });
|
|
194
195
|
var coinNames = pool.coins.map(function (c) { return c.symbol; });
|
|
195
196
|
var coinDecimals = pool.coins.map(function (c) { return Number(c.decimals); });
|
|
196
|
-
var nativeToken =
|
|
197
|
+
var nativeToken = _this.constants.NATIVE_TOKEN;
|
|
197
198
|
if (isCrypto) {
|
|
198
199
|
var cryptoCoinNames = pool.coins.map(function (c) { return c.symbol === nativeToken.symbol ? nativeToken.wrappedSymbol : c.symbol; });
|
|
199
200
|
var underlyingCoinNames = pool.coins.map(function (c) { return c.symbol === nativeToken.wrappedSymbol ? nativeToken.symbol : c.symbol; });
|
|
200
|
-
var underlyingCoinAddresses = coinAddresses.map(function (addr) { return addr === nativeToken.wrappedAddress ?
|
|
201
|
+
var underlyingCoinAddresses = coinAddresses.map(function (addr) { return addr === nativeToken.wrappedAddress ? nativeToken.address : addr; });
|
|
201
202
|
var isPlain = !coinAddresses.includes(nativeToken.wrappedAddress);
|
|
202
203
|
var isMeta = _this.chainId === 137 && coinAddresses[1].toLowerCase() === atricrypto3Lp;
|
|
203
204
|
if (isMeta) {
|
|
@@ -318,7 +319,7 @@ function getFactoryPoolsDataFromApi(isCrypto) {
|
|
|
318
319
|
underlying_decimals: coinDecimals,
|
|
319
320
|
wrapped_decimals: coinDecimals,
|
|
320
321
|
swap_abi: implementationABIDict[pool.implementationAddress],
|
|
321
|
-
gauge_abi: _this.chainId === 1 ? gauge_factory_json_1.default : gauge_child_json_1.default,
|
|
322
|
+
gauge_abi: _this.chainId === 1 ? gauge_factory_json_1.default : _this.chainId === 2222 ? gauge_rewards_only_json_1.default : gauge_child_json_1.default, // TODO remove RewardsOnly for Kava
|
|
322
323
|
};
|
|
323
324
|
}
|
|
324
325
|
});
|
|
@@ -56,7 +56,6 @@ var factory_crypto_pool_2_json_1 = __importDefault(require("../constants/abis/fa
|
|
|
56
56
|
var gauge_factory_json_1 = __importDefault(require("../constants/abis/gauge_factory.json"));
|
|
57
57
|
var gauge_child_json_1 = __importDefault(require("../constants/abis/gauge_child.json"));
|
|
58
58
|
var base_pool_zap_json_1 = __importDefault(require("../constants/abis/atricrypto3/base_pool_zap.json"));
|
|
59
|
-
var constants_1 = require("./constants");
|
|
60
59
|
var common_1 = require("./common");
|
|
61
60
|
var deepFlatten = function (arr) { return [].concat.apply([], arr.map(function (v) { return (Array.isArray(v) ? deepFlatten(v) : v); })); };
|
|
62
61
|
function getCryptoFactoryIdsAndSwapAddresses() {
|
|
@@ -211,7 +210,7 @@ function getCryptoFactoryUnderlyingCoinAddresses(coinAddresses) {
|
|
|
211
210
|
return __awaiter(this, void 0, void 0, function () {
|
|
212
211
|
var _this = this;
|
|
213
212
|
return __generator(this, function (_a) {
|
|
214
|
-
return [2 /*return*/, coinAddresses.map(function (coins) { return coins.map(function (c) { return c ===
|
|
213
|
+
return [2 /*return*/, coinAddresses.map(function (coins) { return coins.map(function (c) { return c === _this.constants.NATIVE_TOKEN.wrappedAddress ? _this.constants.NATIVE_TOKEN.address : c; }); })];
|
|
215
214
|
});
|
|
216
215
|
});
|
|
217
216
|
}
|
|
@@ -234,21 +233,23 @@ function getExistingCoinAddressNameDict() {
|
|
|
234
233
|
_loop_1(poolData);
|
|
235
234
|
}
|
|
236
235
|
if (this.chainId === 1)
|
|
237
|
-
dict[
|
|
236
|
+
dict[this.constants.NATIVE_TOKEN.address] = "ETH";
|
|
238
237
|
if (this.chainId === 10)
|
|
239
|
-
dict[
|
|
238
|
+
dict[this.constants.NATIVE_TOKEN.address] = "ETH";
|
|
240
239
|
if (this.chainId === 100)
|
|
241
|
-
dict[
|
|
240
|
+
dict[this.constants.NATIVE_TOKEN.address] = "XDAI";
|
|
242
241
|
if (this.chainId === 137)
|
|
243
|
-
dict[
|
|
242
|
+
dict[this.constants.NATIVE_TOKEN.address] = "MATIC";
|
|
244
243
|
if (this.chainId === 250)
|
|
245
|
-
dict[
|
|
244
|
+
dict[this.constants.NATIVE_TOKEN.address] = "FTM";
|
|
246
245
|
if (this.chainId === 1284)
|
|
247
|
-
dict[
|
|
246
|
+
dict[this.constants.NATIVE_TOKEN.address] = "GLMR";
|
|
247
|
+
if (this.chainId === 2222)
|
|
248
|
+
dict[this.constants.NATIVE_TOKEN.address] = "KAVA";
|
|
248
249
|
if (this.chainId === 43114)
|
|
249
|
-
dict[
|
|
250
|
+
dict[this.constants.NATIVE_TOKEN.address] = "AVAX";
|
|
250
251
|
if (this.chainId === 42161)
|
|
251
|
-
dict[
|
|
252
|
+
dict[this.constants.NATIVE_TOKEN.address] = "ETH";
|
|
252
253
|
return dict;
|
|
253
254
|
}
|
|
254
255
|
function getCoinAddressNameDict(coinAddresses, existingCoinAddrNameDict) {
|
|
@@ -282,7 +283,7 @@ function getCoinAddressNameDict(coinAddresses, existingCoinAddrNameDict) {
|
|
|
282
283
|
newCoinAddresses.forEach(function (addr, i) {
|
|
283
284
|
coinAddrNamesDict[addr] = names[i];
|
|
284
285
|
});
|
|
285
|
-
coinAddrNamesDict[
|
|
286
|
+
coinAddrNamesDict[this.constants.NATIVE_TOKEN.address] = this.constants.NATIVE_TOKEN.symbol;
|
|
286
287
|
return [2 /*return*/, coinAddrNamesDict];
|
|
287
288
|
}
|
|
288
289
|
});
|
|
@@ -316,7 +317,7 @@ function getCoinAddressDecimalsDict(coinAddresses, existingCoinAddressDecimalsDi
|
|
|
316
317
|
newCoinAddresses.forEach(function (addr, i) {
|
|
317
318
|
coinAddressDecimalsDict[addr] = decimals[i];
|
|
318
319
|
});
|
|
319
|
-
coinAddressDecimalsDict[
|
|
320
|
+
coinAddressDecimalsDict[this.constants.NATIVE_TOKEN.address] = 18;
|
|
320
321
|
return [2 /*return*/, coinAddressDecimalsDict];
|
|
321
322
|
}
|
|
322
323
|
});
|
package/lib/factory/factory.js
CHANGED
|
@@ -79,6 +79,7 @@ var BLACK_LIST = {
|
|
|
79
79
|
],
|
|
80
80
|
250: [],
|
|
81
81
|
1284: [],
|
|
82
|
+
2222: [],
|
|
82
83
|
43114: [],
|
|
83
84
|
42161: [],
|
|
84
85
|
};
|
|
@@ -269,21 +270,23 @@ function getExistingCoinAddressNameDict() {
|
|
|
269
270
|
_loop_1(poolData);
|
|
270
271
|
}
|
|
271
272
|
if (this.chainId === 1)
|
|
272
|
-
dict[
|
|
273
|
+
dict[this.constants.NATIVE_TOKEN.address] = "ETH";
|
|
273
274
|
if (this.chainId === 10)
|
|
274
|
-
dict[
|
|
275
|
+
dict[this.constants.NATIVE_TOKEN.address] = "ETH";
|
|
275
276
|
if (this.chainId === 100)
|
|
276
|
-
dict[
|
|
277
|
+
dict[this.constants.NATIVE_TOKEN.address] = "XDAI";
|
|
277
278
|
if (this.chainId === 137)
|
|
278
|
-
dict[
|
|
279
|
+
dict[this.constants.NATIVE_TOKEN.address] = "MATIC";
|
|
279
280
|
if (this.chainId === 250)
|
|
280
|
-
dict[
|
|
281
|
+
dict[this.constants.NATIVE_TOKEN.address] = "FTM";
|
|
281
282
|
if (this.chainId === 1284)
|
|
282
|
-
dict[
|
|
283
|
+
dict[this.constants.NATIVE_TOKEN.address] = "GLMR";
|
|
284
|
+
if (this.chainId === 2222)
|
|
285
|
+
dict[this.constants.NATIVE_TOKEN.address] = "KAVA";
|
|
283
286
|
if (this.chainId === 43114)
|
|
284
|
-
dict[
|
|
287
|
+
dict[this.constants.NATIVE_TOKEN.address] = "AVAX";
|
|
285
288
|
if (this.chainId === 42161)
|
|
286
|
-
dict[
|
|
289
|
+
dict[this.constants.NATIVE_TOKEN.address] = "ETH";
|
|
287
290
|
return dict;
|
|
288
291
|
}
|
|
289
292
|
function getCoinAddressNameDict(coinAddresses, existingCoinAddrNameDict) {
|
|
@@ -326,7 +329,7 @@ function getCoinAddressDecimalsDict(coinAddresses, existingCoinAddressDecimalsDi
|
|
|
326
329
|
return __generator(this, function (_a) {
|
|
327
330
|
switch (_a.label) {
|
|
328
331
|
case 0:
|
|
329
|
-
flattenedCoinAddresses = Array.from(new Set(deepFlatten(coinAddresses))).filter(function (addr) { return addr !==
|
|
332
|
+
flattenedCoinAddresses = Array.from(new Set(deepFlatten(coinAddresses))).filter(function (addr) { return addr !== _this.constants.NATIVE_TOKEN.address; });
|
|
330
333
|
newCoinAddresses = [];
|
|
331
334
|
coinAddrNamesDict = {};
|
|
332
335
|
for (_i = 0, flattenedCoinAddresses_3 = flattenedCoinAddresses; _i < flattenedCoinAddresses_3.length; _i++) {
|
|
@@ -347,7 +350,7 @@ function getCoinAddressDecimalsDict(coinAddresses, existingCoinAddressDecimalsDi
|
|
|
347
350
|
newCoinAddresses.forEach(function (addr, i) {
|
|
348
351
|
coinAddrNamesDict[addr] = decimals[i];
|
|
349
352
|
});
|
|
350
|
-
coinAddrNamesDict[
|
|
353
|
+
coinAddrNamesDict[this.constants.NATIVE_TOKEN.address] = 18;
|
|
351
354
|
return [2 /*return*/, coinAddrNamesDict];
|
|
352
355
|
}
|
|
353
356
|
});
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -61,6 +61,12 @@ export interface ICurve {
|
|
|
61
61
|
maxPriorityFeePerGas?: number | ethers.BigNumber;
|
|
62
62
|
};
|
|
63
63
|
constants: {
|
|
64
|
+
NATIVE_TOKEN: {
|
|
65
|
+
symbol: string;
|
|
66
|
+
wrappedSymbol: string;
|
|
67
|
+
address: string;
|
|
68
|
+
wrappedAddress: string;
|
|
69
|
+
};
|
|
64
70
|
NETWORK_NAME: INetworkName;
|
|
65
71
|
ALIASES: IDict<string>;
|
|
66
72
|
POOLS_DATA: IDict<IPoolData>;
|
|
@@ -168,10 +168,10 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
168
168
|
return __generator(this, function (_e) {
|
|
169
169
|
switch (_e.label) {
|
|
170
170
|
case 0:
|
|
171
|
-
if (!
|
|
171
|
+
if (![1284, 2222, 1313161554].includes(curve_1.curve.chainId)) return [3 /*break*/, 3];
|
|
172
172
|
return [4 /*yield*/, Promise.all([
|
|
173
173
|
(0, external_api_1._getLegacyAPYsAndVolumes)(curve_1.curve.constants.NETWORK_NAME),
|
|
174
|
-
(0, external_api_1.
|
|
174
|
+
(0, external_api_1._getFactoryAPYsAndVolumes)(curve_1.curve.constants.NETWORK_NAME),
|
|
175
175
|
])];
|
|
176
176
|
case 1:
|
|
177
177
|
_c = _e.sent(), mainPoolsData = _c[0], factoryPoolsData = _c[1];
|
|
@@ -203,10 +203,10 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
203
203
|
return __generator(this, function (_d) {
|
|
204
204
|
switch (_d.label) {
|
|
205
205
|
case 0:
|
|
206
|
-
if (!
|
|
206
|
+
if (![1284, 2222, 1313161554].includes(curve_1.curve.chainId)) return [3 /*break*/, 2];
|
|
207
207
|
return [4 /*yield*/, Promise.all([
|
|
208
208
|
(0, external_api_1._getLegacyAPYsAndVolumes)(curve_1.curve.constants.NETWORK_NAME),
|
|
209
|
-
(0, external_api_1.
|
|
209
|
+
(0, external_api_1._getFactoryAPYsAndVolumes)(curve_1.curve.constants.NETWORK_NAME),
|
|
210
210
|
])];
|
|
211
211
|
case 1:
|
|
212
212
|
_c = _d.sent(), mainPoolsData = _c[0], factoryPoolsData = _c[1];
|
package/lib/router.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { IRouteStep } from "./interfaces";
|
|
2
|
-
export declare const NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
3
|
-
export declare const NATIVE_TOKENS: {
|
|
4
|
-
[index: number]: {
|
|
5
|
-
symbol: string;
|
|
6
|
-
wrappedSymbol: string;
|
|
7
|
-
wrappedAddress: string;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
2
|
export declare const _findAllRoutesTheShorterTheBetter: (inputCoinAddress: string, outputCoinAddress: string) => Promise<IRouteStep[][]>;
|
|
11
3
|
export declare const _findAllRoutesTvl: (inputCoinAddress: string, outputCoinAddress: string) => Promise<IRouteStep[][]>;
|
|
12
4
|
export declare const _findAllRoutes: (inputCoinAddress: string, outputCoinAddress: string) => Promise<IRouteStep[][]>;
|
package/lib/router.js
CHANGED
|
@@ -59,7 +59,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
59
59
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
60
|
};
|
|
61
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
exports.swap = exports.swapEstimateGas = exports.swapApprove = exports.swapApproveEstimateGas = exports.swapIsApproved = exports.swapPriceImpact = exports.swapExpected = exports.getBestRouteAndOutput = exports._findAllRoutes = exports._findAllRoutesTvl = exports._findAllRoutesTheShorterTheBetter =
|
|
62
|
+
exports.swap = exports.swapEstimateGas = exports.swapApprove = exports.swapApproveEstimateGas = exports.swapIsApproved = exports.swapPriceImpact = exports.swapExpected = exports.getBestRouteAndOutput = exports._findAllRoutes = exports._findAllRoutesTvl = exports._findAllRoutesTheShorterTheBetter = void 0;
|
|
63
63
|
var axios_1 = __importDefault(require("axios"));
|
|
64
64
|
var memoizee_1 = __importDefault(require("memoizee"));
|
|
65
65
|
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
@@ -67,55 +67,6 @@ var ethers_1 = require("ethers");
|
|
|
67
67
|
var curve_1 = require("./curve");
|
|
68
68
|
var utils_1 = require("./utils");
|
|
69
69
|
var pools_1 = require("./pools");
|
|
70
|
-
// TODO Move to another place
|
|
71
|
-
exports.NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
72
|
-
exports.NATIVE_TOKENS = {
|
|
73
|
-
1: {
|
|
74
|
-
symbol: 'ETH',
|
|
75
|
-
wrappedSymbol: 'WETH',
|
|
76
|
-
wrappedAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'.toLowerCase(),
|
|
77
|
-
},
|
|
78
|
-
10: {
|
|
79
|
-
symbol: 'ETH',
|
|
80
|
-
wrappedSymbol: 'WETH',
|
|
81
|
-
wrappedAddress: '0x4200000000000000000000000000000000000006'.toLowerCase(),
|
|
82
|
-
},
|
|
83
|
-
100: {
|
|
84
|
-
symbol: 'XDAi',
|
|
85
|
-
wrappedSymbol: 'WXDAI',
|
|
86
|
-
wrappedAddress: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d'.toLowerCase(),
|
|
87
|
-
},
|
|
88
|
-
137: {
|
|
89
|
-
symbol: 'MATIC',
|
|
90
|
-
wrappedSymbol: 'WMATIC',
|
|
91
|
-
wrappedAddress: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270'.toLowerCase(),
|
|
92
|
-
},
|
|
93
|
-
250: {
|
|
94
|
-
symbol: 'FTM',
|
|
95
|
-
wrappedSymbol: 'WFTM',
|
|
96
|
-
wrappedAddress: '0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83'.toLowerCase(),
|
|
97
|
-
},
|
|
98
|
-
1284: {
|
|
99
|
-
symbol: 'GLMR',
|
|
100
|
-
wrappedSymbol: 'WGLMR',
|
|
101
|
-
wrappedAddress: '0xAcc15dC74880C9944775448304B263D191c6077F'.toLowerCase(),
|
|
102
|
-
},
|
|
103
|
-
43114: {
|
|
104
|
-
symbol: 'AVAX',
|
|
105
|
-
wrappedSymbol: 'WAVAX',
|
|
106
|
-
wrappedAddress: '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7'.toLowerCase(),
|
|
107
|
-
},
|
|
108
|
-
42161: {
|
|
109
|
-
symbol: 'ETH',
|
|
110
|
-
wrappedSymbol: 'WETH',
|
|
111
|
-
wrappedAddress: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1'.toLowerCase(),
|
|
112
|
-
},
|
|
113
|
-
1313161554: {
|
|
114
|
-
symbol: 'ETH',
|
|
115
|
-
wrappedSymbol: 'WETH',
|
|
116
|
-
wrappedAddress: '0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB'.toLowerCase(),
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
70
|
var MAX_ROUTES_FOR_ONE_COIN = 3;
|
|
120
71
|
// Inspired by Dijkstra's algorithm
|
|
121
72
|
var _findAllRoutesTheShorterTheBetter = function (inputCoinAddress, outputCoinAddress) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -232,7 +183,7 @@ var _findAllRoutesTheShorterTheBetter = function (inputCoinAddress, outputCoinAd
|
|
|
232
183
|
if (markedCoins.includes(wrapped_coin_addresses[j]) || curCoins.includes(wrapped_coin_addresses[j]))
|
|
233
184
|
return [3 /*break*/, 6];
|
|
234
185
|
// Native swaps spend less gas
|
|
235
|
-
if (wrapped_coin_addresses[j] !== outputCoinAddress && wrapped_coin_addresses[j] ===
|
|
186
|
+
if (wrapped_coin_addresses[j] !== outputCoinAddress && wrapped_coin_addresses[j] === curve_1.curve.constants.NATIVE_TOKEN.wrappedAddress)
|
|
236
187
|
return [3 /*break*/, 6];
|
|
237
188
|
// Looking for outputCoinAddress only on the final step
|
|
238
189
|
if (step === 3 && wrapped_coin_addresses[j] !== outputCoinAddress)
|
|
@@ -287,7 +238,7 @@ var _findAllRoutesTheShorterTheBetter = function (inputCoinAddress, outputCoinAd
|
|
|
287
238
|
tvl = _m.apply(void 0, [_x.sent()]);
|
|
288
239
|
if (tvl === 0)
|
|
289
240
|
return [3 /*break*/, 10];
|
|
290
|
-
hasEth = (inCoin ===
|
|
241
|
+
hasEth = (inCoin === curve_1.curve.constants.NATIVE_TOKEN.address || underlying_coin_addresses[j] === curve_1.curve.constants.NATIVE_TOKEN.address);
|
|
291
242
|
swapType = ((base_pool === null || base_pool === void 0 ? void 0 : base_pool.is_lending) && poolData.is_factory) ? 5 : hasEth ? 3 : poolData.is_crypto ? 4 : 2;
|
|
292
243
|
for (_o = 0, _p = routes[inCoin]; _o < _p.length; _o++) {
|
|
293
244
|
inCoinRoute = _p[_o];
|
|
@@ -499,7 +450,7 @@ var _findAllRoutesTvl = function (inputCoinAddress, outputCoinAddress) { return
|
|
|
499
450
|
if (j === inCoinIndexes.wrapped_coin)
|
|
500
451
|
return [2 /*return*/, "continue"];
|
|
501
452
|
// Native swaps spend less gas
|
|
502
|
-
if (wrapped_coin_addresses[j] !== outputCoinAddress && wrapped_coin_addresses[j] ===
|
|
453
|
+
if (wrapped_coin_addresses[j] !== outputCoinAddress && wrapped_coin_addresses[j] === curve_1.curve.constants.NATIVE_TOKEN.wrappedAddress)
|
|
503
454
|
return [2 /*return*/, "continue"];
|
|
504
455
|
// Looking for outputCoinAddress only on the final step
|
|
505
456
|
if (step === 3 && wrapped_coin_addresses[j] !== outputCoinAddress)
|
|
@@ -588,7 +539,7 @@ var _findAllRoutesTvl = function (inputCoinAddress, outputCoinAddress) { return
|
|
|
588
539
|
tvl = _u.apply(void 0, [_v.sent()]);
|
|
589
540
|
if (tvl === 0)
|
|
590
541
|
return [2 /*return*/, "continue"];
|
|
591
|
-
hasEth = (inCoin ===
|
|
542
|
+
hasEth = (inCoin === curve_1.curve.constants.NATIVE_TOKEN.address || underlying_coin_addresses[j] === curve_1.curve.constants.NATIVE_TOKEN.address);
|
|
592
543
|
swapType = ((base_pool === null || base_pool === void 0 ? void 0 : base_pool.is_lending) && poolData.is_factory) ? 5 : hasEth ? 3 : poolData.is_crypto ? 4 : 2;
|
|
593
544
|
newRoutes = routes[inCoin].map(function (route) {
|
|
594
545
|
var routePoolIds = route.steps.map(function (s) { return s.poolId; });
|
package/lib/utils.js
CHANGED
|
@@ -468,6 +468,7 @@ var _getUsdRate = function (assetId) { return __awaiter(void 0, void 0, void 0,
|
|
|
468
468
|
137: 'polygon-pos',
|
|
469
469
|
250: 'fantom',
|
|
470
470
|
1284: 'moonbeam',
|
|
471
|
+
2222: 'kava',
|
|
471
472
|
43114: 'avalanche',
|
|
472
473
|
42161: 'arbitrum-one',
|
|
473
474
|
1313161554: 'aurora',
|
|
@@ -479,6 +480,7 @@ var _getUsdRate = function (assetId) { return __awaiter(void 0, void 0, void 0,
|
|
|
479
480
|
137: 'matic-network',
|
|
480
481
|
250: 'fantom',
|
|
481
482
|
1284: 'moonbeam',
|
|
483
|
+
2222: 'kava',
|
|
482
484
|
43114: 'avalanche-2',
|
|
483
485
|
42161: 'ethereum',
|
|
484
486
|
1313161554: 'ethereum',
|
|
@@ -549,6 +551,7 @@ var getTVL = function (chainId) {
|
|
|
549
551
|
137: "polygon",
|
|
550
552
|
250: "fantom",
|
|
551
553
|
1284: "moonbeam",
|
|
554
|
+
2222: 'kava',
|
|
552
555
|
43114: "avalanche",
|
|
553
556
|
42161: "arbitrum",
|
|
554
557
|
1313161554: "aurora",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@curvefi/api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.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
|
"@ethersproject/networks": "^5.5.0",
|
|
35
35
|
"axios": "^0.21.1",
|
|
36
36
|
"bignumber.js": "^9.0.1",
|
|
37
|
-
"ethcall": "^4.8.
|
|
37
|
+
"ethcall": "^4.8.4",
|
|
38
38
|
"ethers": "^5.4.6",
|
|
39
39
|
"memoizee": "^0.4.15"
|
|
40
40
|
}
|