@dhedge/v2-sdk 2.1.3 → 2.1.4

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.
@@ -27041,6 +27041,20 @@ var PTAbi = [
27041
27041
  ],
27042
27042
  stateMutability: "view",
27043
27043
  type: "function"
27044
+ },
27045
+ {
27046
+ inputs: [
27047
+ ],
27048
+ name: "YT",
27049
+ outputs: [
27050
+ {
27051
+ internalType: "address",
27052
+ name: "",
27053
+ type: "address"
27054
+ }
27055
+ ],
27056
+ stateMutability: "view",
27057
+ type: "function"
27044
27058
  }
27045
27059
  ];
27046
27060
 
@@ -27136,43 +27150,98 @@ function _getPendleSwapTxData() {
27136
27150
  return _getPendleSwapTxData.apply(this, arguments);
27137
27151
  }
27138
27152
 
27153
+ function getPendleMintTxData(_x6, _x7, _x8, _x9, _x10) {
27154
+ return _getPendleMintTxData.apply(this, arguments);
27155
+ }
27156
+
27157
+ function _getPendleMintTxData() {
27158
+ _getPendleMintTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(pool, tokenIn, pt, amountIn, slippage) {
27159
+ var PTcontract, ytAddress, params, swapResult;
27160
+ return runtime_1.wrap(function _callee4$(_context4) {
27161
+ while (1) {
27162
+ switch (_context4.prev = _context4.next) {
27163
+ case 0:
27164
+ PTcontract = new ethers.Contract(pt, PTAbi, pool.signer);
27165
+ _context4.next = 3;
27166
+ return PTcontract.YT();
27167
+
27168
+ case 3:
27169
+ ytAddress = _context4.sent;
27170
+ params = {
27171
+ receiver: pool.address,
27172
+ tokensIn: tokenIn,
27173
+ tokensOut: pt + "," + ytAddress,
27174
+ amountsIn: amountIn.toString(),
27175
+ slippage: slippage / 100
27176
+ };
27177
+ _context4.prev = 5;
27178
+ _context4.next = 8;
27179
+ return axios.get(pendleBaseUrl + "/v2/sdk/" + networkChainIdMap[pool.network] + "/convert", {
27180
+ params: params
27181
+ });
27182
+
27183
+ case 8:
27184
+ swapResult = _context4.sent;
27185
+ return _context4.abrupt("return", {
27186
+ swapTxData: swapResult.data.routes[0].tx.data,
27187
+ minAmountOut: swapResult.data.routes[0].outputs.filter(function (e) {
27188
+ return e.token === pt.toLowerCase();
27189
+ })[0].amount
27190
+ });
27191
+
27192
+ case 12:
27193
+ _context4.prev = 12;
27194
+ _context4.t0 = _context4["catch"](5);
27195
+ console.error("Error in Pendle API request:", _context4.t0);
27196
+ throw new ApiError("Pendle api request failed");
27197
+
27198
+ case 16:
27199
+ case "end":
27200
+ return _context4.stop();
27201
+ }
27202
+ }
27203
+ }, _callee4, null, [[5, 12]]);
27204
+ }));
27205
+ return _getPendleMintTxData.apply(this, arguments);
27206
+ }
27207
+
27139
27208
  var checkUnderlying = function checkUnderlying(market, token, networkId) {
27140
27209
  if (market.underlyingAsset !== networkId + "-" + token.toLocaleLowerCase()) {
27141
27210
  throw new Error("Can only trade in or out of the underlying asset");
27142
27211
  }
27143
27212
  };
27144
27213
 
27145
- function getMarket(_x6, _x7, _x8) {
27214
+ function getMarket(_x11, _x12, _x13) {
27146
27215
  return _getMarket.apply(this, arguments);
27147
27216
  }
27148
27217
 
27149
27218
  function _getMarket() {
27150
- _getMarket = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(pool, tokenIn, tokenOut) {
27219
+ _getMarket = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(pool, tokenIn, tokenOut) {
27151
27220
  var networkId, marketResult, params, allMarkets, markets;
27152
- return runtime_1.wrap(function _callee4$(_context4) {
27221
+ return runtime_1.wrap(function _callee5$(_context5) {
27153
27222
  while (1) {
27154
- switch (_context4.prev = _context4.next) {
27223
+ switch (_context5.prev = _context5.next) {
27155
27224
  case 0:
27156
27225
  networkId = networkChainIdMap[pool.network];
27157
- _context4.prev = 1;
27226
+ _context5.prev = 1;
27158
27227
  params = {
27159
27228
  isActive: true,
27160
27229
  chainId: networkId
27161
27230
  };
27162
- _context4.next = 5;
27231
+ _context5.next = 5;
27163
27232
  return axios.get(pendleBaseUrl + "/v1/markets/all", {
27164
27233
  params: params
27165
27234
  });
27166
27235
 
27167
27236
  case 5:
27168
- marketResult = _context4.sent;
27169
- _context4.next = 12;
27237
+ marketResult = _context5.sent;
27238
+ _context5.next = 12;
27170
27239
  break;
27171
27240
 
27172
27241
  case 8:
27173
- _context4.prev = 8;
27174
- _context4.t0 = _context4["catch"](1);
27175
- console.error("Error in Pendle API request:", _context4.t0);
27242
+ _context5.prev = 8;
27243
+ _context5.t0 = _context5["catch"](1);
27244
+ console.error("Error in Pendle API request:", _context5.t0);
27176
27245
  throw new ApiError("Pendle api request failed");
27177
27246
 
27178
27247
  case 12:
@@ -27184,31 +27253,31 @@ function _getMarket() {
27184
27253
  });
27185
27254
 
27186
27255
  if (!markets[0]) {
27187
- _context4.next = 19;
27256
+ _context5.next = 19;
27188
27257
  break;
27189
27258
  }
27190
27259
 
27191
27260
  checkUnderlying(markets[0], tokenOut, networkId);
27192
- return _context4.abrupt("return", markets[0].address);
27261
+ return _context5.abrupt("return", markets[0].address);
27193
27262
 
27194
27263
  case 19:
27195
27264
  if (!markets[1]) {
27196
- _context4.next = 24;
27265
+ _context5.next = 24;
27197
27266
  break;
27198
27267
  }
27199
27268
 
27200
27269
  checkUnderlying(markets[1], tokenIn, networkId);
27201
- return _context4.abrupt("return", markets[1].address);
27270
+ return _context5.abrupt("return", markets[1].address);
27202
27271
 
27203
27272
  case 24:
27204
27273
  throw new Error("Can only trade PT assets");
27205
27274
 
27206
27275
  case 25:
27207
27276
  case "end":
27208
- return _context4.stop();
27277
+ return _context5.stop();
27209
27278
  }
27210
27279
  }
27211
- }, _callee4, null, [[1, 8]]);
27280
+ }, _callee5, null, [[1, 8]]);
27212
27281
  }));
27213
27282
  return _getMarket.apply(this, arguments);
27214
27283
  }
