@dhedge/v2-sdk 2.1.0 → 2.1.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.
@@ -27033,7 +27033,7 @@ var SYAbi = [
27033
27033
  }
27034
27034
  ];
27035
27035
 
27036
- var pendleBaseUrl = "https://api-v2.pendle.finance/core/v1";
27036
+ var pendleBaseUrl = "https://api-v2.pendle.finance/core";
27037
27037
  function getPendleSwapTxData(_x, _x2, _x3, _x4, _x5) {
27038
27038
  return _getPendleSwapTxData.apply(this, arguments);
27039
27039
  }
@@ -27081,7 +27081,7 @@ function _getPendleSwapTxData() {
27081
27081
  market = _context3.sent;
27082
27082
  _context3.prev = 12;
27083
27083
  _context3.next = 15;
27084
- return axios.get(pendleBaseUrl + "/sdk/" + networkChainIdMap[pool.network] + "/markets/" + market + "/swap", {
27084
+ return axios.get(pendleBaseUrl + "/v2/sdk/" + networkChainIdMap[pool.network] + "/markets/" + market + "/swap", {
27085
27085
  params: params
27086
27086
  });
27087
27087
 
@@ -27120,28 +27120,34 @@ function getMarket(_x6, _x7, _x8) {
27120
27120
 
27121
27121
  function _getMarket() {
27122
27122
  _getMarket = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(pool, tokenIn, tokenOut) {
27123
- var networkId, marketResult, allMarkets, markets;
27123
+ var networkId, marketResult, params, allMarkets, markets;
27124
27124
  return runtime_1.wrap(function _callee4$(_context4) {
27125
27125
  while (1) {
27126
27126
  switch (_context4.prev = _context4.next) {
27127
27127
  case 0:
27128
27128
  networkId = networkChainIdMap[pool.network];
27129
27129
  _context4.prev = 1;
27130
- _context4.next = 4;
27131
- return axios.get(pendleBaseUrl + "/" + networkId + "/markets/active");
27130
+ params = {
27131
+ isActive: true,
27132
+ chainId: networkId
27133
+ };
27134
+ _context4.next = 5;
27135
+ return axios.get(pendleBaseUrl + "/v1/markets/all", {
27136
+ params: params
27137
+ });
27132
27138
 
27133
- case 4:
27139
+ case 5:
27134
27140
  marketResult = _context4.sent;
27135
- _context4.next = 11;
27141
+ _context4.next = 12;
27136
27142
  break;
27137
27143
 
27138
- case 7:
27139
- _context4.prev = 7;
27144
+ case 8:
27145
+ _context4.prev = 8;
27140
27146
  _context4.t0 = _context4["catch"](1);
27141
27147
  console.error("Error in Pendle API request:", _context4.t0);
27142
27148
  throw new ApiError("Pendle api request failed");
27143
27149
 
27144
- case 11:
27150
+ case 12:
27145
27151
  allMarkets = marketResult.data.markets;
27146
27152
  markets = [tokenIn, tokenOut].map(function (token) {
27147
27153
  return allMarkets.find(function (market) {
@@ -27150,59 +27156,65 @@ function _getMarket() {
27150
27156
  });
27151
27157
 
27152
27158
  if (!markets[0]) {
27153
- _context4.next = 18;
27159
+ _context4.next = 19;
27154
27160
  break;
27155
27161
  }
27156
27162
 
27157
27163
  checkUnderlying(markets[0], tokenOut, networkId);
27158
27164
  return _context4.abrupt("return", markets[0].address);
27159
27165
 
27160
- case 18:
27166
+ case 19:
27161
27167
  if (!markets[1]) {
27162
- _context4.next = 23;
27168
+ _context4.next = 24;
27163
27169
  break;
27164
27170
  }
27165
27171
 
27166
27172
  checkUnderlying(markets[1], tokenIn, networkId);
27167
27173
  return _context4.abrupt("return", markets[1].address);
27168
27174
 
27169
- case 23:
27175
+ case 24:
27170
27176
  throw new Error("Can only trade PT assets");
27171
27177
 
27172
- case 24:
27178
+ case 25:
27173
27179
  case "end":
27174
27180
  return _context4.stop();
27175
27181
  }
27176
27182
  }
27177
- }, _callee4, null, [[1, 7]]);
27183
+ }, _callee4, null, [[1, 8]]);
27178
27184
  }));
27179
27185
  return _getMarket.apply(this, arguments);
27180
27186
  }
27181
27187
 
27182
27188
  var checkExitPostExpPT = /*#__PURE__*/function () {
27183
27189
  var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(pool, tokenIn, tokenOut) {
27184
- var networkId, inactiveMarketResult, allInactiveMarkets, markets;
27190
+ var networkId, inactiveMarketResult, params, allInactiveMarkets, markets;
27185
27191
  return runtime_1.wrap(function _callee$(_context) {
27186
27192
  while (1) {
27187
27193
  switch (_context.prev = _context.next) {
27188
27194
  case 0:
27189
27195
  networkId = networkChainIdMap[pool.network];
27190
27196
  _context.prev = 1;
27191
- _context.next = 4;
27192
- return axios.get(pendleBaseUrl + "/" + networkId + "/markets/inactive");
27197
+ params = {
27198
+ isActive: false,
27199
+ chainId: networkId
27200
+ };
27201
+ _context.next = 5;
27202
+ return axios.get(pendleBaseUrl + "/v1/markets/all", {
27203
+ params: params
27204
+ });
27193
27205
 
27194
- case 4:
27206
+ case 5:
27195
27207
  inactiveMarketResult = _context.sent;
27196
- _context.next = 11;
27208
+ _context.next = 12;
27197
27209
  break;
27198
27210
 
27199
- case 7:
27200
- _context.prev = 7;
27211
+ case 8:
27212
+ _context.prev = 8;
27201
27213
  _context.t0 = _context["catch"](1);
27202
27214
  console.error("Error in Pendle API request:", _context.t0);
27203
27215
  throw new ApiError("Pendle api request failed");
27204
27216
 
27205
- case 11:
27217
+ case 12:
27206
27218
  allInactiveMarkets = inactiveMarketResult.data.markets;
27207
27219
  markets = [tokenIn, tokenOut].map(function (token) {
27208
27220
  return allInactiveMarkets.find(function (market) {
@@ -27211,30 +27223,30 @@ var checkExitPostExpPT = /*#__PURE__*/function () {
27211
27223
  });
27212
27224
 
27213
27225
  if (!markets[0]) {
27214
- _context.next = 18;
27226
+ _context.next = 19;
27215
27227
  break;
27216
27228
  }
27217
27229
 
27218
27230
  checkUnderlying(markets[0], tokenOut, networkId);
27219
27231
  return _context.abrupt("return", markets[0].address);
27220
27232
 
27221
- case 18:
27233
+ case 19:
27222
27234
  if (!markets[1]) {
27223
- _context.next = 22;
27235
+ _context.next = 23;
27224
27236
  break;
27225
27237
  }
27226
27238
 
27227
27239
  throw new Error("Can not trade to expired PT asset");
27228
27240
 
27229
- case 22:
27241
+ case 23:
27230
27242
  return _context.abrupt("return", null);
27231
27243
 
27232
- case 23:
27244
+ case 24:
27233
27245
  case "end":
27234
27246
  return _context.stop();
27235
27247
  }
27236
27248
  }
27237
- }, _callee, null, [[1, 7]]);
27249
+ }, _callee, null, [[1, 8]]);
27238
27250
  }));
27239
27251
 
27240
27252
  return function checkExitPostExpPT(_x9, _x10, _x11) {
@@ -27905,7 +27917,10 @@ function _getKyberSwapTxData() {
27905
27917
  _context.prev = 1;
27906
27918
  _context.next = 4;
27907
27919
  return axios.get(kyberBaseUrl + "/" + pool.network + "/api/v1/routes", {
27908
- params: params
27920
+ params: params,
27921
+ headers: {
27922
+ "x-client-id": "dHEDGE"
27923
+ }
27909
27924
  });
27910
27925
 
27911
27926
  case 4:
@@ -27918,7 +27933,11 @@ function _getKyberSwapTxData() {
27918
27933
 
27919
27934
  };
27920
27935
  _context.next = 8;
27921
- return axios.post(kyberBaseUrl + "/" + pool.network + "/api/v1/route/build", buildParams);
27936
+ return axios.post(kyberBaseUrl + "/" + pool.network + "/api/v1/route/build", buildParams, {
27937
+ headers: {
27938
+ "x-client-id": "dHEDGE"
27939
+ }
27940
+ });
27922
27941
 
27923
27942
  case 8:
27924
27943
  buildResult = _context.sent;