@curvefi/api 2.16.2 → 2.17.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/index.d.ts CHANGED
@@ -17,6 +17,8 @@ declare function init(providerType: 'JsonRpc' | 'Web3' | 'Infura' | 'Alchemy', p
17
17
  }): Promise<void>;
18
18
  declare function fetchFactoryPools(useApi?: boolean): Promise<void>;
19
19
  declare function fetchCryptoFactoryPools(useApi?: boolean): Promise<void>;
20
+ declare function fetchRecentlyDeployedFactoryPool(poolAddress: string): Promise<string>;
21
+ declare function fetchRecentlyDeployedCryptoFactoryPool(poolAddress: string): Promise<string>;
20
22
  declare function setCustomFeeData(customFeeData: {
21
23
  gasPrice?: number;
22
24
  maxFeePerGas?: number;
@@ -42,6 +44,32 @@ declare const curve: {
42
44
  getAllowance: (coins: string[], address: string, spender: string) => Promise<string[]>;
43
45
  hasAllowance: (coins: string[], amounts: (string | number)[], address: string, spender: string) => Promise<boolean>;
44
46
  ensureAllowance: (coins: string[], amounts: (string | number)[], spender: string) => Promise<string[]>;
47
+ factory: {
48
+ deployPlainPool: (name: string, symbol: string, coins: string[], A: number, fee: number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3) => Promise<ethers.ContractTransaction>;
49
+ deployMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: number, fee: number, implementationIdx: 0 | 1) => Promise<ethers.ContractTransaction>;
50
+ deployGauge: (poolAddress: string) => Promise<ethers.ContractTransaction>;
51
+ getDeployedPlainPoolAddress: (tx: ethers.ContractTransaction) => Promise<string>;
52
+ getDeployedMetaPoolAddress: (tx: ethers.ContractTransaction) => Promise<string>;
53
+ getDeployedGaugeAddress: (tx: ethers.ContractTransaction) => Promise<string>;
54
+ fetchRecentlyDeployedPool: typeof fetchRecentlyDeployedFactoryPool;
55
+ estimateGas: {
56
+ deployPlainPool: (name: string, symbol: string, coins: string[], A: number, fee: number, assetType: 0 | 1 | 2 | 3, implementationIdx: 0 | 1 | 2 | 3) => Promise<number>;
57
+ deployMetaPool: (basePool: string, name: string, symbol: string, coin: string, A: number, fee: number, implementationIdx: 0 | 1) => Promise<number>;
58
+ deployGauge: (poolAddress: string) => Promise<number>;
59
+ };
60
+ };
61
+ cryptoFactory: {
62
+ deployPool: (name: string, symbol: string, coins: string[], A: number, gamma: number, midFee: number, outFee: number, allowedExtraProfit: number, feeGamma: number, adjustmentStep: number, maHalfTime: number, initialPrice: number) => Promise<ethers.ContractTransaction>;
63
+ deployGauge: (poolAddress: string) => Promise<ethers.ContractTransaction>;
64
+ getDeployed: (tx: ethers.ContractTransaction) => Promise<string>;
65
+ getDeployedPoolAddress: (tx: ethers.ContractTransaction) => Promise<string>;
66
+ getDeployedGaugeAddress: (tx: ethers.ContractTransaction) => Promise<string>;
67
+ fetchRecentlyDeployedPool: typeof fetchRecentlyDeployedCryptoFactoryPool;
68
+ estimateGas: {
69
+ deployPool: (name: string, symbol: string, coins: string[], A: number, gamma: number, midFee: number, outFee: number, allowedExtraProfit: number, feeGamma: number, adjustmentStep: number, maHalfTime: number, initialPrice: number) => Promise<number>;
70
+ deployGauge: (poolAddress: string) => Promise<number>;
71
+ };
72
+ };
45
73
  estimateGas: {
46
74
  ensureAllowance: (coins: string[], amounts: (string | number)[], spender: string) => Promise<number>;
47
75
  };
package/lib/index.js CHANGED
@@ -42,6 +42,7 @@ var router_1 = require("./router");
42
42
  var curve_1 = require("./curve");
43
43
  var boosting_1 = require("./boosting");
44
44
  var utils_2 = require("./utils");
45
+ var deploy_1 = require("./factory/deploy");
45
46
  function init(providerType, providerSettings, options) {
46
47
  if (options === void 0) { options = {}; }
47
48
  return __awaiter(this, void 0, void 0, function () {
@@ -85,6 +86,26 @@ function fetchCryptoFactoryPools(useApi) {
85
86
  });
86
87
  });
87
88
  }
89
+ function fetchRecentlyDeployedFactoryPool(poolAddress) {
90
+ return __awaiter(this, void 0, void 0, function () {
91
+ return __generator(this, function (_a) {
92
+ switch (_a.label) {
93
+ case 0: return [4 /*yield*/, curve_1.curve.fetchRecentlyDeployedFactoryPool(poolAddress)];
94
+ case 1: return [2 /*return*/, _a.sent()];
95
+ }
96
+ });
97
+ });
98
+ }
99
+ function fetchRecentlyDeployedCryptoFactoryPool(poolAddress) {
100
+ return __awaiter(this, void 0, void 0, function () {
101
+ return __generator(this, function (_a) {
102
+ switch (_a.label) {
103
+ case 0: return [4 /*yield*/, curve_1.curve.fetchRecentlyDeployedCryptoFactoryPool(poolAddress)];
104
+ case 1: return [2 /*return*/, _a.sent()];
105
+ }
106
+ });
107
+ });
108
+ }
88
109
  function setCustomFeeData(customFeeData) {
89
110
  curve_1.curve.setCustomFeeData(customFeeData);
90
111
  }
@@ -108,6 +129,40 @@ var curve = {
108
129
  getAllowance: utils_2.getAllowance,
109
130
  hasAllowance: utils_2.hasAllowance,
110
131
  ensureAllowance: utils_2.ensureAllowance,
132
+ factory: {
133
+ deployPlainPool: deploy_1.deployStablePlainPool,
134
+ deployMetaPool: deploy_1.deployStableMetaPool,
135
+ deployGauge: function (poolAddress) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
136
+ return [2 /*return*/, (0, deploy_1.deployGauge)(poolAddress, false)];
137
+ }); }); },
138
+ getDeployedPlainPoolAddress: deploy_1.getDeployedStablePlainPoolAddress,
139
+ getDeployedMetaPoolAddress: deploy_1.getDeployedStableMetaPoolAddress,
140
+ getDeployedGaugeAddress: deploy_1.getDeployedGaugeAddress,
141
+ fetchRecentlyDeployedPool: fetchRecentlyDeployedFactoryPool,
142
+ estimateGas: {
143
+ deployPlainPool: deploy_1.deployStablePlainPoolEstimateGas,
144
+ deployMetaPool: deploy_1.deployStableMetaPoolEstimateGas,
145
+ deployGauge: function (poolAddress) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
146
+ return [2 /*return*/, (0, deploy_1.deployGaugeEstimateGas)(poolAddress, false)];
147
+ }); }); },
148
+ },
149
+ },
150
+ cryptoFactory: {
151
+ deployPool: deploy_1.deployCryptoPool,
152
+ deployGauge: function (poolAddress) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
153
+ return [2 /*return*/, (0, deploy_1.deployGauge)(poolAddress, true)];
154
+ }); }); },
155
+ getDeployed: deploy_1.getDeployedStablePlainPoolAddress,
156
+ getDeployedPoolAddress: deploy_1.getDeployedCryptoPoolAddress,
157
+ getDeployedGaugeAddress: deploy_1.getDeployedGaugeAddress,
158
+ fetchRecentlyDeployedPool: fetchRecentlyDeployedCryptoFactoryPool,
159
+ estimateGas: {
160
+ deployPool: deploy_1.deployCryptoPoolEstimateGas,
161
+ deployGauge: function (poolAddress) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
162
+ return [2 /*return*/, (0, deploy_1.deployGaugeEstimateGas)(poolAddress, true)];
163
+ }); }); },
164
+ },
165
+ },
111
166
  estimateGas: {
112
167
  ensureAllowance: utils_2.ensureAllowanceEstimateGas,
113
168
  },
