@curvefi/api 2.31.1 → 2.33.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.
Files changed (62) hide show
  1. package/lib/boosting.js +385 -135
  2. package/lib/constants/abis/stable_calc.json +151 -0
  3. package/lib/constants/abis/wbeth/swap.json +1086 -0
  4. package/lib/constants/aliases.js +33 -11
  5. package/lib/constants/coins/arbitrum.js +5 -5
  6. package/lib/constants/coins/aurora.js +5 -5
  7. package/lib/constants/coins/avalanche.js +6 -6
  8. package/lib/constants/coins/celo.js +5 -5
  9. package/lib/constants/coins/ethereum.js +10 -9
  10. package/lib/constants/coins/fantom.js +7 -7
  11. package/lib/constants/coins/kava.js +5 -5
  12. package/lib/constants/coins/moonbeam.js +5 -5
  13. package/lib/constants/coins/optimism.js +5 -5
  14. package/lib/constants/coins/polygon.js +6 -6
  15. package/lib/constants/coins/xdai.js +5 -5
  16. package/lib/constants/pools/arbitrum.js +1 -1
  17. package/lib/constants/pools/aurora.js +1 -1
  18. package/lib/constants/pools/avalanche.js +1 -1
  19. package/lib/constants/pools/celo.js +1 -1
  20. package/lib/constants/pools/ethereum.js +26 -1
  21. package/lib/constants/pools/fantom.js +1 -1
  22. package/lib/constants/pools/kava.js +1 -1
  23. package/lib/constants/pools/moonbeam.js +1 -1
  24. package/lib/constants/pools/optimism.js +1 -1
  25. package/lib/constants/pools/polygon.js +1 -1
  26. package/lib/constants/pools/xdai.js +1 -1
  27. package/lib/constants/utils.d.ts +1 -1
  28. package/lib/constants/utils.js +19 -18
  29. package/lib/curve.js +507 -281
  30. package/lib/external-api.js +132 -45
  31. package/lib/factory/common.js +3 -3
  32. package/lib/factory/constants-crypto.js +21 -21
  33. package/lib/factory/constants.js +32 -31
  34. package/lib/factory/deploy.js +336 -176
  35. package/lib/factory/factory-api.js +256 -180
  36. package/lib/factory/factory-crypto.js +309 -163
  37. package/lib/factory/factory.d.ts +1 -1
  38. package/lib/factory/factory.js +336 -186
  39. package/lib/index.js +98 -44
  40. package/lib/interfaces.d.ts +1 -1
  41. package/lib/pools/PoolTemplate.js +2882 -1511
  42. package/lib/pools/mixins/common.js +106 -22
  43. package/lib/pools/mixins/depositBalancedAmountsMixins.js +131 -48
  44. package/lib/pools/mixins/depositMixins.js +413 -144
  45. package/lib/pools/mixins/depositWrappedMixins.js +223 -72
  46. package/lib/pools/mixins/poolBalancesMixin.js +98 -22
  47. package/lib/pools/mixins/swapMixins.js +347 -125
  48. package/lib/pools/mixins/swapWrappedMixins.js +270 -88
  49. package/lib/pools/mixins/withdrawExpectedMixins.js +104 -23
  50. package/lib/pools/mixins/withdrawImbalanceMixins.js +316 -97
  51. package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +187 -51
  52. package/lib/pools/mixins/withdrawMixins.js +385 -122
  53. package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +88 -16
  54. package/lib/pools/mixins/withdrawOneCoinMixins.js +386 -123
  55. package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +62 -8
  56. package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +185 -53
  57. package/lib/pools/mixins/withdrawWrappedMixins.js +185 -50
  58. package/lib/pools/poolConstructor.js +25 -5
  59. package/lib/pools/utils.js +488 -298
  60. package/lib/router.js +636 -378
  61. package/lib/utils.js +675 -354
  62. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1,3 +1,39 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
1
37
  import { PoolTemplate, getPool } from "./pools/index.js";
2
38
  import { getUserPoolListByLiquidity, getUserPoolListByClaimable, getUserPoolList, getUserLiquidityUSD, getUserClaimable, } from "./pools/utils.js";
3
39
  import { getBestRouteAndOutput, swapExpected, swapPriceImpact, swapIsApproved, swapApproveEstimateGas, swapApprove, swapEstimateGas, swap, getSwappedAmount, } from "./router.js";
@@ -5,44 +41,56 @@ import { curve as _curve } from "./curve.js";
5
41
  import { getCrv, getLockedAmountAndUnlockTime, getVeCrv, getVeCrvPct, calcUnlockTime, createLockEstimateGas, createLock, isApproved, approveEstimateGas, approve, increaseAmountEstimateGas, increaseAmount, increaseUnlockTimeEstimateGas, increaseUnlockTime, withdrawLockedCrvEstimateGas, withdrawLockedCrv, claimableFees, claimFeesEstimateGas, claimFees, } from "./boosting.js";
6
42
  import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, getUsdRate, getTVL, getCoinsData, getVolume, } from "./utils.js";
7
43
  import { deployStablePlainPool, deployStablePlainPoolEstimateGas, deployStableMetaPool, deployStableMetaPoolEstimateGas, deployCryptoPool, deployCryptoPoolEstimateGas, deployGauge, deployGaugeEstimateGas, getDeployedStablePlainPoolAddress, getDeployedStableMetaPoolAddress, getDeployedCryptoPoolAddress, getDeployedGaugeAddress, } from './factory/deploy.js';
8
- async function init(providerType, providerSettings, options = {}) {
9
- await _curve.init(providerType, providerSettings, options);
10
- // @ts-ignore
11
- this.signerAddress = _curve.signerAddress;
12
- // @ts-ignore
13
- this.chainId = _curve.chainId;
44
+ function init(providerType, providerSettings, options) {
45
+ if (options === void 0) { options = {}; }
46
+ return __awaiter(this, void 0, void 0, function () {
47
+ return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0: return [4 /*yield*/, _curve.init(providerType, providerSettings, options)];
50
+ case 1:
51
+ _a.sent();
52
+ // @ts-ignore
53
+ this.signerAddress = _curve.signerAddress;
54
+ // @ts-ignore
55
+ this.chainId = _curve.chainId;
56
+ return [2 /*return*/];
57
+ }
58
+ });
59
+ });
14
60
  }
15
61
  function setCustomFeeData(customFeeData) {
16
62
  _curve.setCustomFeeData(customFeeData);
17
63
  }
18
- const curve = {
19
- init,
64
+ var curve = {
65
+ init: init,
20
66
  chainId: 0,
21
67
  signerAddress: '',
22
- setCustomFeeData,
68
+ setCustomFeeData: setCustomFeeData,
23
69
  getPoolList: _curve.getPoolList,
24
- getUserPoolListByLiquidity,
25
- getUserPoolListByClaimable,
26
- getUserPoolList,
27
- getUserLiquidityUSD,
28
- getUserClaimable,
29
- PoolTemplate,
30
- getPool,
31
- getUsdRate,
32
- getTVL,
33
- getBalances,
34
- getAllowance,
35
- hasAllowance,
36
- ensureAllowance,
37
- getCoinsData,
38
- getVolume,
70
+ getUserPoolListByLiquidity: getUserPoolListByLiquidity,
71
+ getUserPoolListByClaimable: getUserPoolListByClaimable,
72
+ getUserPoolList: getUserPoolList,
73
+ getUserLiquidityUSD: getUserLiquidityUSD,
74
+ getUserClaimable: getUserClaimable,
75
+ PoolTemplate: PoolTemplate,
76
+ getPool: getPool,
77
+ getUsdRate: getUsdRate,
78
+ getTVL: getTVL,
79
+ getBalances: getBalances,
80
+ getAllowance: getAllowance,
81
+ hasAllowance: hasAllowance,
82
+ ensureAllowance: ensureAllowance,
83
+ getCoinsData: getCoinsData,
84
+ getVolume: getVolume,
39
85
  factory: {
40
86
  fetchPools: _curve.fetchFactoryPools,
41
87
  fetchNewPools: _curve.fetchNewFactoryPools,
42
88
  getPoolList: _curve.getFactoryPoolList,
43
89
  deployPlainPool: deployStablePlainPool,
44
90
  deployMetaPool: deployStableMetaPool,
45
- deployGauge: async (poolAddress) => deployGauge(poolAddress, false),
91
+ deployGauge: function (poolAddress) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
92
+ return [2 /*return*/, deployGauge(poolAddress, false)];
93
+ }); }); },
46
94
  getDeployedPlainPoolAddress: getDeployedStablePlainPoolAddress,