@@ -27277,7 +27346,7 @@ var checkExitPostExpPT = /*#__PURE__*/function () {
27277
27346
  }, _callee, null, [[1, 8]]);
27278
27347
  }));
27279
27348
 
27280
- return function checkExitPostExpPT(_x9, _x10, _x11) {
27349
+ return function checkExitPostExpPT(_x14, _x15, _x16) {
27281
27350
  return _ref.apply(this, arguments);
27282
27351
  };
27283
27352
  }();
@@ -27324,7 +27393,7 @@ var getExitExpPTTxData = /*#__PURE__*/function () {
27324
27393
  }, _callee2);
27325
27394
  }));
27326
27395
 
27327
- return function getExitExpPTTxData(_x12, _x13, _x14, _x15, _x16) {
27396
+ return function getExitExpPTTxData(_x17, _x18, _x19, _x20, _x21) {
27328
27397
  return _ref2.apply(this, arguments);
27329
27398
  };
27330
27399
  }();
@@ -31523,6 +31592,70 @@ var Pool = /*#__PURE__*/function () {
31523
31592
  }
31524
31593
 
31525
31594
  return completeTorosWithdrawal;
31595
+ }()
31596
+ /**
31597
+ * Mint PT and YT tokens on Pendle
31598
+ * @param {string} assetFrom Asset to mint from (only underlying asset)
31599
+ * @param {string} pt PT address
31600
+ * @param {BigNumber | string} amountIn Amount underlying asset
31601
+ * @param {number} slippage Slippage tolerance in %
31602
+ * @param {any} options Transaction options
31603
+ * @param {SDKOptions} sdkOptions SDK options including estimateGas
31604
+ * @returns {Promise<any>} Transaction
31605
+ */
31606
+ ;
31607
+
31608
+ _proto.mintPendle =
31609
+ /*#__PURE__*/
31610
+ function () {
31611
+ var _mintPendle = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee58(assetFrom, pt, amountIn, slippage, options, sdkOptions) {
31612
+ var _yield$getPendleMintT, swapTxData, minAmountOut, tx;
31613
+
31614
+ return runtime_1.wrap(function _callee58$(_context58) {
31615
+ while (1) {
31616
+ switch (_context58.prev = _context58.next) {
31617
+ case 0:
31618
+ if (slippage === void 0) {
31619
+ slippage = 0.5;
31620
+ }
31621
+
31622
+ if (options === void 0) {
31623
+ options = null;
31624
+ }
31625
+
31626
+ if (sdkOptions === void 0) {
31627
+ sdkOptions = {
31628
+ estimateGas: false
31629
+ };
31630
+ }
31631
+
31632
+ _context58.next = 5;
31633
+ return getPendleMintTxData(this, assetFrom, pt, amountIn, slippage);
31634
+
31635
+ case 5:
31636
+ _yield$getPendleMintT = _context58.sent;
31637
+ swapTxData = _yield$getPendleMintT.swapTxData;
31638
+ minAmountOut = _yield$getPendleMintT.minAmountOut;
31639
+ _context58.next = 10;
31640
+ return getPoolTxOrGasEstimate(this, [routerAddress[this.network][Dapp.PENDLE], swapTxData, options, minAmountOut], sdkOptions);
31641
+
31642
+ case 10:
31643
+ tx = _context58.sent;
31644
+ return _context58.abrupt("return", tx);
31645
+
31646
+ case 12:
31647
+ case "end":
31648
+ return _context58.stop();
31649
+ }
31650
+ }
31651
+ }, _callee58, this);
31652
+ }));
31653
+
31654
+ function mintPendle(_x273, _x274, _x275, _x276, _x277, _x278) {
31655
+ return _mintPendle.apply(this, arguments);
31656
+ }
31657
+
31658
+ return mintPendle;
31526
31659
  }();
31527
31660
 
31528
31661
  return Pool;