@curvefi/api 2.30.1 → 2.31.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/avaxcrypto/swap.json +1195 -0
- package/lib/constants/abis/avaxcrypto/zap.json +250 -0
- package/lib/constants/coins/avalanche.js +5 -0
- package/lib/constants/pools/avalanche.js +35 -0
- package/lib/constants/pools/polygon.js +1 -0
- package/lib/constants/pools/xdai.js +1 -0
- package/lib/curve.js +1 -1
- package/lib/interfaces.d.ts +1 -0
- package/lib/pools/PoolTemplate.d.ts +1 -0
- package/lib/pools/PoolTemplate.js +4 -3
- package/lib/pools/mixins/common.d.ts +1 -1
- package/lib/pools/mixins/common.js +21 -11
- package/lib/pools/mixins/depositMixins.js +23 -10
- package/lib/pools/mixins/poolBalancesMixin.d.ts +0 -1
- package/lib/pools/mixins/poolBalancesMixin.js +7 -33
- package/lib/pools/mixins/withdrawExpectedMixins.d.ts +0 -1
- package/lib/pools/mixins/withdrawExpectedMixins.js +2 -46
- package/lib/pools/mixins/withdrawMixins.js +23 -10
- package/lib/pools/mixins/withdrawOneCoinMixins.js +23 -10
- package/lib/pools/poolConstructor.js +3 -9
- package/lib/router.js +32 -13
- package/package.json +1 -1
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"stateMutability": "nonpayable",
|
|
4
|
+
"type": "constructor",
|
|
5
|
+
"inputs": [
|
|
6
|
+
{
|
|
7
|
+
"name": "_pool",
|
|
8
|
+
"type": "address"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "_base_pool",
|
|
12
|
+
"type": "address"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"outputs": []
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"stateMutability": "payable",
|
|
19
|
+
"type": "fallback"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"stateMutability": "payable",
|
|
23
|
+
"type": "function",
|
|
24
|
+
"name": "add_liquidity",
|
|
25
|
+
"inputs": [
|
|
26
|
+
{
|
|
27
|
+
"name": "_amounts",
|
|
28
|
+
"type": "uint256[4]"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "_min_mint_amount",
|
|
32
|
+
"type": "uint256"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "use_eth",
|
|
36
|
+
"type": "bool"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"outputs": []
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"stateMutability": "payable",
|
|
43
|
+
"type": "function",
|
|
44
|
+
"name": "exchange_underlying",
|
|
45
|
+
"inputs": [
|
|
46
|
+
{
|
|
47
|
+
"name": "i",
|
|
48
|
+
"type": "uint256"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "j",
|
|
52
|
+
"type": "uint256"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "_dx",
|
|
56
|
+
"type": "uint256"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "_min_dy",
|
|
60
|
+
"type": "uint256"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "use_eth",
|
|
64
|
+
"type": "bool"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"outputs": []
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"stateMutability": "nonpayable",
|
|
71
|
+
"type": "function",
|
|
72
|
+
"name": "remove_liquidity",
|
|
73
|
+
"inputs": [
|
|
74
|
+
{
|
|
75
|
+
"name": "_amount",
|
|
76
|
+
"type": "uint256"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "_min_amounts",
|
|
80
|
+
"type": "uint256[4]"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "use_eth",
|
|
84
|
+
"type": "bool"
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"outputs": []
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"stateMutability": "nonpayable",
|
|
91
|
+
"type": "function",
|
|
92
|
+
"name": "remove_liquidity_one_coin",
|
|
93
|
+
"inputs": [
|
|
94
|
+
{
|
|
95
|
+
"name": "_token_amount",
|
|
96
|
+
"type": "uint256"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "i",
|
|
100
|
+
"type": "uint256"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "_min_amount",
|
|
104
|
+
"type": "uint256"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "use_eth",
|
|
108
|
+
"type": "bool"
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"outputs": []
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"stateMutability": "view",
|
|
115
|
+
"type": "function",
|
|
116
|
+
"name": "get_dy_underlying",
|
|
117
|
+
"inputs": [
|
|
118
|
+
{
|
|
119
|
+
"name": "i",
|
|
120
|
+
"type": "uint256"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "j",
|
|
124
|
+
"type": "uint256"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"name": "_dx",
|
|
128
|
+
"type": "uint256"
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
"outputs": [
|
|
132
|
+
{
|
|
133
|
+
"name": "",
|
|
134
|
+
"type": "uint256"
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"stateMutability": "view",
|
|
140
|
+
"type": "function",
|
|
141
|
+
"name": "calc_token_amount",
|
|
142
|
+
"inputs": [
|
|
143
|
+
{
|
|
144
|
+
"name": "_amounts",
|
|
145
|
+
"type": "uint256[4]"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"name": "_is_deposit",
|
|
149
|
+
"type": "bool"
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
"outputs": [
|
|
153
|
+
{
|
|
154
|
+
"name": "",
|
|
155
|
+
"type": "uint256"
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"stateMutability": "view",
|
|
161
|
+
"type": "function",
|
|
162
|
+
"name": "calc_withdraw_one_coin",
|
|
163
|
+
"inputs": [
|
|
164
|
+
{
|
|
165
|
+
"name": "token_amount",
|
|
166
|
+
"type": "uint256"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"name": "i",
|
|
170
|
+
"type": "uint256"
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
"outputs": [
|
|
174
|
+
{
|
|
175
|
+
"name": "",
|
|
176
|
+
"type": "uint256"
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"stateMutability": "view",
|
|
182
|
+
"type": "function",
|
|
183
|
+
"name": "coins",
|
|
184
|
+
"inputs": [
|
|
185
|
+
{
|
|
186
|
+
"name": "arg0",
|
|
187
|
+
"type": "uint256"
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
"outputs": [
|
|
191
|
+
{
|
|
192
|
+
"name": "",
|
|
193
|
+
"type": "address"
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"stateMutability": "view",
|
|
199
|
+
"type": "function",
|
|
200
|
+
"name": "underlying_coins",
|
|
201
|
+
"inputs": [
|
|
202
|
+
{
|
|
203
|
+
"name": "arg0",
|
|
204
|
+
"type": "uint256"
|
|
205
|
+
}
|
|
206
|
+
],
|
|
207
|
+
"outputs": [
|
|
208
|
+
{
|
|
209
|
+
"name": "",
|
|
210
|
+
"type": "address"
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"stateMutability": "view",
|
|
216
|
+
"type": "function",
|
|
217
|
+
"name": "pool",
|
|
218
|
+
"inputs": [],
|
|
219
|
+
"outputs": [
|
|
220
|
+
{
|
|
221
|
+
"name": "",
|
|
222
|
+
"type": "address"
|
|
223
|
+
}
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"stateMutability": "view",
|
|
228
|
+
"type": "function",
|
|
229
|
+
"name": "base_pool",
|
|
230
|
+
"inputs": [],
|
|
231
|
+
"outputs": [
|
|
232
|
+
{
|
|
233
|
+
"name": "",
|
|
234
|
+
"type": "address"
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"stateMutability": "view",
|
|
240
|
+
"type": "function",
|
|
241
|
+
"name": "token",
|
|
242
|
+
"inputs": [],
|
|
243
|
+
"outputs": [
|
|
244
|
+
{
|
|
245
|
+
"name": "",
|
|
246
|
+
"type": "address"
|
|
247
|
+
}
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
]
|
|
@@ -15,13 +15,18 @@ exports.COINS_AVALANCHE = (0, utils_1.lowerCaseValues)({
|
|
|
15
15
|
'avusdc': '0x46A51127C3ce23fb7AB1DE06226147F446e4a857',
|
|
16
16
|
'avusdt': '0x532E6537FEA298397212F09A61e03311686f548e',
|
|
17
17
|
'av3crv': '0x1337bedc9d22ecbe766df105c9623922a27963ec',
|
|
18
|
+
'2crv': '0x0974D9d3bc463Fa17497aAFc3a87535553298FbE',
|
|
18
19
|
// --- BTC ---
|
|
19
20
|
'wbtc.e': '0x50b7545627a5162F82A992c33b87aDc75187B218',
|
|
20
21
|
'renbtc': '0xDBf31dF14B66535aF65AaC99C32e9eA844e14501',
|
|
21
22
|
'avwbtc': '0x686bEF2417b6Dc32C50a3cBfbCC3bb60E1e9a15D',
|
|
23
|
+
'btc.b': '0x152b9d0FdC40C096757F570A51E494bd4b943E50',
|
|
22
24
|
// --- ETH ---
|
|
23
25
|
'weth.e': '0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB',
|
|
24
26
|
'avweth': '0x53f7c5869a859F0AeC3D334ee8B4Cf01E3492f21',
|
|
27
|
+
// --- AVAX ---
|
|
28
|
+
'avax': '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
29
|
+
'wavax': '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7',
|
|
25
30
|
});
|
|
26
31
|
exports.cTokensAvalanche = []; //.map((a) => a.toLowerCase());
|
|
27
32
|
exports.yTokensAvalanche = []; //.map((a) => a.toLowerCase());
|
|
@@ -9,6 +9,8 @@ var swap_json_1 = __importDefault(require("../abis/aave/swap.json"));
|
|
|
9
9
|
var swap_json_2 = __importDefault(require("../abis/ren-polygon/swap.json"));
|
|
10
10
|
var swap_json_3 = __importDefault(require("../abis/atricrypto3/swap.json"));
|
|
11
11
|
var zap_json_1 = __importDefault(require("../abis/atricrypto3/zap.json"));
|
|
12
|
+
var swap_json_4 = __importDefault(require("../abis/avaxcrypto/swap.json"));
|
|
13
|
+
var zap_json_2 = __importDefault(require("../abis/avaxcrypto/zap.json"));
|
|
12
14
|
var gauge_child_json_1 = __importDefault(require("../abis/gauge_child.json"));
|
|
13
15
|
exports.POOLS_DATA_AVALANCHE = (0, utils_1.lowerCasePoolDataAddresses)({
|
|
14
16
|
aave: {
|
|
@@ -82,6 +84,7 @@ exports.POOLS_DATA_AVALANCHE = (0, utils_1.lowerCasePoolDataAddresses)({
|
|
|
82
84
|
is_crypto: true,
|
|
83
85
|
is_fake: true,
|
|
84
86
|
base_pool: 'aave',
|
|
87
|
+
meta_coin_idx: 0,
|
|
85
88
|
underlying_coins: ['DAI.e', 'USDC.e', 'USDT.e', 'WBTC.e', 'WETH.e'],
|
|
86
89
|
wrapped_coins: ['av3CRV', 'avWBTC', 'avWETH'],
|
|
87
90
|
underlying_coin_addresses: [
|
|
@@ -133,4 +136,36 @@ exports.POOLS_DATA_AVALANCHE = (0, utils_1.lowerCasePoolDataAddresses)({
|
|
|
133
136
|
// sCurveRewards_address: '0xB504b6EB06760019801a91B451d3f7BD9f027fC9',
|
|
134
137
|
// reward_token: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
|
|
135
138
|
},
|
|
139
|
+
avaxcrypto: {
|
|
140
|
+
name: "avaxcrypto",
|
|
141
|
+
full_name: "avaxcrypto",
|
|
142
|
+
symbol: "avaxcrypto",
|
|
143
|
+
reference_asset: 'CRYPTO',
|
|
144
|
+
swap_address: '0x204f0620E7E7f07B780535711884835977679bba',
|
|
145
|
+
token_address: '0x6a4aC4DE3bF6bCD2975E2cb15A46954D9bA43fDb',
|
|
146
|
+
gauge_address: '0xf6C5Be565A25Be925c9D8fB0368a87bd20ee470b',
|
|
147
|
+
deposit_address: '0x25b3D0eeBcd85Ea5A970981c5E2A342f4e1064e8',
|
|
148
|
+
is_meta: true,
|
|
149
|
+
is_crypto: true,
|
|
150
|
+
base_pool: 'factory-v2-99',
|
|
151
|
+
meta_coin_idx: 0,
|
|
152
|
+
underlying_coins: ['USDC', 'USDt', 'BTC.b', 'AVAX'],
|
|
153
|
+
wrapped_coins: ['2CRV', 'BTC.b', 'WAVAX'],
|
|
154
|
+
underlying_coin_addresses: [
|
|
155
|
+
'0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
|
|
156
|
+
'0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7',
|
|
157
|
+
'0x152b9d0FdC40C096757F570A51E494bd4b943E50',
|
|
158
|
+
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
159
|
+
],
|
|
160
|
+
wrapped_coin_addresses: [
|
|
161
|
+
'0x0974D9d3bc463Fa17497aAFc3a87535553298FbE',
|
|
162
|
+
'0x152b9d0FdC40C096757F570A51E494bd4b943E50',
|
|
163
|
+
'0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7',
|
|
164
|
+
],
|
|
165
|
+
underlying_decimals: [6, 6, 8, 18],
|
|
166
|
+
wrapped_decimals: [18, 8, 18],
|
|
167
|
+
swap_abi: swap_json_4.default,
|
|
168
|
+
gauge_abi: gauge_child_json_1.default,
|
|
169
|
+
deposit_abi: zap_json_2.default,
|
|
170
|
+
},
|
|
136
171
|
});
|
|
@@ -86,6 +86,7 @@ exports.POOLS_DATA_POLYGON = (0, utils_1.lowerCasePoolDataAddresses)({
|
|
|
86
86
|
is_crypto: true,
|
|
87
87
|
is_fake: true,
|
|
88
88
|
base_pool: 'aave',
|
|
89
|
+
meta_coin_idx: 0,
|
|
89
90
|
underlying_coins: ['DAI', 'USDC', 'USDT', 'WBTC', 'WETH'],
|
|
90
91
|
wrapped_coins: ['am3CRV', 'amWBTC', 'amWETH'],
|
|
91
92
|
underlying_coin_addresses: [
|
|
@@ -85,6 +85,7 @@ exports.POOLS_DATA_XDAI = (0, utils_1.lowerCasePoolDataAddresses)({
|
|
|
85
85
|
is_crypto: true,
|
|
86
86
|
is_meta: true,
|
|
87
87
|
base_pool: '3pool',
|
|
88
|
+
meta_coin_idx: 0,
|
|
88
89
|
underlying_coins: ['WXDAI', 'USDC', 'USDT', 'WBTC', 'WETH'],
|
|
89
90
|
wrapped_coins: ['x3CRV', 'WBTC', 'WETH'],
|
|
90
91
|
underlying_coin_addresses: [
|
package/lib/curve.js
CHANGED
|
@@ -509,7 +509,7 @@ var Curve = /** @class */ (function () {
|
|
|
509
509
|
if (providerType.toLowerCase() === 'JsonRpc'.toLowerCase()) {
|
|
510
510
|
providerSettings = providerSettings;
|
|
511
511
|
if (providerSettings.url) {
|
|
512
|
-
this.provider =
|
|
512
|
+
this.provider = new ethers_1.ethers.providers.JsonRpcProvider(providerSettings.url);
|
|
513
513
|
}
|
|
514
514
|
else {
|
|
515
515
|
this.provider = new ethers_1.ethers.providers.JsonRpcProvider('http://localhost:8545/');
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ var YEAR = 365 * DAY;
|
|
|
73
73
|
var PoolTemplate = /** @class */ (function () {
|
|
74
74
|
function PoolTemplate(id) {
|
|
75
75
|
var _this = this;
|
|
76
|
-
var _c;
|
|
76
|
+
var _c, _d;
|
|
77
77
|
this.statsParameters = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
78
78
|
var multicallContract, lpMulticallContract, calls, i, additionalCalls, _virtualPrice, _fee, _prices, _adminFee, _A, _lpTokenSupply, _gamma, e_1, _c, virtualPrice, fee, adminFee, A, lpTokenSupply, gamma, priceOracle, priceScale, prices, i, A_PRECISION, _d, _future_A, _initial_A, _future_A_time, _initial_A_time, _e, future_A, initial_A, future_A_time, initial_A_time;
|
|
79
79
|
var _f, _g, _h;
|
|
@@ -1134,6 +1134,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1134
1134
|
this.isFactory = poolData.is_factory || false;
|
|
1135
1135
|
this.isMetaFactory = (this.isMeta && this.isFactory) || this.zap === '0xa79828df1850e8a3a3064576f380d90aecdd3359';
|
|
1136
1136
|
this.basePool = poolData.base_pool || '';
|
|
1137
|
+
this.metaCoinIdx = this.isMeta ? (_c = poolData.meta_coin_idx) !== null && _c !== void 0 ? _c : poolData.wrapped_coins.length - 1 : -1;
|
|
1137
1138
|
this.underlyingCoins = poolData.underlying_coins;
|
|
1138
1139
|
this.wrappedCoins = poolData.wrapped_coins;
|
|
1139
1140
|
this.underlyingCoinAddresses = poolData.underlying_coin_addresses;
|
|
@@ -1141,7 +1142,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
1141
1142
|
this.underlyingDecimals = poolData.underlying_decimals;
|
|
1142
1143
|
this.wrappedDecimals = poolData.wrapped_decimals;
|
|
1143
1144
|
this.useLending = poolData.use_lending || poolData.underlying_coin_addresses.map(function () { return false; });
|
|
1144
|
-
this.inApi = (
|
|
1145
|
+
this.inApi = (_d = poolData.in_api) !== null && _d !== void 0 ? _d : false;
|
|
1145
1146
|
this.estimateGas = {
|
|
1146
1147
|
depositApprove: this.depositApproveEstimateGas.bind(this),
|
|
1147
1148
|
deposit: this.depositEstimateGas.bind(this),
|
|
@@ -2184,7 +2185,7 @@ var PoolTemplate = /** @class */ (function () {
|
|
|
2184
2185
|
case 12:
|
|
2185
2186
|
_amounts = amounts.map(function (amount, i) { return (0, utils_1.parseUnits)(amount, decimals[i]); });
|
|
2186
2187
|
contract = curve_1.curve.contracts[curve_1.curve.constants.ALIASES.deposit_and_stake].contract;
|
|
2187
|
-
useUnderlying = isUnderlying && (this.isLending || (this.isCrypto && !this.isPlain)) && !this.zap;
|
|
2188
|
+
useUnderlying = isUnderlying && (this.isLending || (this.isCrypto && !this.isPlain)) && (!this.zap || this.id == 'avaxcrypto');
|
|
2188
2189
|
if (!isUnderlying) return [3 /*break*/, 14];
|
|
2189
2190
|
_l = (_k = ethers_1.ethers.utils).parseUnits;
|
|
2190
2191
|
return [4 /*yield*/, this.depositAndStakeExpected(amounts)];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
import { PoolTemplate } from "../PoolTemplate";
|
|
3
3
|
export declare function _calcExpectedAmounts(this: PoolTemplate, _lpTokenAmount: ethers.BigNumber): Promise<ethers.BigNumber[]>;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function _calcExpectedUnderlyingAmountsMeta(this: PoolTemplate, _lpTokenAmount: ethers.BigNumber): Promise<ethers.BigNumber[]>;
|
|
@@ -45,7 +45,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
45
45
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.
|
|
48
|
+
exports._calcExpectedUnderlyingAmountsMeta = exports._calcExpectedAmounts = void 0;
|
|
49
49
|
var PoolTemplate_1 = require("../PoolTemplate");
|
|
50
50
|
var curve_1 = require("../../curve");
|
|
51
51
|
var utils_1 = require("../../utils");
|
|
@@ -85,22 +85,32 @@ function _calcExpectedAmounts(_lpTokenAmount) {
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
exports._calcExpectedAmounts = _calcExpectedAmounts;
|
|
88
|
-
function
|
|
88
|
+
function _calcExpectedUnderlyingAmountsMeta(_lpTokenAmount) {
|
|
89
89
|
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
-
var _expectedWrappedAmounts, _expectedMetaCoinAmount, _expectedUnderlyingAmounts, basePool, _basePoolExpectedAmounts;
|
|
91
|
-
return __generator(this, function (
|
|
92
|
-
switch (
|
|
90
|
+
var _expectedWrappedAmounts, _expectedMetaCoinAmount, _expectedUnderlyingAmounts, basePool, _basePoolExpectedAmounts, _a;
|
|
91
|
+
return __generator(this, function (_b) {
|
|
92
|
+
switch (_b.label) {
|
|
93
93
|
case 0: return [4 /*yield*/, _calcExpectedAmounts.call(this, _lpTokenAmount)];
|
|
94
94
|
case 1:
|
|
95
|
-
_expectedWrappedAmounts =
|
|
96
|
-
_expectedMetaCoinAmount = _expectedWrappedAmounts
|
|
95
|
+
_expectedWrappedAmounts = _b.sent();
|
|
96
|
+
_expectedMetaCoinAmount = _expectedWrappedAmounts.splice(this.metaCoinIdx, 1)[0];
|
|
97
|
+
_expectedUnderlyingAmounts = _expectedWrappedAmounts;
|
|
97
98
|
basePool = new PoolTemplate_1.PoolTemplate(this.basePool);
|
|
98
|
-
return [
|
|
99
|
+
if (!basePool.isMeta) return [3 /*break*/, 3];
|
|
100
|
+
return [4 /*yield*/, _calcExpectedUnderlyingAmountsMeta.call(basePool, _expectedMetaCoinAmount)];
|
|
99
101
|
case 2:
|
|
100
|
-
|
|
101
|
-
return [
|
|
102
|
+
_a = _b.sent();
|
|
103
|
+
return [3 /*break*/, 5];
|
|
104
|
+
case 3: return [4 /*yield*/, _calcExpectedAmounts.call(basePool, _expectedMetaCoinAmount)];
|
|
105
|
+
case 4:
|
|
106
|
+
_a = _b.sent();
|
|
107
|
+
_b.label = 5;
|
|
108
|
+
case 5:
|
|
109
|
+
_basePoolExpectedAmounts = _a;
|
|
110
|
+
_expectedUnderlyingAmounts.splice.apply(_expectedUnderlyingAmounts, __spreadArray([this.metaCoinIdx, 0], _basePoolExpectedAmounts, false));
|
|
111
|
+
return [2 /*return*/, _expectedUnderlyingAmounts];
|
|
102
112
|
}
|
|
103
113
|
});
|
|
104
114
|
});
|
|
105
115
|
}
|
|
106
|
-
exports.
|
|
116
|
+
exports._calcExpectedUnderlyingAmountsMeta = _calcExpectedUnderlyingAmountsMeta;
|
|
@@ -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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
59
|
exports.depositPlainMixin = exports.depositLendingOrCryptoMixin = exports.depositZapMixin = exports.depositCryptoMetaFactoryMixin = exports.depositMetaFactoryMixin = void 0;
|
|
51
60
|
var utils_1 = require("../../utils");
|
|
@@ -245,29 +254,33 @@ exports.depositZapMixin = {
|
|
|
245
254
|
_deposit: function (_amounts, slippage, estimateGas) {
|
|
246
255
|
if (estimateGas === void 0) { estimateGas = false; }
|
|
247
256
|
return __awaiter(this, void 0, void 0, function () {
|
|
248
|
-
var _minMintAmount, ethIndex, value, contract, gas, gasLimit;
|
|
249
|
-
|
|
250
|
-
|
|
257
|
+
var _minMintAmount, ethIndex, value, contract, args, gas, gasLimit;
|
|
258
|
+
var _a;
|
|
259
|
+
return __generator(this, function (_b) {
|
|
260
|
+
switch (_b.label) {
|
|
251
261
|
case 0:
|
|
252
262
|
if (!!estimateGas) return [3 /*break*/, 2];
|
|
253
263
|
return [4 /*yield*/, (0, utils_1._ensureAllowance)(this.underlyingCoinAddresses, _amounts, this.zap)];
|
|
254
264
|
case 1:
|
|
255
|
-
|
|
256
|
-
|
|
265
|
+
_b.sent();
|
|
266
|
+
_b.label = 2;
|
|
257
267
|
case 2: return [4 /*yield*/, _depositMinAmount.call(this, _amounts, slippage)];
|
|
258
268
|
case 3:
|
|
259
|
-
_minMintAmount =
|
|
269
|
+
_minMintAmount = _b.sent();
|
|
260
270
|
ethIndex = (0, utils_1.getEthIndex)(this.underlyingCoinAddresses);
|
|
261
271
|
value = _amounts[ethIndex] || ethers_1.ethers.BigNumber.from(0);
|
|
262
272
|
contract = curve_1.curve.contracts[this.zap].contract;
|
|
263
|
-
|
|
273
|
+
args = [_amounts, _minMintAmount];
|
|
274
|
+
if ("add_liquidity(uint256[".concat(this.underlyingCoinAddresses.length, "],uint256,bool)") in contract)
|
|
275
|
+
args.push(true);
|
|
276
|
+
return [4 /*yield*/, (_a = contract.estimateGas).add_liquidity.apply(_a, __spreadArray(__spreadArray([], args, false), [__assign(__assign({}, curve_1.curve.constantOptions), { value: value })], false))];
|
|
264
277
|
case 4:
|
|
265
|
-
gas =
|
|
278
|
+
gas = _b.sent();
|
|
266
279
|
if (estimateGas)
|
|
267
280
|
return [2 /*return*/, gas.toNumber()];
|
|
268
281
|
gasLimit = gas.mul(130).div(100);
|
|
269
|
-
return [4 /*yield*/, contract.add_liquidity(
|
|
270
|
-
case 5: return [2 /*return*/, (
|
|
282
|
+
return [4 /*yield*/, contract.add_liquidity.apply(contract, __spreadArray(__spreadArray([], args, false), [__assign(__assign({}, curve_1.curve.options), { gasLimit: gasLimit, value: value })], false))];
|
|
283
|
+
case 5: return [2 /*return*/, (_b.sent()).hash];
|
|
271
284
|
}
|
|
272
285
|
});
|
|
273
286
|
});
|
|
@@ -45,42 +45,16 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
45
45
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.poolBalancesLendingMixin = exports.poolBalancesMetaMixin =
|
|
48
|
+
exports.poolBalancesLendingMixin = exports.poolBalancesMetaMixin = void 0;
|
|
49
49
|
var ethers_1 = require("ethers");
|
|
50
50
|
var curve_1 = require("../../curve");
|
|
51
51
|
var common_1 = require("./common");
|
|
52
52
|
var PoolTemplate_1 = require("../PoolTemplate");
|
|
53
53
|
// @ts-ignore
|
|
54
|
-
exports.poolBalancesAtricrypto3Mixin = {
|
|
55
|
-
statsUnderlyingBalances: function () {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
-
var swapContract, contractCalls, _poolWrappedBalances, _poolMetaCoinBalance, _poolNonMetaBalances, basePool, _basePoolExpectedAmounts, _poolUnderlyingBalances;
|
|
58
|
-
var _this = this;
|
|
59
|
-
return __generator(this, function (_a) {
|
|
60
|
-
switch (_a.label) {
|
|
61
|
-
case 0:
|
|
62
|
-
swapContract = curve_1.curve.contracts[this.address].multicallContract;
|
|
63
|
-
contractCalls = this.wrappedCoins.map(function (_, i) { return swapContract.balances(i); });
|
|
64
|
-
return [4 /*yield*/, curve_1.curve.multicallProvider.all(contractCalls)];
|
|
65
|
-
case 1:
|
|
66
|
-
_poolWrappedBalances = _a.sent();
|
|
67
|
-
_poolMetaCoinBalance = _poolWrappedBalances[0], _poolNonMetaBalances = _poolWrappedBalances.slice(1);
|
|
68
|
-
basePool = new PoolTemplate_1.PoolTemplate(this.basePool);
|
|
69
|
-
return [4 /*yield*/, common_1._calcExpectedAmounts.call(basePool, _poolMetaCoinBalance)];
|
|
70
|
-
case 2:
|
|
71
|
-
_basePoolExpectedAmounts = _a.sent();
|
|
72
|
-
_poolUnderlyingBalances = __spreadArray(__spreadArray([], _basePoolExpectedAmounts, true), _poolNonMetaBalances, true);
|
|
73
|
-
return [2 /*return*/, _poolUnderlyingBalances.map(function (_b, i) { return ethers_1.ethers.utils.formatUnits(_b, _this.underlyingDecimals[i]); })];
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
// @ts-ignore
|
|
80
54
|
exports.poolBalancesMetaMixin = {
|
|
81
55
|
statsUnderlyingBalances: function () {
|
|
82
56
|
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
-
var swapContract, contractCalls, _poolWrappedBalances, _poolMetaCoinBalance,
|
|
57
|
+
var swapContract, contractCalls, _poolWrappedBalances, _poolMetaCoinBalance, _poolUnderlyingBalances, basePool, _basePoolExpectedAmounts, _a;
|
|
84
58
|
var _this = this;
|
|
85
59
|
return __generator(this, function (_c) {
|
|
86
60
|
switch (_c.label) {
|
|
@@ -90,11 +64,11 @@ exports.poolBalancesMetaMixin = {
|
|
|
90
64
|
return [4 /*yield*/, curve_1.curve.multicallProvider.all(contractCalls)];
|
|
91
65
|
case 1:
|
|
92
66
|
_poolWrappedBalances = _c.sent();
|
|
93
|
-
_poolWrappedBalances.
|
|
94
|
-
|
|
67
|
+
_poolMetaCoinBalance = _poolWrappedBalances.splice(this.metaCoinIdx, 1)[0];
|
|
68
|
+
_poolUnderlyingBalances = _poolWrappedBalances;
|
|
95
69
|
basePool = new PoolTemplate_1.PoolTemplate(this.basePool);
|
|
96
|
-
if (!
|
|
97
|
-
return [4 /*yield*/, common_1.
|
|
70
|
+
if (!basePool.isMeta) return [3 /*break*/, 3];
|
|
71
|
+
return [4 /*yield*/, common_1._calcExpectedUnderlyingAmountsMeta.call(basePool, _poolMetaCoinBalance)];
|
|
98
72
|
case 2:
|
|
99
73
|
_a = _c.sent();
|
|
100
74
|
return [3 /*break*/, 5];
|
|
@@ -104,7 +78,7 @@ exports.poolBalancesMetaMixin = {
|
|
|
104
78
|
_c.label = 5;
|
|
105
79
|
case 5:
|
|
106
80
|
_basePoolExpectedAmounts = _a;
|
|
107
|
-
_poolUnderlyingBalances
|
|
81
|
+
_poolUnderlyingBalances.splice.apply(_poolUnderlyingBalances, __spreadArray([this.metaCoinIdx, 0], _basePoolExpectedAmounts, false));
|
|
108
82
|
return [2 /*return*/, _poolUnderlyingBalances.map(function (_b, i) { return ethers_1.ethers.utils.formatUnits(_b, _this.underlyingDecimals[i]); })];
|
|
109
83
|
}
|
|
110
84
|
});
|
|
@@ -2,5 +2,4 @@ import { PoolTemplate } from "../PoolTemplate";
|
|
|
2
2
|
export declare const withdrawExpectedMixin: PoolTemplate;
|
|
3
3
|
export declare const withdrawExpectedLendingOrCryptoMixin: PoolTemplate;
|
|
4
4
|
export declare const withdrawExpectedMetaMixin: PoolTemplate;
|
|
5
|
-
export declare const withdrawExpectedAtricrypto3Mixin: PoolTemplate;
|
|
6
5
|
export declare const withdrawWrappedExpectedMixin: PoolTemplate;
|