@gearbox-protocol/sdk 1.5.3 → 1.5.6

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.
@@ -29,6 +29,7 @@ export declare type CurveParams = {
29
29
  type: AdapterInterface.CURVE_V1_2ASSETS | AdapterInterface.CURVE_V1_3ASSETS | AdapterInterface.CURVE_V1_4ASSETS | AdapterInterface.CURVE_V1_WRAPPER;
30
30
  lpToken: CurveLPToken;
31
31
  tokens: Array<NormalToken | CurveLPToken>;
32
+ underlyings?: Array<NormalToken>;
32
33
  wrapper?: CurvePoolContract;
33
34
  } & BaseContractParams;
34
35
  export declare type CurveSteCRVPoolParams = {
@@ -23,7 +23,7 @@ exports.contractsByNetwork = {
23
23
  SUSHISWAP_ROUTER: "0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F",
24
24
  // CURVE
25
25
  CURVE_3CRV_POOL: "0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7",
26
- CURVE_STETH_GATEWAY: "0xB949Ef5b39164537ee97BF17b968e465368C97AD",
26
+ CURVE_STETH_GATEWAY: "0xC9c612799C8c5F52a25d57ce24881A854d376E14",
27
27
  CURVE_FRAX_POOL: token_1.tokenDataByNetwork.Mainnet.FRAX3CRV,
28
28
  CURVE_LUSD_POOL: token_1.tokenDataByNetwork.Mainnet.LUSD3CRV,
29
29
  CURVE_SUSD_POOL: "0xA5407eAE9Ba41422680e2e00537571bcC53efBfD",
@@ -126,6 +126,7 @@ exports.contractParams = {
126
126
  type: adapters_1.AdapterInterface.CURVE_V1_2ASSETS,
127
127
  lpToken: "FRAX3CRV",
128
128
  tokens: ["FRAX", "3Crv"],
129
+ underlyings: ["FRAX", "DAI", "USDC", "USDT"],
129
130
  },
130
131
  CURVE_LUSD_POOL: {
131
132
  name: "Curve LUSD",
@@ -133,6 +134,7 @@ exports.contractParams = {
133
134
  type: adapters_1.AdapterInterface.CURVE_V1_2ASSETS,
134
135
  lpToken: "LUSD3CRV",
135
136
  tokens: ["LUSD", "3Crv"],
137
+ underlyings: ["LUSD", "DAI", "USDC", "USDT"],
136
138
  },
137
139
  CURVE_SUSD_POOL: {
138
140
  name: "Curve SUSD",
@@ -155,6 +157,7 @@ exports.contractParams = {
155
157
  type: adapters_1.AdapterInterface.CURVE_V1_2ASSETS,
156
158
  lpToken: "gusd3CRV",
157
159
  tokens: ["GUSD", "3Crv"],
160
+ underlyings: ["GUSD", "DAI", "USDC", "USDT"],
158
161
  },
159
162
  YEARN_DAI_VAULT: {
160
163
  name: "Yearn DAI",
@@ -18,7 +18,6 @@ export declare type PriceFeedData = {
18
18
  } | {
19
19
  type: OracleType.YEARN_TOKEN_ORACLE;
20
20
  token: SupportedToken;
21
- address: Record<NetworkType, string>;
22
21
  } | {
23
22
  type: OracleType.CURVE_LP_TOKEN_ORACLE;
24
23
  assets: Array<SupportedToken>;
@@ -378,56 +378,32 @@ exports.priceFeedsByNetwork = {
378
378
  priceFeedETH: {
379
379
  type: oracles_1.OracleType.YEARN_TOKEN_ORACLE,
380
380
  token: "DAI",
381
- address: {
382
- Mainnet: "",
383
- Goerli: "TODO: DEPLOY ME",
384
- },
385
381
  },
386
382
  priceFeedUSD: {
387
383
  type: oracles_1.OracleType.YEARN_TOKEN_ORACLE,
388
384
  token: "DAI",
389
- address: {
390
- Mainnet: "",
391
- Goerli: "TODO: DEPLOY ME",
392
- },
393
385
  },
394
386
  },
395
387
  yvUSDC: {
396
388
  priceFeedETH: {
397
389
  type: oracles_1.OracleType.YEARN_TOKEN_ORACLE,
398
390
  token: "USDC",
399
- address: {
400
- Mainnet: "",
401
- Goerli: "TODO: DEPLOY ME",
402
- },
403
391
  },
404
392
  priceFeedUSD: {
405
393
  type: oracles_1.OracleType.YEARN_TOKEN_ORACLE,
406
394
  token: "USDC",
407
- address: {
408
- Mainnet: "",
409
- Goerli: "TODO: DEPLOY ME",
410
- },
411
395
  },
412
396
  },
413
397
  yvWETH: {
414
398
  priceFeedUSD: {
415
399
  type: oracles_1.OracleType.YEARN_TOKEN_ORACLE,
416
400
  token: "WETH",
417
- address: {
418
- Mainnet: "",
419
- Goerli: "TODO: DEPLOY ME",
420
- },
421
401
  },
422
402
  },
423
403
  yvWBTC: {
424
404
  priceFeedUSD: {
425
405
  type: oracles_1.OracleType.YEARN_TOKEN_ORACLE,
426
406
  token: "WBTC",
427
- address: {
428
- Mainnet: "",
429
- Goerli: "TODO: DEPLOY ME",
430
- },
431
407
  },
432
408
  },
433
409
  // CURVE LP TOKENS
@@ -8,5 +8,6 @@ export declare class CurveAdapterParser extends AbstractParser implements IParse
8
8
  constructor(contract: SupportedContract, isContract: boolean);
9
9
  parse(calldata: string): string;
10
10
  getTokenByIndex(index: number): SupportedToken;
11
+ getUnderlyingTokenByIndex(index: number): SupportedToken;
11
12
  convertAmounts(amounts: Array<BigNumberish>): string;
12
13
  }
@@ -53,8 +53,12 @@ var CurveAdapterParser = /** @class */ (function (_super) {
53
53
  case "exchange":
54
54
  case "exchange_underlying": {
55
55
  var _b = this.decodeFunctionData(functionFragment, calldata), i = _b[0], j = _b[1], dx = _b[2], min_dy = _b[3];
56
- var iSym = this.getTokenByIndex(i);
57
- var jSym = this.getTokenByIndex(j);
56
+ var iSym = functionFragment.name === "exchange_underlying"
57
+ ? this.getUnderlyingTokenByIndex(i)
58
+ : this.getTokenByIndex(i);
59
+ var jSym = functionFragment.name === "exchange_underlying"
60
+ ? this.getUnderlyingTokenByIndex(j)
61
+ : this.getTokenByIndex(j);
58
62
  return "".concat(functionName, "(i ,j: ").concat(iSym, " => ").concat(jSym, ", dx: ").concat(this.formatBN(dx, iSym), ", min_dy: ").concat(this.formatBN(min_dy, jSym), ")");
59
63
  }
60
64
  case "exchange_all":
@@ -92,6 +96,10 @@ var CurveAdapterParser = /** @class */ (function (_super) {
92
96
  return contracts_1.contractParams[this.contract]
93
97
  .tokens[index];
94
98
  };
99
+ CurveAdapterParser.prototype.getUnderlyingTokenByIndex = function (index) {
100
+ return contracts_1.contractParams[this.contract]
101
+ .underlyings[index];
102
+ };
95
103
  CurveAdapterParser.prototype.convertAmounts = function (amounts) {
96
104
  var _this = this;
97
105
  return amounts
@@ -16,7 +16,7 @@ describe("CurveAdapterParser test", function () {
16
16
  constants_1.WAD.mul(3),
17
17
  constants_1.WAD.mul(32),
18
18
  ]));
19
- (0, chai_1.expect)(parsed).to.be.eq("Curve2AssetsAdapter[CURVE_FRAX_POOL].exchange_underlying(i ,j: FRAX => 3Crv, dx: 3.00 [3000000000000000000], min_dy: 32.00 [32000000000000000000])", "Curve2AssetsAdapter: Incorrect parse exchange_underlying");
19
+ (0, chai_1.expect)(parsed).to.be.eq("Curve2AssetsAdapter[CURVE_FRAX_POOL].exchange_underlying(i ,j: FRAX => DAI, dx: 3.00 [3000000000000000000], min_dy: 32.00 [32000000000000000000])", "Curve2AssetsAdapter: Incorrect parse exchange_underlying");
20
20
  parsed = parser.parse(ifc.encodeFunctionData("add_liquidity_one_coin", [
21
21
  constants_1.WAD.mul(3),
22
22
  0,
@@ -17,6 +17,7 @@ var __extends = (this && this.__extends) || (function () {
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.UniswapV3AdapterParser = void 0;
19
19
  var types_1 = require("../types");
20
+ var formatter_1 = require("../utils/formatter");
20
21
  var abstractParser_1 = require("./abstractParser");
21
22
  var UniswapV3AdapterParser = /** @class */ (function (_super) {
22
23
  __extends(UniswapV3AdapterParser, _super);
@@ -38,22 +39,33 @@ var UniswapV3AdapterParser = /** @class */ (function (_super) {
38
39
  var amountOutMinimumStr = this.formatBN(amountOutMinimum, tokenOut);
39
40
  return "".concat(functionName, "(amountIn: ").concat(amountInStr, ", amountOutMinimum: ").concat(amountOutMinimumStr, ", path: ").concat(tokenInSym, " ==(fee: ").concat(fee, ")==> ").concat(tokenOutSym, ")");
40
41
  }
42
+ case "exactAllInputSingle": {
43
+ var _c = this.decodeFunctionData(functionFragment, calldata).params, tokenIn = _c.tokenIn, tokenOut = _c.tokenOut, fee = _c.fee, rateMinRAY = _c.rateMinRAY;
44
+ var tokenInSym = this.tokenSymbol(tokenIn);
45
+ var tokenOutSym = this.tokenSymbol(tokenOut);
46
+ return "".concat(functionName, "(rate: ").concat((0, formatter_1.formatBN)(rateMinRAY, 27), ", path: ").concat(tokenInSym, " ==(fee: ").concat(fee, ")==> ").concat(tokenOutSym, ")");
47
+ }
41
48
  case "exactInput": {
42
- var _c = this.decodeFunctionData(functionFragment, calldata).params, amountIn = _c.amountIn, amountOutMinimum = _c.amountOutMinimum, path = _c.path;
49
+ var _d = this.decodeFunctionData(functionFragment, calldata).params, amountIn = _d.amountIn, amountOutMinimum = _d.amountOutMinimum, path = _d.path;
43
50
  var pathStr = this.trackInputPath(path);
44
51
  var amountInStr = this.formatBN(amountIn, this.tokenSymbol("0x".concat(path.replace("0x", "").slice(0, 40))));
45
52
  var amountOutMinimumStr = this.formatBN(amountOutMinimum, this.tokenSymbol("0x".concat(path.slice(-40, path.length))));
46
53
  return "".concat(functionName, "(amountIn: ").concat(amountInStr, ", amountOutMinimum: ").concat(amountOutMinimumStr, ", path: ").concat(pathStr);
47
54
  }
55
+ case "exactAllInput": {
56
+ var _e = this.decodeFunctionData(functionFragment, calldata).params, rateMinRAY = _e.rateMinRAY, path = _e.path;
57
+ var pathStr = this.trackInputPath(path);
58
+ return "".concat(functionName, "(rate: ").concat((0, formatter_1.formatBN)(rateMinRAY, 27), ", path: ").concat(pathStr);
59
+ }
48
60
  case "exactOutput": {
49
- var _d = this.decodeFunctionData(functionFragment, calldata).params, amountInMaximum = _d.amountInMaximum, amountOut = _d.amountOut, path = _d.path;
61
+ var _f = this.decodeFunctionData(functionFragment, calldata).params, amountInMaximum = _f.amountInMaximum, amountOut = _f.amountOut, path = _f.path;
50
62
  var pathStr = this.trackOutputPath(path);
51
63
  var amountInMaximumStr = this.formatBN(amountInMaximum, this.tokenSymbol("0x".concat(path.slice(-40, path.length))));
52
64
  var amountOutStr = this.formatBN(amountOut, this.tokenSymbol("0x".concat(path.replace("0x", "").slice(0, 40))));
53
65
  return "".concat(functionName, "(amountInMaximum: ").concat(amountInMaximumStr, ", amountOut: ").concat(amountOutStr, ", path: ").concat(pathStr);
54
66
  }
55
67
  case "exactOutputSingle": {
56
- var _e = this.decodeFunctionData(functionFragment, calldata)[0], tokenIn = _e[0], tokenOut = _e[1], fee = _e[2], amountOut = _e[5], amountInMaximum = _e[6];
68
+ var _g = this.decodeFunctionData(functionFragment, calldata)[0], tokenIn = _g[0], tokenOut = _g[1], fee = _g[2], amountOut = _g[5], amountInMaximum = _g[6];
57
69
  var tokenInSym = this.tokenSymbol(tokenIn);
58
70
  var tokenOutSym = this.tokenSymbol(tokenOut);
59
71
  var amountInMaximumStr = this.formatBN(amountInMaximum, tokenInSym);
@@ -37,6 +37,17 @@ describe("UniswapV3AdapterParser test", function () {
37
37
  },
38
38
  ]));
39
39
  (0, chai_1.expect)(parsed).to.be.eq("UniswapV3Adapter[UNISWAP_V3_ROUTER].exactInputSingle(amountIn: 1.29M [1299000000000000000000000], amountOutMinimum: 10.20K [10200000000000000000000], path: 1INCH ==(fee: 3000)==> 3Crv)", "Incorrect parse swapExactTokensForTokens");
40
+ parsed = parser.parse(ifc.encodeFunctionData("exactAllInputSingle", [
41
+ {
42
+ tokenIn: token_1.tokenDataByNetwork.Goerli["1INCH"],
43
+ tokenOut: token_1.tokenDataByNetwork.Goerli["3Crv"],
44
+ fee: 3000,
45
+ deadline: 12300,
46
+ rateMinRAY: constants_1.RAY.mul(1200),
47
+ sqrtPriceLimitX96: 0,
48
+ },
49
+ ]));
50
+ (0, chai_1.expect)(parsed).to.be.eq("UniswapV3Adapter[UNISWAP_V3_ROUTER].exactAllInputSingle(rate: 1.20K, path: 1INCH ==(fee: 3000)==> 3Crv)", "Incorrect parse swapExactTokensForTokens");
40
51
  parsed = parser.parse(ifc.encodeFunctionData("exactInput", [
41
52
  {
42
53
  path: pathToUniV3Path([
@@ -51,6 +62,18 @@ describe("UniswapV3AdapterParser test", function () {
51
62
  },
52
63
  ]));
53
64
  (0, chai_1.expect)(parsed).to.be.eq("UniswapV3Adapter[UNISWAP_V3_ROUTER].exactInput(amountIn: 12.39K [12399000000000000000000], amountOutMinimum: 122.00 [122000000], path: AAVE ==(fee: 3000)==> LINK ==(fee: 3000)==> USDC", "Incorrect parse swapExactTokensForTokens");
65
+ parsed = parser.parse(ifc.encodeFunctionData("exactAllInput", [
66
+ {
67
+ path: pathToUniV3Path([
68
+ token_1.tokenDataByNetwork.Mainnet.AAVE,
69
+ token_1.tokenDataByNetwork.Mainnet.LINK,
70
+ token_1.tokenDataByNetwork.Mainnet.USDC,
71
+ ]),
72
+ rateMinRAY: constants_1.RAY.mul(1200),
73
+ deadline: 1232131,
74
+ },
75
+ ]));
76
+ (0, chai_1.expect)(parsed).to.be.eq("UniswapV3Adapter[UNISWAP_V3_ROUTER].exactAllInput(rate: 1.20K, path: AAVE ==(fee: 3000)==> LINK ==(fee: 3000)==> USDC", "Incorrect parse swapExactTokensForTokens");
54
77
  parsed = parser.parse(ifc.encodeFunctionData("exactOutputSingle", [
55
78
  {
56
79
  tokenIn: token_1.tokenDataByNetwork.Goerli["1INCH"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "1.5.3",
3
+ "version": "1.5.6",
4
4
  "description": "Gearbox SDK",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",