@@ -1116,6 +1116,8 @@ var PoolTemplate = /** @class */ (function () {
1116
1116
  };
1117
1117
  }
1118
1118
  PoolTemplate.prototype.rewardsOnly = function () {
1119
+ if (curve_1.curve.chainId === 2222)
1120
+ return true; // TODO remove this for Kava
1119
1121
  if (this.gauge === ethers_1.ethers.constants.AddressZero)
1120
1122
  throw Error("".concat(this.name, " doesn't have gauge"));
1121
1123
  var gaugeContract = curve_1.curve.contracts[this.gauge].contract;
@@ -1238,7 +1240,7 @@ var PoolTemplate = /** @class */ (function () {
1238
1240
  return [4 /*yield*/, curve_1.curve.contracts[this.address].contract.price_scale(curve_1.curve.constantOptions)];
1239
1241
  case 1:
1240
1242
  priceScaleBN = _c.apply(void 0, [_d.sent()]);
1241
- return [2 /*return*/, [amount1BN.toFixed(decimals[0]), amount1BN.div(priceScaleBN).toFixed(decimals[1])]];
1243
+ return [2 /*return*/, [(0, utils_1._cutZeros)(amount1BN.toFixed(decimals[0])), (0, utils_1._cutZeros)(amount1BN.div(priceScaleBN).toFixed(decimals[1]))]];
1242
1244
  }
1243
1245
  });
1244
1246
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "2.16.2",
3
+ "version": "2.17.0",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "author": "Macket",