@curvefi/api 1.20.1 → 1.20.2

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/curve.d.ts CHANGED
@@ -35,7 +35,7 @@ export declare let ALIASES: {
35
35
  declare class Curve {
36
36
  provider: ethers.providers.Web3Provider | ethers.providers.JsonRpcProvider;
37
37
  multicallProvider: MulticallProvider;
38
- signer: ethers.Signer;
38
+ signer: ethers.Signer | null;
39
39
  signerAddress: string;
40
40
  chainId: number;
41
41
  contracts: {
package/lib/curve.js CHANGED
@@ -144,10 +144,13 @@ var Curve = /** @class */ (function () {
144
144
  else if (providerType.toLowerCase() === 'Infura'.toLowerCase()) {
145
145
  providerSettings = providerSettings;
146
146
  this.provider = new ethers_1.ethers.providers.InfuraProvider(providerSettings.network, providerSettings.apiKey);
147
+ this.signer = null;
148
+ // Alchemy provider
147
149
  }
148
150
  else if (providerType.toLowerCase() === 'Alchemy'.toLowerCase()) {
149
151
  providerSettings = providerSettings;
150
152
  this.provider = new ethers_1.ethers.providers.AlchemyProvider(providerSettings.network, providerSettings.apiKey);
153
+ this.signer = null;
151
154
  }
152
155
  else {
153
156
  throw Error('Wrong providerType');
@@ -438,6 +441,8 @@ var Curve = /** @class */ (function () {
438
441
  DECIMALS_LOWER_CASE: exports.DECIMALS_LOWER_CASE,
439
442
  LP_TOKENS: exports.LP_TOKENS,
440
443
  GAUGES: exports.GAUGES,
444
+ FACTORY_POOLS_DATA: [],
445
+ CRYPTO_FACTORY_POOLS_DATA: [],
441
446
  };
442
447
  return [2 /*return*/];
443
448
  }
@@ -4,7 +4,7 @@ import { DictInterface, PoolDataInterface } from "./interfaces";
4
4
  interface CurveInterface {
5
5
  provider: ethers.providers.Web3Provider | ethers.providers.JsonRpcProvider;
6
6
  multicallProvider: MulticallProvider;
7
- signer: ethers.Signer;
7
+ signer: ethers.Signer | null;
8
8
  signerAddress: string;
9
9
  chainId: number;
10
10
  contracts: {
@@ -255,6 +255,9 @@ function getCoinAddressNameDict(coinAddresses, existingCoinAddrNameDict) {
255
255
  if (addr in existingCoinAddrNameDict) {
256
256
  coinAddrNamesDict[addr] = existingCoinAddrNameDict[addr];
257
257
  }
258
+ else if (addr === "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2") {
259
+ coinAddrNamesDict[addr] = "MKR";
260
+ }
258
261
  else {
259
262
  newCoinAddresses.push(addr);
260
263
  }
package/lib/factory.d.ts CHANGED
@@ -4,7 +4,7 @@ import { DictInterface, PoolDataInterface } from "./interfaces";
4
4
  interface CurveInterface {
5
5
  provider: ethers.providers.Web3Provider | ethers.providers.JsonRpcProvider;
6
6
  multicallProvider: MulticallProvider;
7
- signer: ethers.Signer;
7
+ signer: ethers.Signer | null;
8
8
  signerAddress: string;
9
9
  chainId: number;
10
10
  contracts: {
package/lib/index.d.ts CHANGED
@@ -56,6 +56,7 @@ declare const curve: {
56
56
  crossAssetExchangeIsApproved: (inputCoin: string, amount: string) => Promise<boolean>;
57
57
  crossAssetExchangeApprove: (inputCoin: string, amount: string) => Promise<string[]>;
58
58
  crossAssetExchange: (inputCoin: string, outputCoin: string, amount: string, maxSlippage?: number) => Promise<string>;
59
+ getUserPoolList: (address?: string | undefined) => Promise<string[]>;
59
60
  estimateGas: {
60
61
  ensureAllowance: (coins: string[], amounts: string[], spender: string) => Promise<number>;
61
62
  exchangeApprove: (inputCoin: string, outputCoin: string, amount: string) => Promise<number>;
package/lib/index.js CHANGED
@@ -111,6 +111,7 @@ var curve = {
111
111
  crossAssetExchangeIsApproved: pools_1.crossAssetExchangeIsApproved,
112
112
  crossAssetExchangeApprove: pools_1.crossAssetExchangeApprove,
113
113
  crossAssetExchange: pools_1.crossAssetExchange,
114
+ getUserPoolList: pools_1.getUserPoolList,
114
115
  estimateGas: {
115
116
  ensureAllowance: utils_1.ensureAllowanceEstimateGas,
116
117
  exchangeApprove: pools_1.exchangeApproveEstimateGas,
package/lib/pools.d.ts CHANGED
@@ -250,3 +250,4 @@ export declare const crossAssetExchangeApproveEstimateGas: (inputCoin: string, a
250
250
  export declare const crossAssetExchangeApprove: (inputCoin: string, amount: string) => Promise<string[]>;
251
251
  export declare const crossAssetExchangeEstimateGas: (inputCoin: string, outputCoin: string, amount: string, maxSlippage?: number) => Promise<number>;
252
252
  export declare const crossAssetExchange: (inputCoin: string, outputCoin: string, amount: string, maxSlippage?: number) => Promise<string>;
253
+ export declare const getUserPoolList: (address?: string | undefined) => Promise<string[]>;
package/lib/pools.js CHANGED
@@ -59,7 +59,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
59
59
  return (mod && mod.__esModule) ? mod : { "default": mod };
60
60
  };
61
61
  Object.defineProperty(exports, "__esModule", { value: true });
62
- exports.crossAssetExchange = exports.crossAssetExchangeEstimateGas = exports.crossAssetExchangeApprove = exports.crossAssetExchangeApproveEstimateGas = exports.crossAssetExchangeIsApproved = exports.crossAssetExchangeExpected = exports.crossAssetExchangeOutputAndSlippage = exports._crossAssetExchangeInfo = exports._getSmallAmountForCoin = exports.crossAssetExchangeAvailable = exports.exchange = exports.exchangeEstimateGas = exports.exchangeApprove = exports.exchangeApproveEstimateGas = exports.exchangeIsApproved = exports.exchangeExpected = exports.getBestPoolAndOutput = exports.Pool = void 0;
62
+ exports.getUserPoolList = exports.crossAssetExchange = exports.crossAssetExchangeEstimateGas = exports.crossAssetExchangeApprove = exports.crossAssetExchangeApproveEstimateGas = exports.crossAssetExchangeIsApproved = exports.crossAssetExchangeExpected = exports.crossAssetExchangeOutputAndSlippage = exports._crossAssetExchangeInfo = exports._getSmallAmountForCoin = exports.crossAssetExchangeAvailable = exports.exchange = exports.exchangeEstimateGas = exports.exchangeApprove = exports.exchangeApproveEstimateGas = exports.exchangeIsApproved = exports.exchangeExpected = exports.getBestPoolAndOutput = exports.Pool = void 0;
63
63
  var ethers_1 = require("ethers");
64
64
  var utils_1 = require("./utils");
65
65
  var curve_1 = require("./curve");
@@ -4125,3 +4125,32 @@ var crossAssetExchange = function (inputCoin, outputCoin, amount, maxSlippage) {
4125
4125
  });
4126
4126
  };
4127
4127
  exports.crossAssetExchange = crossAssetExchange;
4128
+ var getUserPoolList = function (address) { return __awaiter(void 0, void 0, void 0, function () {
4129
+ var poolNames, promises, _i, poolNames_1, poolName, pool, userPoolList, balances, i;
4130
+ return __generator(this, function (_a) {
4131
+ switch (_a.label) {
4132
+ case 0:
4133
+ if (!address)
4134
+ address = curve_1.curve.signerAddress;
4135
+ address = address;
4136
+ poolNames = __spreadArray(__spreadArray(__spreadArray([], (0, utils_1.getPoolList)(), true), (0, utils_1.getFactoryPoolList)(), true), (0, utils_1.getCryptoFactoryPoolList)(), true);
4137
+ promises = [];
4138
+ for (_i = 0, poolNames_1 = poolNames; _i < poolNames_1.length; _i++) {
4139
+ poolName = poolNames_1[_i];
4140
+ pool = new Pool(poolName);
4141
+ promises.push(pool.lpTokenBalances(address)); // TODO optimization
4142
+ }
4143
+ userPoolList = [];
4144
+ return [4 /*yield*/, Promise.all(promises)];
4145
+ case 1:
4146
+ balances = (_a.sent()).map(function (lpBalance) { return Object.values(lpBalance).map(Number).reduce(function (a, b) { return a + b; }); });
4147
+ for (i = 0; i < poolNames.length; i++) {
4148
+ if (balances[i] > 0) {
4149
+ userPoolList.push(poolNames[i]);
4150
+ }
4151
+ }
4152
+ return [2 /*return*/, userPoolList];
4153
+ }
4154
+ });
4155
+ }); };
4156
+ exports.getUserPoolList = getUserPoolList;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@curvefi/api",
3
- "version": "1.20.1",
3
+ "version": "1.20.2",
4
4
  "description": "JavaScript library for curve.fi",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {