@curvefi/api 1.6.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +340 -8
- package/lib/boosting.d.ts +3 -0
- package/lib/boosting.js +30 -3
- package/lib/constants/abis/abis-ethereum.js +2 -2
- package/lib/constants/abis/json/registry_exchange.json +0 -37
- package/lib/constants/abis/json/tricrypto2/deposit.json +0 -79
- package/lib/curve.d.ts +1 -0
- package/lib/curve.js +47 -9
- package/lib/index.d.ts +9 -0
- package/lib/index.js +9 -0
- package/lib/pools.d.ts +6 -11
- package/lib/pools.js +413 -343
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +25 -3
- package/package.json +1 -1
- package/lib/constants/abis/json/registry.json +0 -940
package/README.md
CHANGED
|
@@ -1,13 +1,223 @@
|
|
|
1
1
|
# Curve JS
|
|
2
2
|
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
Install from npm:
|
|
6
|
+
|
|
7
|
+
`npm install @curvefi/api`
|
|
8
|
+
|
|
9
|
+
## Init
|
|
10
|
+
```ts
|
|
11
|
+
import curve from "@curvefi/api";
|
|
12
|
+
|
|
13
|
+
(async () => {
|
|
14
|
+
// 1. Dev
|
|
15
|
+
await curve.init('JsonRpc', {url: 'http://localhost:8545/', privateKey: ''}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0, chainId: 1 });
|
|
16
|
+
// OR
|
|
17
|
+
await curve.init('JsonRpc', {}, { chainId: 1 }); // In this case fee data will be specified automatically
|
|
18
|
+
|
|
19
|
+
// 2. Infura
|
|
20
|
+
curve.init("Infura", { network: "homestead", apiKey: <INFURA_KEY> }, { chainId: 1 });
|
|
21
|
+
|
|
22
|
+
// 3. Web3 provider
|
|
23
|
+
curve.init('Web3', { externalProvider: <WEB3_PROVIDER> }, { chainId: 1 });
|
|
24
|
+
})()
|
|
25
|
+
```
|
|
26
|
+
**Note 1.** ```chainId``` parameter is optional, but you must specify it in the case you use Metamask on localhost network, because Metamask has that [bug](https://hardhat.org/metamask-issue.html)
|
|
27
|
+
|
|
28
|
+
**Note 2.** Web3 init requires the address. Therefore, it can be initialized only after receiving the address.
|
|
29
|
+
|
|
30
|
+
**Wrong ❌️**
|
|
31
|
+
```tsx
|
|
32
|
+
import type { FunctionComponent } from 'react'
|
|
33
|
+
import { useState, useMemo } from 'react'
|
|
34
|
+
import { providers } from 'ethers'
|
|
35
|
+
import Onboard from 'bnc-onboard'
|
|
36
|
+
import type { Wallet } from 'bnc-onboard/dist/src/interfaces'
|
|
37
|
+
import curve from '@curvefi/api'
|
|
38
|
+
|
|
39
|
+
...
|
|
40
|
+
|
|
41
|
+
const WalletProvider: FunctionComponent = ({ children }) => {
|
|
42
|
+
const [wallet, setWallet] = useState<Wallet>()
|
|
43
|
+
const [provider, setProvider] = useState<providers.Web3Provider>()
|
|
44
|
+
const [address, setAddress] = useState<string>()
|
|
45
|
+
|
|
46
|
+
const networkId = 1
|
|
47
|
+
|
|
48
|
+
const onboard = useMemo(
|
|
49
|
+
() =>
|
|
50
|
+
Onboard({
|
|
51
|
+
dappId: DAPP_ID,
|
|
52
|
+
networkId,
|
|
53
|
+
|
|
54
|
+
subscriptions: {
|
|
55
|
+
address: (address) => {
|
|
56
|
+
setAddress(address)
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
wallet: (wallet) => {
|
|
60
|
+
setWallet(wallet)
|
|
61
|
+
if (wallet.provider) {
|
|
62
|
+
curve.init("Web3", { externalProvider: wallet.provider }, { chainId: networkId })
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
walletSelect: {
|
|
67
|
+
wallets: wallets,
|
|
68
|
+
},
|
|
69
|
+
}),
|
|
70
|
+
[]
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
...
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Right ✔️**
|
|
77
|
+
```tsx
|
|
78
|
+
import type { FunctionComponent } from 'react'
|
|
79
|
+
import { useState, useMemo, useEffect } from 'react'
|
|
80
|
+
import { providers } from 'ethers'
|
|
81
|
+
import Onboard from 'bnc-onboard'
|
|
82
|
+
import type { Wallet } from 'bnc-onboard/dist/src/interfaces'
|
|
83
|
+
import curve from '@curvefi/api'
|
|
84
|
+
|
|
85
|
+
...
|
|
86
|
+
|
|
87
|
+
const WalletProvider: FunctionComponent = ({ children }) => {
|
|
88
|
+
const [wallet, setWallet] = useState<Wallet>()
|
|
89
|
+
const [provider, setProvider] = useState<providers.Web3Provider>()
|
|
90
|
+
const [address, setAddress] = useState<string>()
|
|
91
|
+
|
|
92
|
+
const networkId = 1
|
|
93
|
+
|
|
94
|
+
const onboard = useMemo(
|
|
95
|
+
() =>
|
|
96
|
+
Onboard({
|
|
97
|
+
dappId: DAPP_ID,
|
|
98
|
+
networkId,
|
|
99
|
+
|
|
100
|
+
subscriptions: {
|
|
101
|
+
address: (address) => {
|
|
102
|
+
setAddress(address)
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
wallet: (wallet) => {
|
|
106
|
+
setWallet(wallet)
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
walletSelect: {
|
|
110
|
+
wallets: wallets,
|
|
111
|
+
},
|
|
112
|
+
}),
|
|
113
|
+
[]
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (address && wallet?.provider) {
|
|
118
|
+
curve.init("Web3", { externalProvider: wallet.provider }, { chainId: networkId })
|
|
119
|
+
}
|
|
120
|
+
}, [address, wallet?.provider]);
|
|
121
|
+
|
|
122
|
+
...
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Balances
|
|
126
|
+
```ts
|
|
127
|
+
import curve from "@curvefi/api";
|
|
128
|
+
|
|
129
|
+
(async () => {
|
|
130
|
+
await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0, chainId: 1 });
|
|
131
|
+
|
|
132
|
+
console.log(await curve.getBalances(['DAI', 'sUSD']));
|
|
133
|
+
// OR console.log(await curve.getBalances(['0x6B175474E89094C44Da98b954EedeAC495271d0F', '0x57Ab1ec28D129707052df4dF418D58a2D46d5f51']));
|
|
134
|
+
|
|
135
|
+
// [ '10000.0', '10000.0' ]
|
|
136
|
+
|
|
137
|
+
console.log(await curve.getBalances(['aDAI', 'aSUSD']));
|
|
138
|
+
// OR console.log(await curve.getBalances(['0x028171bCA77440897B824Ca71D1c56caC55b68A3', '0x6c5024cd4f8a59110119c56f8933403a539555eb']));
|
|
139
|
+
|
|
140
|
+
// [ '10000.000211315200513239', '10000.0' ]
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
// --- Pool ---
|
|
144
|
+
|
|
145
|
+
const saave = new curve.Pool('saave');
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
// 1. Current address balances (signer balances)
|
|
149
|
+
|
|
150
|
+
console.log(await saave.balances());
|
|
151
|
+
// {
|
|
152
|
+
// lpToken: '0.0',
|
|
153
|
+
// gauge: '0.0',
|
|
154
|
+
// DAI: '10000.0',
|
|
155
|
+
// sUSD: '10000.0',
|
|
156
|
+
// aDAI: '10000.000211315200513239',
|
|
157
|
+
// aSUSD: '10000.0'
|
|
158
|
+
// }
|
|
159
|
+
|
|
160
|
+
console.log(await saave.lpTokenBalances());
|
|
161
|
+
// { lpToken: '0.0', gauge: '0.0' }
|
|
162
|
+
|
|
163
|
+
console.log(await saave.underlyingCoinBalances());
|
|
164
|
+
// { DAI: '10000.0', sUSD: '10000.0' }
|
|
165
|
+
|
|
166
|
+
console.log(await saave.coinBalances());
|
|
167
|
+
// { aDAI: '10000.000211315200513239', aSUSD: '10000.0' }
|
|
168
|
+
|
|
169
|
+
console.log(await saave.allCoinBalances());
|
|
170
|
+
// {
|
|
171
|
+
// DAI: '10000.0',
|
|
172
|
+
// sUSD: '10000.0',
|
|
173
|
+
// aDAI: '10000.000211315200513239',
|
|
174
|
+
// aSUSD: '10000.0'
|
|
175
|
+
// }
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
// 2. For every method above you can specify the address
|
|
179
|
+
|
|
180
|
+
console.log(await saave.balances("0x0063046686E46Dc6F15918b61AE2B121458534a5"));
|
|
181
|
+
// {
|
|
182
|
+
// lpToken: '0.0',
|
|
183
|
+
// gauge: '0.0',
|
|
184
|
+
// DAI: '0.0',
|
|
185
|
+
// sUSD: '0.0',
|
|
186
|
+
// aDAI: '0.0',
|
|
187
|
+
// aSUSD: '0.0'
|
|
188
|
+
// }
|
|
189
|
+
|
|
190
|
+
// Or several addresses
|
|
191
|
+
console.log(await saave.balances("0x0063046686E46Dc6F15918b61AE2B121458534a5", "0x66aB6D9362d4F35596279692F0251Db635165871"));
|
|
192
|
+
// {
|
|
193
|
+
// '0x0063046686E46Dc6F15918b61AE2B121458534a5': {
|
|
194
|
+
// lpToken: '0.0',
|
|
195
|
+
// gauge: '0.0',
|
|
196
|
+
// DAI: '0.0',
|
|
197
|
+
// sUSD: '0.0',
|
|
198
|
+
// aDAI: '0.0',
|
|
199
|
+
// aSUSD: '0.0'
|
|
200
|
+
// },
|
|
201
|
+
// '0x66aB6D9362d4F35596279692F0251Db635165871': {
|
|
202
|
+
// lpToken: '0.0',
|
|
203
|
+
// gauge: '0.0',
|
|
204
|
+
// DAI: '10000.0',
|
|
205
|
+
// sUSD: '10000.0',
|
|
206
|
+
// aDAI: '10000.000211315200513239',
|
|
207
|
+
// aSUSD: '10000.0'
|
|
208
|
+
// }
|
|
209
|
+
// }
|
|
210
|
+
|
|
211
|
+
})()
|
|
212
|
+
```
|
|
213
|
+
|
|
3
214
|
## Add/remove liquidity
|
|
4
215
|
|
|
5
216
|
```ts
|
|
6
|
-
import curve from "
|
|
217
|
+
import curve from "@curvefi/api";
|
|
7
218
|
|
|
8
219
|
(async () => {
|
|
9
|
-
await curve.init('JsonRpc', {
|
|
10
|
-
// OR await curve.init('JsonRpc', {}, { gasPrice: 0, chainId: 1 });
|
|
220
|
+
await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0, chainId: 1 });
|
|
11
221
|
|
|
12
222
|
const pool = new curve.Pool('aave');
|
|
13
223
|
console.log(pool.underlyingCoins); // [ 'DAI', 'USDC', 'USDT' ]
|
|
@@ -208,8 +418,10 @@ import curve from "curve";
|
|
|
208
418
|
## Exchange using all pools
|
|
209
419
|
|
|
210
420
|
```ts
|
|
421
|
+
import curve from "@curvefi/api";
|
|
422
|
+
|
|
211
423
|
(async () => {
|
|
212
|
-
await curve.init('JsonRpc', {}, { gasPrice: 0, chainId: 1 });
|
|
424
|
+
await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0, chainId: 1 });
|
|
213
425
|
|
|
214
426
|
console.log(await curve.getBalances(['DAI', 'USDC']));
|
|
215
427
|
// [ '1000.0', '0.0' ]
|
|
@@ -233,8 +445,10 @@ import curve from "curve";
|
|
|
233
445
|
## Cross-Asset Exchange
|
|
234
446
|
|
|
235
447
|
```ts
|
|
448
|
+
import curve from "@curvefi/api";
|
|
449
|
+
|
|
236
450
|
(async () => {
|
|
237
|
-
await curve.init('JsonRpc', {}, { gasPrice: 0, chainId: 1 });
|
|
451
|
+
await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0, chainId: 1 });
|
|
238
452
|
|
|
239
453
|
console.log(await curve.getBalances(['DAI', 'WBTC']));
|
|
240
454
|
// [ '1000.0', '0.0' ]
|
|
@@ -257,8 +471,10 @@ import curve from "curve";
|
|
|
257
471
|
|
|
258
472
|
## Boosting
|
|
259
473
|
```ts
|
|
260
|
-
|
|
261
|
-
|
|
474
|
+
import curve from "@curvefi/api";
|
|
475
|
+
|
|
476
|
+
(async () => {
|
|
477
|
+
await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0, chainId: 1 });
|
|
262
478
|
|
|
263
479
|
console.log(await curve.boosting.getCrv());
|
|
264
480
|
// 100000.0
|
|
@@ -286,5 +502,121 @@ const boostingTest = async () => {
|
|
|
286
502
|
// { lockedAmount: '1500.0', unlockTime: 1688601600000 }
|
|
287
503
|
// 746.262271689452535192 veCRV
|
|
288
504
|
// 0.000018613852077810 veCRV %
|
|
289
|
-
}
|
|
505
|
+
})()
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
## Allowance and approve
|
|
509
|
+
### General methods
|
|
510
|
+
```ts
|
|
511
|
+
const spender = "0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7" // 3pool swap address
|
|
512
|
+
|
|
513
|
+
await curve.getAllowance(["DAI", "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"], curve.signerAddress, spender)
|
|
514
|
+
// [ '0.0', '0.0' ]
|
|
515
|
+
await curve.hasAllowance(["DAI", "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"], ['1000', '1000'], curve.signerAddress, spender)
|
|
516
|
+
// false
|
|
517
|
+
await curve.ensureAllowance(["DAI", "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"], ['1000', '1000'], spender)
|
|
518
|
+
// [
|
|
519
|
+
// '0xb0cada2a2983dc0ed85a26916d32b9caefe45fecde47640bd7d0e214ff22aed3',
|
|
520
|
+
// '0x00ea7d827b3ad50ce933e96c579810cd7e70d66a034a86ec4e1e10005634d041'
|
|
521
|
+
// ]
|
|
522
|
+
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
### Pools
|
|
526
|
+
```ts
|
|
527
|
+
const pool = new curve.Pool('usdn');
|
|
528
|
+
|
|
529
|
+
// --- Add Liquidity ---
|
|
530
|
+
|
|
531
|
+
await pool.addLiquidityIsApproved(["1000", "1000", "1000", "1000"])
|
|
532
|
+
// false
|
|
533
|
+
await pool.addLiquidityApprove(["1000", "1000", "1000", "1000"])
|
|
534
|
+
// [
|
|
535
|
+
// '0xbac4b0271ad340488a8135dda2f9adf3e3c402361b514f483ba2b7e9cafbdc21',
|
|
536
|
+
// '0x39fe196a52d9fb649f9c099fbd40ae773d28c457195c878ecdb7cd05be0f6512',
|
|
537
|
+
// '0xf39ebfb4b11434b879f951a08a1c633a038425c35eae09b2b7015816d068de3c',
|
|
538
|
+
// '0xa8b1631384da247efe1987b56fe010b852fc1d38e4d71d204c7dc5448a3a6c96'
|
|
539
|
+
// ]
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
// --- Add Liquidity Wrapped ---
|
|
543
|
+
|
|
544
|
+
await pool.addLiquidityWrappedIsApproved(["1000", "1000"])
|
|
545
|
+
// false
|
|
546
|
+
await pool.addLiquidityWrappedApprove(["1000", "1000"])
|
|
547
|
+
// [
|
|
548
|
+
// '0xe486bfba5e9e8190be580ad528707876136e6b0c201e228db0f3bd82e51619fa',
|
|
549
|
+
// '0xd56f7d583b20f4f7760510cc4310e3651f7dab8c276fe3bcde7e7200d65ed0dd'
|
|
550
|
+
// ]
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
// --- Remove Liquidity ---
|
|
554
|
+
|
|
555
|
+
await pool.removeLiquidityIsApproved("1000")
|
|
556
|
+
await pool.removeLiquidityApprove("1000")
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
// --- Remove Liquidity Imbalance ---
|
|
560
|
+
|
|
561
|
+
await pool.removeLiquidityImbalanceIsApproved(["1000", "1000", "1000", "1000"])
|
|
562
|
+
await pool.removeLiquidityImbalanceApprove(["1000", "1000", "1000", "1000"])
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
// --- Remove Liquidity One Coin ---
|
|
566
|
+
|
|
567
|
+
await pool.removeLiquidityOneCoinIsApproved("1000")
|
|
568
|
+
await pool.removeLiquidityOneCoinApprove("1000")
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
// --- Gauge Deposit ---
|
|
572
|
+
|
|
573
|
+
await pool.gaugeDepositIsApproved("1000")
|
|
574
|
+
await pool.gaugeDepositApprove("1000")
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
// --- Exchange ---
|
|
578
|
+
|
|
579
|
+
await pool.exchangeIsApproved("DAI", "1000")
|
|
580
|
+
await pool.exchangeApprove("DAI", "1000")
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
// --- Exchange Wrapped ---
|
|
584
|
+
|
|
585
|
+
await pool.exchangeWrappedIsApproved("0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490", "1000")
|
|
586
|
+
await pool.exchangeWrappedApprove("0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490", "1000")
|
|
587
|
+
```
|
|
588
|
+
**Note.** Removing wrapped does not require approve.
|
|
589
|
+
|
|
590
|
+
### Exchange
|
|
591
|
+
```ts
|
|
592
|
+
// Straight
|
|
593
|
+
await curve.exchangeisApproved("DAI", "0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3", "1000"); // DAI -> MIM
|
|
594
|
+
await curve.exchangeApprove("DAI", "0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3", "1000"); // DAI -> MIM
|
|
595
|
+
|
|
596
|
+
// Cross-Asset
|
|
597
|
+
await curve.crossAssetExchangeIsApproved("DAI", "1000");
|
|
598
|
+
await curve.crossAssetExchangeApprove("DAI", "1000");
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
### Boosting
|
|
602
|
+
```ts
|
|
603
|
+
await curve.boosting.isApproved('1000')
|
|
604
|
+
await curve.boosting.approve('1000')
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
## Gas estimation
|
|
608
|
+
Every non-constant method has corresponding gas estimation method. Rule: ```obj.method -> obj.estimateGas.method```
|
|
609
|
+
|
|
610
|
+
**Examples**
|
|
611
|
+
```ts
|
|
612
|
+
const spender = "0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7" // 3pool swap address
|
|
613
|
+
await curve.estimateGas.ensureAllowance(["DAI", "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"], curve.signerAddress, spender);
|
|
614
|
+
|
|
615
|
+
const pool = new curve.Pool('usdn');
|
|
616
|
+
await pool.estimateGas.addLiquidityApprove(["1000", "1000", "1000", "1000"])
|
|
617
|
+
await pool.estimateGas.addLiquidity(["1000", "1000", "1000", "1000"])
|
|
618
|
+
|
|
619
|
+
await curve.estimateGas.crossAssetExchange('DAI', "WBTC", "1000", 0.01)
|
|
620
|
+
|
|
621
|
+
await curve.boosting.estimateGas.createLock('1000', 365)
|
|
290
622
|
```
|
package/lib/boosting.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export declare const getLockedAmountAndUnlockTime: (...addresses: string[] | str
|
|
|
9
9
|
}>;
|
|
10
10
|
export declare const getVeCrv: (...addresses: string[] | string[][]) => Promise<DictInterface<string> | string>;
|
|
11
11
|
export declare const getVeCrvPct: (...addresses: string[] | string[][]) => Promise<DictInterface<string> | string>;
|
|
12
|
+
export declare const isApproved: (amount: string) => Promise<boolean>;
|
|
13
|
+
export declare const approveEstimateGas: (amount: string) => Promise<number>;
|
|
14
|
+
export declare const approve: (amount: string) => Promise<string[]>;
|
|
12
15
|
export declare const createLockEstimateGas: (amount: string, days: number) => Promise<number>;
|
|
13
16
|
export declare const createLock: (amount: string, days: number) => Promise<string>;
|
|
14
17
|
export declare const increaseAmountEstimateGas: (amount: string) => Promise<number>;
|
package/lib/boosting.js
CHANGED
|
@@ -47,7 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.withdrawLockedCrv = exports.withdrawLockedCrvEstimateGas = exports.increaseUnlockTime = exports.increaseUnlockTimeEstimateGas = exports.increaseAmount = exports.increaseAmountEstimateGas = exports.createLock = exports.createLockEstimateGas = exports.getVeCrvPct = exports.getVeCrv = exports.getLockedAmountAndUnlockTime = exports.getCrv = void 0;
|
|
50
|
+
exports.withdrawLockedCrv = exports.withdrawLockedCrvEstimateGas = exports.increaseUnlockTime = exports.increaseUnlockTimeEstimateGas = exports.increaseAmount = exports.increaseAmountEstimateGas = exports.createLock = exports.createLockEstimateGas = exports.approve = exports.approveEstimateGas = exports.isApproved = exports.getVeCrvPct = exports.getVeCrv = exports.getLockedAmountAndUnlockTime = exports.getCrv = void 0;
|
|
51
51
|
var ethers_1 = require("ethers");
|
|
52
52
|
var utils_1 = require("./utils");
|
|
53
53
|
var utils_2 = require("./utils");
|
|
@@ -164,6 +164,33 @@ var getVeCrvPct = function () {
|
|
|
164
164
|
});
|
|
165
165
|
};
|
|
166
166
|
exports.getVeCrvPct = getVeCrvPct;
|
|
167
|
+
var isApproved = function (amount) { return __awaiter(void 0, void 0, void 0, function () {
|
|
168
|
+
return __generator(this, function (_a) {
|
|
169
|
+
switch (_a.label) {
|
|
170
|
+
case 0: return [4 /*yield*/, (0, utils_1.hasAllowance)([curve_1.ALIASES.crv], [amount], curve_1.curve.signerAddress, curve_1.ALIASES.voting_escrow)];
|
|
171
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}); };
|
|
175
|
+
exports.isApproved = isApproved;
|
|
176
|
+
var approveEstimateGas = function (amount) { return __awaiter(void 0, void 0, void 0, function () {
|
|
177
|
+
return __generator(this, function (_a) {
|
|
178
|
+
switch (_a.label) {
|
|
179
|
+
case 0: return [4 /*yield*/, (0, utils_1.ensureAllowanceEstimateGas)([curve_1.ALIASES.crv], [amount], curve_1.ALIASES.voting_escrow)];
|
|
180
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}); };
|
|
184
|
+
exports.approveEstimateGas = approveEstimateGas;
|
|
185
|
+
var approve = function (amount) { return __awaiter(void 0, void 0, void 0, function () {
|
|
186
|
+
return __generator(this, function (_a) {
|
|
187
|
+
switch (_a.label) {
|
|
188
|
+
case 0: return [4 /*yield*/, (0, utils_1.ensureAllowance)([curve_1.ALIASES.crv], [amount], curve_1.ALIASES.voting_escrow)];
|
|
189
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}); };
|
|
193
|
+
exports.approve = approve;
|
|
167
194
|
var createLockEstimateGas = function (amount, days) { return __awaiter(void 0, void 0, void 0, function () {
|
|
168
195
|
var crvBalance, _amount, unlockTime;
|
|
169
196
|
return __generator(this, function (_a) {
|
|
@@ -172,7 +199,7 @@ var createLockEstimateGas = function (amount, days) { return __awaiter(void 0, v
|
|
|
172
199
|
case 1:
|
|
173
200
|
crvBalance = _a.sent();
|
|
174
201
|
if (Number(crvBalance) < Number(amount)) {
|
|
175
|
-
throw Error("Not enough . Actual: "
|
|
202
|
+
throw Error("Not enough . Actual: ".concat(crvBalance, ", required: ").concat(amount));
|
|
176
203
|
}
|
|
177
204
|
return [4 /*yield*/, (0, utils_1.hasAllowance)([curve_1.ALIASES.crv], [amount], curve_1.curve.signerAddress, curve_1.ALIASES.voting_escrow)];
|
|
178
205
|
case 2:
|
|
@@ -218,7 +245,7 @@ var increaseAmountEstimateGas = function (amount) { return __awaiter(void 0, voi
|
|
|
218
245
|
case 1:
|
|
219
246
|
crvBalance = _a.sent();
|
|
220
247
|
if (Number(crvBalance) < Number(amount)) {
|
|
221
|
-
throw Error("Not enough. Actual: "
|
|
248
|
+
throw Error("Not enough. Actual: ".concat(crvBalance, ", required: ").concat(amount));
|
|
222
249
|
}
|
|
223
250
|
return [4 /*yield*/, (0, utils_1.hasAllowance)([curve_1.ALIASES.crv], [amount], curve_1.curve.signerAddress, curve_1.ALIASES.voting_escrow)];
|
|
224
251
|
case 2:
|
|
@@ -1414,12 +1414,12 @@ exports.poolsData = {
|
|
|
1414
1414
|
swap_address: '0xD51a44d3FaE010294C616388b506AcdA1bfAAE46',
|
|
1415
1415
|
token_address: '0xc4AD29ba4B3c580e6D59105FFf484999997675Ff',
|
|
1416
1416
|
gauge_address: '0xDeFd8FdD20e0f34115C7018CCfb655796F6B2168',
|
|
1417
|
-
underlying_coins: ['USDT', 'WBTC', '
|
|
1417
|
+
underlying_coins: ['USDT', 'WBTC', 'ETH'],
|
|
1418
1418
|
coins: ['USDT', 'WBTC', 'WETH'],
|
|
1419
1419
|
underlying_coin_addresses: [
|
|
1420
1420
|
'0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
|
1421
1421
|
'0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
|
|
1422
|
-
'
|
|
1422
|
+
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
1423
1423
|
],
|
|
1424
1424
|
coin_addresses: [
|
|
1425
1425
|
'0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
|
@@ -155,43 +155,6 @@
|
|
|
155
155
|
}
|
|
156
156
|
]
|
|
157
157
|
},
|
|
158
|
-
{
|
|
159
|
-
"stateMutability": "payable",
|
|
160
|
-
"type": "function",
|
|
161
|
-
"name": "exchange",
|
|
162
|
-
"inputs": [
|
|
163
|
-
{
|
|
164
|
-
"name": "_pool",
|
|
165
|
-
"type": "address"
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
"name": "_from",
|
|
169
|
-
"type": "address"
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
"name": "_to",
|
|
173
|
-
"type": "address"
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
"name": "_amount",
|
|
177
|
-
"type": "uint256"
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
"name": "_expected",
|
|
181
|
-
"type": "uint256"
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
"name": "_receiver",
|
|
185
|
-
"type": "address"
|
|
186
|
-
}
|
|
187
|
-
],
|
|
188
|
-
"outputs": [
|
|
189
|
-
{
|
|
190
|
-
"name": "",
|
|
191
|
-
"type": "uint256"
|
|
192
|
-
}
|
|
193
|
-
]
|
|
194
|
-
},
|
|
195
158
|
{
|
|
196
159
|
"stateMutability": "view",
|
|
197
160
|
"type": "function",
|
|
@@ -35,52 +35,6 @@
|
|
|
35
35
|
}
|
|
36
36
|
]
|
|
37
37
|
},
|
|
38
|
-
{
|
|
39
|
-
"stateMutability": "payable",
|
|
40
|
-
"type": "function",
|
|
41
|
-
"name": "add_liquidity",
|
|
42
|
-
"inputs": [
|
|
43
|
-
{
|
|
44
|
-
"name": "_amounts",
|
|
45
|
-
"type": "uint256[3]"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"name": "_min_mint_amount",
|
|
49
|
-
"type": "uint256"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"name": "_receiver",
|
|
53
|
-
"type": "address"
|
|
54
|
-
}
|
|
55
|
-
],
|
|
56
|
-
"outputs": [
|
|
57
|
-
{
|
|
58
|
-
"name": "",
|
|
59
|
-
"type": "uint256"
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"stateMutability": "nonpayable",
|
|
65
|
-
"type": "function",
|
|
66
|
-
"name": "remove_liquidity",
|
|
67
|
-
"inputs": [
|
|
68
|
-
{
|
|
69
|
-
"name": "_amount",
|
|
70
|
-
"type": "uint256"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
"name": "_min_amounts",
|
|
74
|
-
"type": "uint256[3]"
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
"outputs": [
|
|
78
|
-
{
|
|
79
|
-
"name": "",
|
|
80
|
-
"type": "uint256[3]"
|
|
81
|
-
}
|
|
82
|
-
]
|
|
83
|
-
},
|
|
84
38
|
{
|
|
85
39
|
"stateMutability": "nonpayable",
|
|
86
40
|
"type": "function",
|
|
@@ -93,10 +47,6 @@
|
|
|
93
47
|
{
|
|
94
48
|
"name": "_min_amounts",
|
|
95
49
|
"type": "uint256[3]"
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"name": "_receiver",
|
|
99
|
-
"type": "address"
|
|
100
50
|
}
|
|
101
51
|
],
|
|
102
52
|
"outputs": [
|
|
@@ -131,35 +81,6 @@
|
|
|
131
81
|
}
|
|
132
82
|
]
|
|
133
83
|
},
|
|
134
|
-
{
|
|
135
|
-
"stateMutability": "nonpayable",
|
|
136
|
-
"type": "function",
|
|
137
|
-
"name": "remove_liquidity_one_coin",
|
|
138
|
-
"inputs": [
|
|
139
|
-
{
|
|
140
|
-
"name": "_token_amount",
|
|
141
|
-
"type": "uint256"
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
"name": "i",
|
|
145
|
-
"type": "uint256"
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
"name": "_min_amount",
|
|
149
|
-
"type": "uint256"
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
"name": "_receiver",
|
|
153
|
-
"type": "address"
|
|
154
|
-
}
|
|
155
|
-
],
|
|
156
|
-
"outputs": [
|
|
157
|
-
{
|
|
158
|
-
"name": "",
|
|
159
|
-
"type": "uint256"
|
|
160
|
-
}
|
|
161
|
-
]
|
|
162
|
-
},
|
|
163
84
|
{
|
|
164
85
|
"stateMutability": "view",
|
|
165
86
|
"type": "function",
|
package/lib/curve.d.ts
CHANGED