@curvefi/api 1.15.1 → 1.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -717,3 +717,64 @@ console.log(await pool.gaugeClaimableRewards());
717
717
  // ]
718
718
  await pool.gaugeClaimRewards();
719
719
  ```
720
+
721
+ ## Deposit&Stake
722
+ Add liquidity and deposit into gauge in one transaction.
723
+
724
+ ### Underlying
725
+ ```ts
726
+ (async () => {
727
+ const pool = new curve.Pool('compound');
728
+ const amounts = ['1000', '1000'];
729
+
730
+ console.log(await pool.underlyingCoinBalances());
731
+ // { DAI: '10000.0', USDC: '10000.0' }
732
+ console.log(await pool.lpTokenBalances());
733
+ // { lpToken: '0.0', gauge: '0.0' }
734
+
735
+ console.log(await pool.depositAndStakeExpected(amounts));
736
+ // 1820.604572902286288394
737
+ console.log(await pool.depositAndStakeSlippage(amounts));
738
+ // -0.0000036435051742755193
739
+
740
+ console.log(await pool.depositAndStakeIsApproved(amounts));
741
+ // false
742
+
743
+ await pool.depositAndStakeApprove(amounts);
744
+ await pool.depositAndStake(amounts);
745
+
746
+ console.log(await pool.underlyingCoinBalances());
747
+ // { DAI: '9000.0', USDC: '9000.0' }
748
+ console.log(await pool.lpTokenBalances());
749
+ // { lpToken: '0.0', gauge: '1820.556829935710883568' }
750
+ })();
751
+ ```
752
+
753
+ ### Wrapped
754
+ ```ts
755
+ (async () => {
756
+ const pool = new curve.Pool('compound');
757
+ const amounts = ['1000', '1000'];
758
+
759
+ console.log(await pool.coinBalances());
760
+ // { cDAI: '10000.0', cUSDC: '10000.0' }
761
+ console.log(await pool.lpTokenBalances());
762
+ // { lpToken: '0.0', gauge: '1820.556829935710883568' }
763
+
764
+ console.log(await pool.depositAndStakeWrappedExpected(amounts));
765
+ // 40.328408669183101673
766
+ console.log(await pool.depositAndStakeWrappedSlippage(amounts));
767
+ // -0.0020519915272297325
768
+
769
+ console.log(await pool.depositAndStakeWrappedIsApproved(amounts));
770
+ // false
771
+
772
+ await pool.depositAndStakeWrappedApprove(amounts);
773
+ await pool.depositAndStakeWrapped(amounts);
774
+
775
+ console.log(await pool.coinBalances());
776
+ // { cDAI: '9000.0', cUSDC: '9000.0' }
777
+ console.log(await pool.lpTokenBalances());
778
+ // { lpToken: '0.0', gauge: '1860.884096082215274556' }
779
+ })();
780
+ ```
@@ -1649,4 +1649,99 @@ exports.POOLS_DATA_ETHEREUM = {
1649
1649
  ],
1650
1650
  gauge_abi: gauge_v4_json_1.default,
1651
1651
  },
1652
+ xautusd: {
1653
+ reference_asset: 'CRYPTO',
1654
+ N_COINS: 2,
1655
+ underlying_decimals: [6, 18],
1656
+ decimals: [6, 18],
1657
+ tethered: [false, false],
1658
+ use_lending: [false, false],
1659
+ is_plain: [true, true],
1660
+ swap_address: '0xAdCFcf9894335dC340f6Cd182aFA45999F45Fc44',
1661
+ token_address: '0x8484673cA7BfF40F82B041916881aeA15ee84834',
1662
+ gauge_address: '0x1B3E14157ED33F60668f2103bCd5Db39a1573E5B',
1663
+ is_crypto: true,
1664
+ base_pool: '3pool',
1665
+ underlying_coins: ['XAUt', 'DAI', 'USDC', 'USDT'],
1666
+ coins: ['XAUt', '3Crv'],
1667
+ underlying_coin_addresses: [
1668
+ '0x68749665ff8d2d112fa859aa293f07a622782f38',
1669
+ '0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490',
1670
+ ],
1671
+ coin_addresses: [
1672
+ '0x68749665ff8d2d112fa859aa293f07a622782f38',
1673
+ '0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490',
1674
+ ],
1675
+ swap_abi: swap_json_36.default,
1676
+ deposit_abi: deposit_json_22.default,
1677
+ deposit_address: '0xc5FA220347375ac4f91f9E4A4AAb362F22801504',
1678
+ is_meta: true,
1679
+ meta_N: 5,
1680
+ meta_decimals: [6, 18, 18, 6, 6],
1681
+ meta_coin_decimals: [6, 18, 6, 6],
1682
+ meta_wrapped_decimals: [6, 18],
1683
+ meta_coin_addresses: [
1684
+ '0x6B175474E89094C44Da98b954EedeAC495271d0F',
1685
+ '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
1686
+ '0xdAC17F958D2ee523a2206206994597C13D831ec7',
1687
+ ],
1688
+ all_coin_addresses: [
1689
+ '0x68749665ff8d2d112fa859aa293f07a622782f38',
1690
+ '0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490',
1691
+ '0x6B175474E89094C44Da98b954EedeAC495271d0F',
1692
+ '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
1693
+ '0xdAC17F958D2ee523a2206206994597C13D831ec7',
1694
+ ],
1695
+ gauge_abi: gauge_v4_json_1.default,
1696
+ },
1697
+ spelleth: {
1698
+ reference_asset: 'CRYPTO',
1699
+ N_COINS: 2,
1700
+ is_crypto: true,
1701
+ underlying_decimals: [18, 18],
1702
+ decimals: [18, 18],
1703
+ tethered: [false, false],
1704
+ use_lending: [false, false],
1705
+ is_plain: [true, true],
1706
+ swap_address: '0x98638FAcf9a3865cd033F36548713183f6996122',
1707
+ token_address: '0x8282BD15dcA2EA2bDf24163E8f2781B30C43A2ef',
1708
+ gauge_address: '0x08380a4999Be1a958E2abbA07968d703C7A3027C',
1709
+ underlying_coins: ['ETH', 'SPELL'],
1710
+ coins: ['WETH', 'SPELL'],
1711
+ underlying_coin_addresses: [
1712
+ '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
1713
+ '0x090185f2135308bad17527004364ebcc2d37e5f6',
1714
+ ],
1715
+ coin_addresses: [
1716
+ '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
1717
+ '0x090185f2135308bad17527004364ebcc2d37e5f6',
1718
+ ],
1719
+ swap_abi: swap_json_37.default,
1720
+ gauge_abi: gauge_v4_json_1.default,
1721
+ },
1722
+ teth: {
1723
+ reference_asset: 'CRYPTO',
1724
+ N_COINS: 2,
1725
+ is_crypto: true,
1726
+ underlying_decimals: [18, 18],
1727
+ decimals: [18, 18],
1728
+ tethered: [false, false],
1729
+ use_lending: [false, false],
1730
+ is_plain: [true, true],
1731
+ swap_address: '0x752eBeb79963cf0732E9c0fec72a49FD1DEfAEAC',
1732
+ token_address: '0xCb08717451aaE9EF950a2524E33B6DCaBA60147B',
1733
+ gauge_address: '0x6070fBD4E608ee5391189E7205d70cc4A274c017',
1734
+ underlying_coins: ['ETH', 'T'],
1735
+ coins: ['WETH', 'T'],
1736
+ underlying_coin_addresses: [
1737
+ '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
1738
+ '0xCdF7028ceAB81fA0C6971208e83fa7872994beE5',
1739
+ ],
1740
+ coin_addresses: [
1741
+ '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
1742
+ '0xCdF7028ceAB81fA0C6971208e83fa7872994beE5',
1743
+ ],
1744
+ swap_abi: swap_json_37.default,
1745
+ gauge_abi: gauge_v4_json_1.default,
1746
+ },
1652
1747
  };
@@ -0,0 +1,51 @@
1
+ [
2
+ {
3
+ "stateMutability": "payable",
4
+ "type": "function",
5
+ "name": "deposit_and_stake",
6
+ "inputs": [
7
+ {
8
+ "name": "deposit",
9
+ "type": "address"
10
+ },
11
+ {
12
+ "name": "lp_token",
13
+ "type": "address"
14
+ },
15
+ {
16
+ "name": "gauge",
17
+ "type": "address"
18
+ },
19
+ {
20
+ "name": "n_coins",
21
+ "type": "uint256"
22
+ },
23
+ {
24
+ "name": "coins",
25
+ "type": "address[5]"
26
+ },
27
+ {
28
+ "name": "amounts",
29
+ "type": "uint256[5]"
30
+ },
31
+ {
32
+ "name": "min_mint_amount",
33
+ "type": "uint256"
34
+ },
35
+ {
36
+ "name": "use_underlying",
37
+ "type": "bool"
38
+ },
39
+ {
40
+ "name": "pool",
41
+ "type": "address"
42
+ }
43
+ ],
44
+ "outputs": [],
45
+ "gas": "409532"
46
+ },
47
+ {
48
+ "stateMutability": "payable",
49
+ "type": "fallback"
50
+ }
51
+ ]
@@ -5,6 +5,7 @@ export declare const ALIASES_ETHEREUM: {
5
5
  gauge_controller: string;
6
6
  address_provider: string;
7
7
  router: string;
8
+ deposit_and_stake: string;
8
9
  registry_exchange: string;
9
10
  };
10
11
  export declare const ALIASES_POLYGON: {
@@ -14,5 +15,6 @@ export declare const ALIASES_POLYGON: {
14
15
  gauge_controller: string;
15
16
  address_provider: string;
16
17
  router: string;
18
+ deposit_and_stake: string;
17
19
  registry_exchange: string;
18
20
  };
@@ -8,6 +8,7 @@ exports.ALIASES_ETHEREUM = {
8
8
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
9
9
  "address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
10
10
  "router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
11
+ "deposit_and_stake": "0x271fbE8aB7f1fB262f81C77Ea5303F03DA9d3d6A",
11
12
  "registry_exchange": "",
12
13
  };
13
14
  exports.ALIASES_POLYGON = {
@@ -17,5 +18,6 @@ exports.ALIASES_POLYGON = {
17
18
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
18
19
  "address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
19
20
  "router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
21
+ "deposit_and_stake": "0x43FF7b96808988C9d19C1d05Ef19658B03e8a143",
20
22
  "registry_exchange": "",
21
23
  };
@@ -31,7 +31,8 @@ exports.ETH_COINS_ETHEREUM = {
31
31
  ankreth: "0xE95A203B1a91a908F9B9CE46459d101078c2c3cb",
32
32
  seth: "0x5e74c9036fb86bd7ecdcb084a0673efc32ea31cb",
33
33
  reth: "0x9559aaa82d9649c7a7b220e7c461d2e74c9a3593",
34
- weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
34
+ weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
35
+ xaut: "0x68749665ff8d2d112fa859aa293f07a622782f38", // XAUt TODO move to GOLD
35
36
  };
36
37
  // @ts-ignore
37
38
  exports.ETH_COINS_LOWER_CASE_ETHEREUM = Object.fromEntries(Object.entries(exports.ETH_COINS_ETHEREUM).map(function (entry) { return [entry[0], entry[1].toLowerCase()]; }));
@@ -95,7 +96,7 @@ exports.USD_COINS_ETHEREUM = {
95
96
  };
96
97
  // @ts-ignore
97
98
  exports.USD_COINS_LOWER_CASE_ETHEREUM = Object.fromEntries(Object.entries(exports.USD_COINS_ETHEREUM).map(function (entry) { return [entry[0], entry[1].toLowerCase()]; }));
98
- exports.COINS_ETHEREUM = __assign(__assign(__assign(__assign(__assign(__assign({}, exports.BTC_COINS_ETHEREUM), exports.ETH_COINS_ETHEREUM), exports.LINK_COINS_ETHEREUM), exports.EUR_COINS_ETHEREUM), exports.USD_COINS_ETHEREUM), { snx: "0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f" });
99
+ exports.COINS_ETHEREUM = __assign(__assign(__assign(__assign(__assign(__assign({}, exports.BTC_COINS_ETHEREUM), exports.ETH_COINS_ETHEREUM), exports.LINK_COINS_ETHEREUM), exports.EUR_COINS_ETHEREUM), exports.USD_COINS_ETHEREUM), { snx: "0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f", spell: "0x090185f2135308bad17527004364ebcc2d37e5f6", t: "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5" });
99
100
  exports.DECIMALS_ETHEREUM = {
100
101
  "0x075b1bb99792c9E1041bA13afEf80C91a1e70fB3": 18,
101
102
  "0x0316EB71485b0Ab14103307bf65a021042c6d380": 18,
@@ -160,7 +161,10 @@ exports.DECIMALS_ETHEREUM = {
160
161
  "0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3": 18,
161
162
  "0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490": 18,
162
163
  "0xD533a949740bb3306d119CC777fa900bA034cd52": 18,
163
- "0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b": 18, // CVX
164
+ "0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b": 18,
165
+ "0x68749665ff8d2d112fa859aa293f07a622782f38": 6,
166
+ "0x090185f2135308bad17527004364ebcc2d37e5f6": 18,
167
+ "0xCdF7028ceAB81fA0C6971208e83fa7872994beE5": 18, // T
164
168
  };
165
169
  // @ts-ignore
166
170
  exports.DECIMALS_LOWER_CASE_ETHEREUM = Object.fromEntries(Object.entries(exports.DECIMALS_ETHEREUM).map(function (entry) { return [entry[0].toLowerCase(), entry[1]]; }));
package/lib/curve.d.ts CHANGED
@@ -27,6 +27,7 @@ export declare let ALIASES: {
27
27
  gauge_controller: string;
28
28
  address_provider: string;
29
29
  router: string;
30
+ deposit_and_stake: string;
30
31
  registry_exchange: string;
31
32
  };
32
33
  declare class Curve {
package/lib/curve.js CHANGED
@@ -70,6 +70,7 @@ var votingescrow_json_1 = __importDefault(require("./constants/abis/json/votinge
70
70
  var address_provider_json_1 = __importDefault(require("./constants/abis/json/address_provider.json"));
71
71
  var gaugecontroller_json_1 = __importDefault(require("./constants/abis/json/gaugecontroller.json"));
72
72
  var router_json_1 = __importDefault(require("./constants/abis/json/router.json"));
73
+ var deposit_and_stake_json_1 = __importDefault(require("./constants/abis/json/deposit_and_stake.json"));
73
74
  var registry_exchange_json_1 = __importDefault(require("./constants/abis/json/registry_exchange.json"));
74
75
  var streamer_json_1 = __importDefault(require("./constants/abis/json/streamer.json"));
75
76
  var abis_ethereum_1 = require("./constants/abis/abis-ethereum");
@@ -84,6 +85,7 @@ exports.ALIASES = {
84
85
  "gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
85
86
  "address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
86
87
  "router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
88
+ "deposit_and_stake": "0x271fbE8aB7f1fB262f81C77Ea5303F03DA9d3d6A",
87
89
  "registry_exchange": "",
88
90
  };
89
91
  var Curve = /** @class */ (function () {
@@ -399,6 +401,14 @@ var Curve = /** @class */ (function () {
399
401
  contract: new ethers_1.Contract(exports.ALIASES.router, router_json_1.default, this.signer || this.provider),
400
402
  multicallContract: new ethcall_1.Contract(exports.ALIASES.router, router_json_1.default),
401
403
  };
404
+ this.contracts[exports.ALIASES.deposit_and_stake] = {
405
+ contract: new ethers_1.Contract(exports.ALIASES.deposit_and_stake, deposit_and_stake_json_1.default, this.signer || this.provider),
406
+ multicallContract: new ethcall_1.Contract(exports.ALIASES.deposit_and_stake, deposit_and_stake_json_1.default),
407
+ };
408
+ this.contracts[exports.ALIASES.deposit_and_stake.toLowerCase()] = {
409
+ contract: new ethers_1.Contract(exports.ALIASES.deposit_and_stake, deposit_and_stake_json_1.default, this.signer || this.provider),
410
+ multicallContract: new ethcall_1.Contract(exports.ALIASES.deposit_and_stake, deposit_and_stake_json_1.default),
411
+ };
402
412
  return [2 /*return*/];
403
413
  }
404
414
  });
package/lib/pools.d.ts CHANGED
@@ -25,8 +25,12 @@ export declare class Pool {
25
25
  estimateGas: {
26
26
  addLiquidityApprove: (amounts: string[]) => Promise<number>;
27
27
  addLiquidity: (amounts: string[]) => Promise<number>;
28
+ depositAndStakeApprove: (amounts: string[]) => Promise<number>;
29
+ depositAndStake: (amounts: string[]) => Promise<number>;
28
30
  addLiquidityWrappedApprove: (amounts: string[]) => Promise<number>;
29
31
  addLiquidityWrapped: (amounts: string[]) => Promise<number>;
32
+ depositAndStakeWrappedApprove: (amounts: string[]) => Promise<number>;
33
+ depositAndStakeWrapped: (amounts: string[]) => Promise<number>;
30
34
  gaugeDepositApprove: (lpTokenAmount: string) => Promise<number>;
31
35
  gaugeDeposit: (lpTokenAmount: string) => Promise<number>;
32
36
  gaugeWithdraw: (lpTokenAmount: string) => Promise<number>;
@@ -84,6 +88,14 @@ export declare class Pool {
84
88
  private addLiquidityEstimateGas;
85
89
  balancedAmounts: () => Promise<string[]>;
86
90
  addLiquidity: (amounts: string[]) => Promise<string>;
91
+ depositAndStakeExpected: (amounts: string[]) => Promise<string>;
92
+ depositAndStakeSlippage: (amounts: string[]) => Promise<string>;
93
+ depositAndStakeIsApproved: (amounts: string[]) => Promise<boolean>;
94
+ private depositAndStakeApproveEstimateGas;
95
+ depositAndStakeApprove: (amounts: string[]) => Promise<string[]>;
96
+ private depositAndStakeEstimateGas;
97
+ depositAndStake: (amounts: string[]) => Promise<string>;
98
+ private _depositAndStake;
87
99
  balancedWrappedAmounts: () => Promise<string[]>;
88
100
  addLiquidityWrappedExpected: (amounts: string[]) => Promise<string>;
89
101
  addLiquidityWrappedSlippage: (amounts: string[]) => Promise<string>;
@@ -92,6 +104,13 @@ export declare class Pool {
92
104
  addLiquidityWrappedApprove: (amounts: string[]) => Promise<string[]>;
93
105
  private addLiquidityWrappedEstimateGas;
94
106
  addLiquidityWrapped: (amounts: string[]) => Promise<string>;
107
+ depositAndStakeWrappedExpected: (amounts: string[]) => Promise<string>;
108
+ depositAndStakeWrappedSlippage: (amounts: string[]) => Promise<string>;
109
+ depositAndStakeWrappedIsApproved: (amounts: string[]) => Promise<boolean>;
110
+ private depositAndStakeWrappedApproveEstimateGas;
111
+ depositAndStakeWrappedApprove: (amounts: string[]) => Promise<string[]>;
112
+ private depositAndStakeWrappedEstimateGas;
113
+ depositAndStakeWrapped: (amounts: string[]) => Promise<string>;
95
114
  removeLiquidityExpected: (lpTokenAmount: string) => Promise<string[]>;
96
115
  removeLiquidityIsApproved: (lpTokenAmount: string) => Promise<boolean>;
97
116
  private removeLiquidityApproveEstimateGas;
@@ -161,7 +180,11 @@ export declare class Pool {
161
180
  private _getCoinIdx;
162
181
  private _getRates;
163
182
  private _balances;
183
+ private _underlyingPrices;
184
+ private _wrappedPrices;
185
+ private _addLiquidityCryptoSlippage;
164
186
  private _addLiquiditySlippage;
187
+ private _removeLiquidityCryptoSlippage;
165
188
  private _removeLiquiditySlippage;
166
189
  private _balancedAmounts;
167
190
  private _calcLpTokenAmount;