47
95
  getDeployedMetaPoolAddress: getDeployedStableMetaPoolAddress,
48
96
  getDeployedGaugeAddress: getDeployedGaugeAddress,
@@ -50,7 +98,9 @@ const curve = {
50
98
  estimateGas: {
51
99
  deployPlainPool: deployStablePlainPoolEstimateGas,
52
100
  deployMetaPool: deployStableMetaPoolEstimateGas,
53
- deployGauge: async (poolAddress) => deployGaugeEstimateGas(poolAddress, false),
101
+ deployGauge: function (poolAddress) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
102
+ return [2 /*return*/, deployGaugeEstimateGas(poolAddress, false)];
103
+ }); }); },
54
104
  },
55
105
  },
56
106
  cryptoFactory: {
@@ -58,33 +108,37 @@ const curve = {
58
108
  fetchNewPools: _curve.fetchNewCryptoFactoryPools,
59
109
  getPoolList: _curve.getCryptoFactoryPoolList,
60
110
  deployPool: deployCryptoPool,
61
- deployGauge: async (poolAddress) => deployGauge(poolAddress, true),
111
+ deployGauge: function (poolAddress) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
112
+ return [2 /*return*/, deployGauge(poolAddress, true)];
113
+ }); }); },
62
114
  getDeployed: getDeployedStablePlainPoolAddress,
63
115
  getDeployedPoolAddress: getDeployedCryptoPoolAddress,
64
116
  getDeployedGaugeAddress: getDeployedGaugeAddress,
65
117
  fetchRecentlyDeployedPool: _curve.fetchRecentlyDeployedCryptoFactoryPool,
66
118
  estimateGas: {
67
119
  deployPool: deployCryptoPoolEstimateGas,
68
- deployGauge: async (poolAddress) => deployGaugeEstimateGas(poolAddress, true),
120
+ deployGauge: function (poolAddress) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
121
+ return [2 /*return*/, deployGaugeEstimateGas(poolAddress, true)];
122
+ }); }); },
69
123
  },
70
124
  },
71
125
  estimateGas: {
72
126
  ensureAllowance: ensureAllowanceEstimateGas,
73
127
  },
74
128
  boosting: {
75
- getCrv,
76
- getLockedAmountAndUnlockTime,
77
- getVeCrv,
78
- getVeCrvPct,
79
- calcUnlockTime,
80
- isApproved,
81
- approve,
82
- createLock,
83
- increaseAmount,
84
- increaseUnlockTime,
85
- withdrawLockedCrv,
86
- claimableFees,
87
- claimFees,
129
+ getCrv: getCrv,
130
+ getLockedAmountAndUnlockTime: getLockedAmountAndUnlockTime,
131
+ getVeCrv: getVeCrv,
132
+ getVeCrvPct: getVeCrvPct,
133
+ calcUnlockTime: calcUnlockTime,
134
+ isApproved: isApproved,
135
+ approve: approve,
136
+ createLock: createLock,
137
+ increaseAmount: increaseAmount,
138
+ increaseUnlockTime: increaseUnlockTime,
139
+ withdrawLockedCrv: withdrawLockedCrv,
140
+ claimableFees: claimableFees,
141
+ claimFees: claimFees,
88
142
  estimateGas: {
89
143
  approve: approveEstimateGas,
90
144
  createLock: createLockEstimateGas,
@@ -95,13 +149,13 @@ const curve = {
95
149
  },
96
150
  },
97
151
  router: {
98
- getBestRouteAndOutput,
152
+ getBestRouteAndOutput: getBestRouteAndOutput,
99
153
  expected: swapExpected,
100
154
  priceImpact: swapPriceImpact,
101
155
  isApproved: swapIsApproved,
102
156
  approve: swapApprove,
103
- swap,
104
- getSwappedAmount,
157
+ swap: swap,
158
+ getSwappedAmount: getSwappedAmount,
105
159
  estimateGas: {
106
160
  approve: swapApproveEstimateGas,
107
161
  swap: swapEstimateGas,
@@ -100,7 +100,7 @@ export interface IRewardFromApi {
100
100
  tokenPrice: number;
101
101
  name: string;
102
102
  symbol: string;
103
- decimals: number;
103
+ decimals: number | string;
104
104
  apy: number;
105
105
  }
106
106
  export interface IPoolDataFromApi {