@dhedge/v2-sdk 1.11.0 → 2.0.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.
@@ -10514,6 +10514,7 @@ var CONTRACT_ADDRESS = (_CONTRACT_ADDRESS = {}, _CONTRACT_ADDRESS[exports.Networ
10514
10514
  VELODROME_CL_USDC_WETH_GAUGE: "",
10515
10515
  VELO: "",
10516
10516
  COMPOUNDV3_WETH: "",
10517
+ FLUID_WETH: "",
10517
10518
  TOROS: "",
10518
10519
  UNIT: ""
10519
10520
  }, _CONTRACT_ADDRESS[exports.Network.OPTIMISM] = {
@@ -10535,6 +10536,7 @@ var CONTRACT_ADDRESS = (_CONTRACT_ADDRESS = {}, _CONTRACT_ADDRESS[exports.Networ
10535
10536
  VELODROME_CL_USDC_WETH_GAUGE: "0xa75127121d28a9BF848F3B70e7Eea26570aa7700",
10536
10537
  VELO: "0x9560e827aF36c94D2Ac33a39bCE1Fe78631088Db",
10537
10538
  COMPOUNDV3_WETH: "",
10539
+ FLUID_WETH: "",
10538
10540
  TOROS: "0x49bf093277bf4dde49c48c6aa55a3bda3eedef68" //USDmny
10539
10541
 
10540
10542
  }, _CONTRACT_ADDRESS[exports.Network.ARBITRUM] = {
@@ -10558,6 +10560,7 @@ var CONTRACT_ADDRESS = (_CONTRACT_ADDRESS = {}, _CONTRACT_ADDRESS[exports.Networ
10558
10560
  VELODROME_CL_USDC_WETH_GAUGE: "",
10559
10561
  VELO: "",
10560
10562
  COMPOUNDV3_WETH: "0x6f7D514bbD4aFf3BcD1140B7344b32f063dEe486",
10563
+ FLUID_WETH: "0x45df0656f8adf017590009d2f1898eeca4f0a205",
10561
10564
  TOROS: ""
10562
10565
  }, _CONTRACT_ADDRESS[exports.Network.BASE] = {
10563
10566
  USDC: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
@@ -10577,6 +10580,7 @@ var CONTRACT_ADDRESS = (_CONTRACT_ADDRESS = {}, _CONTRACT_ADDRESS[exports.Networ
10577
10580
  VELODROME_CL_USDC_WETH_GAUGE: "0xF33a96b5932D9E9B9A0eDA447AbD8C9d48d2e0c8",
10578
10581
  VELO: "0x940181a94A35A4569E4529A3CDfB74e38FD98631",
10579
10582
  COMPOUNDV3_WETH: "",
10583
+ FLUID_WETH: "",
10580
10584
  TOROS: ""
10581
10585
  }, _CONTRACT_ADDRESS[exports.Network.ETHEREUM] = {
10582
10586
  USDC: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
@@ -10595,6 +10599,7 @@ var CONTRACT_ADDRESS = (_CONTRACT_ADDRESS = {}, _CONTRACT_ADDRESS[exports.Networ
10595
10599
  VELODROME_CL_USDC_WETH_GAUGE: "",
10596
10600
  VELO: "",
10597
10601
  COMPOUNDV3_WETH: "",
10602
+ FLUID_WETH: "",
10598
10603
  TOROS: "",
10599
10604
  UNIT: ""
10600
10605
  }, _CONTRACT_ADDRESS);
@@ -16124,68 +16129,108 @@ function _call() {
16124
16129
  }
16125
16130
  var getPoolTxOrGasEstimate = /*#__PURE__*/function () {
16126
16131
  var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(pool, args, estimateGas) {
16132
+ var gas, gasEstimationError, _gas, _gasEstimationError;
16133
+
16127
16134
  return runtime_1.wrap(function _callee2$(_context2) {
16128
16135
  while (1) {
16129
16136
  switch (_context2.prev = _context2.next) {
16130
16137
  case 0:
16131
16138
  if (!pool.isDhedge) {
16132
- _context2.next = 12;
16139
+ _context2.next = 21;
16133
16140
  break;
16134
16141
  }
16135
16142
 
16136
16143
  if (!estimateGas) {
16137
- _context2.next = 7;
16144
+ _context2.next = 16;
16138
16145
  break;
16139
16146
  }
16140
16147
 
16141
- _context2.next = 4;
16148
+ gas = null;
16149
+ gasEstimationError = null;
16150
+ _context2.prev = 4;
16151
+ _context2.next = 7;
16142
16152
  return pool.poolLogic.estimateGas.execTransaction(args[0], args[1], args[2]);
16143
16153
 
16144
- case 4:
16145
- return _context2.abrupt("return", _context2.sent);
16146
-
16147
16154
  case 7:
16148
- _context2.next = 9;
16155
+ gas = _context2.sent;
16156
+ _context2.next = 13;
16157
+ break;
16158
+
16159
+ case 10:
16160
+ _context2.prev = 10;
16161
+ _context2.t0 = _context2["catch"](4);
16162
+ gasEstimationError = _context2.t0;
16163
+
16164
+ case 13:
16165
+ return _context2.abrupt("return", {
16166
+ gas: gas,
16167
+ txData: args[1],
16168
+ to: args[0],
16169
+ gasEstimationError: gasEstimationError,
16170
+ minAmountOut: args[3] || null
16171
+ });
16172
+
16173
+ case 16:
16174
+ _context2.next = 18;
16149
16175
  return pool.poolLogic.execTransaction(args[0], args[1], args[2]);
16150
16176
 
16151
- case 9:
16177
+ case 18:
16152
16178
  return _context2.abrupt("return", _context2.sent);
16153
16179
 
16154
- case 10:
16155
- _context2.next = 21;
16180
+ case 19:
16181
+ _context2.next = 39;
16156
16182
  break;
16157
16183
 
16158
- case 12:
16184
+ case 21:
16159
16185
  if (!estimateGas) {
16160
- _context2.next = 18;
16186
+ _context2.next = 36;
16161
16187
  break;
16162
16188
  }
16163
16189
 
16164
- _context2.next = 15;
16190
+ _gas = null;
16191
+ _gasEstimationError = null;
16192
+ _context2.prev = 24;
16193
+ _context2.next = 27;
16165
16194
  return pool.signer.estimateGas({
16166
16195
  to: args[0],
16167
16196
  data: args[1]
16168
16197
  });
16169
16198
 
16170
- case 15:
16171
- return _context2.abrupt("return", _context2.sent);
16199
+ case 27:
16200
+ _gas = _context2.sent;
16201
+ _context2.next = 33;
16202
+ break;
16172
16203
 
16173
- case 18:
16174
- _context2.next = 20;
16204
+ case 30:
16205
+ _context2.prev = 30;
16206
+ _context2.t1 = _context2["catch"](24);
16207
+ _gasEstimationError = _context2.t1;
16208
+
16209
+ case 33:
16210
+ return _context2.abrupt("return", {
16211
+ gas: _gas,
16212
+ txData: args[1],
16213
+ to: args[0],
16214
+ gasEstimationError: _gasEstimationError,
16215
+ minAmountOut: args[3] || null
16216
+ });
16217
+
16218
+ case 36:
16219
+ _context2.next = 38;
16175
16220
  return pool.signer.sendTransaction(_extends({
16176
16221
  to: args[0],
16177
16222
  data: args[1]
16178
16223
  }, args[2]));
16179
16224
 
16180
- case 20:
16225
+ case 38:
16181
16226
  return _context2.abrupt("return", _context2.sent);
16182
16227
 
16183
- case 21:
16228
+ case 39:
16184
16229
  case "end":
16185
16230
  return _context2.stop();
16186
16231
  }
16187
16232
  }
16188
- }, _callee2);
16233
+ }, _callee2, null, [[4, 10], [24, 30]]);
16189
16234
  }));
16190
16235
 
16191
16236
  return function getPoolTxOrGasEstimate(_x12, _x13, _x14) {
@@ -23908,11 +23953,162 @@ var ICompoundV3Comet = [
23908
23953
  }
23909
23954
  ];
23910
23955
 
23911
- function getCompoundV3LendTxData(asset, amount) {
23912
- return new ethers.ethers.utils.Interface(ICompoundV3Comet).encodeFunctionData("supply", [asset, amount]);
23956
+ var IFToken = [
23957
+ {
23958
+ inputs: [
23959
+ {
23960
+ internalType: "uint256",
23961
+ name: "assets_",
23962
+ type: "uint256"
23963
+ },
23964
+ {
23965
+ internalType: "address",
23966
+ name: "receiver_",
23967
+ type: "address"
23968
+ }
23969
+ ],
23970
+ name: "deposit",
23971
+ outputs: [
23972
+ {
23973
+ internalType: "uint256",
23974
+ name: "shares_",
23975
+ type: "uint256"
23976
+ }
23977
+ ],
23978
+ stateMutability: "nonpayable",
23979
+ type: "function"
23980
+ },
23981
+ {
23982
+ inputs: [
23983
+ {
23984
+ internalType: "uint256",
23985
+ name: "shares_",
23986
+ type: "uint256"
23987
+ },
23988
+ {
23989
+ internalType: "address",
23990
+ name: "receiver_",
23991
+ type: "address"
23992
+ },
23993
+ {
23994
+ internalType: "address",
23995
+ name: "owner_",
23996
+ type: "address"
23997
+ }
23998
+ ],
23999
+ name: "redeem",
24000
+ outputs: [
24001
+ {
24002
+ internalType: "uint256",
24003
+ name: "assets_",
24004
+ type: "uint256"
24005
+ }
24006
+ ],
24007
+ stateMutability: "nonpayable",
24008
+ type: "function"
24009
+ }
24010
+ ];
24011
+
24012
+ function getCompoundV3LendTxData(_x, _x2, _x3, _x4) {
24013
+ return _getCompoundV3LendTxData.apply(this, arguments);
24014
+ }
24015
+
24016
+ function _getCompoundV3LendTxData() {
24017
+ _getCompoundV3LendTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(pool, market, asset, amount) {
24018
+ return runtime_1.wrap(function _callee$(_context) {
24019
+ while (1) {
24020
+ switch (_context.prev = _context.next) {
24021
+ case 0:
24022
+ _context.next = 2;
24023
+ return isCompoundV3Market(pool, market);
24024
+
24025
+ case 2:
24026
+ if (!_context.sent) {
24027
+ _context.next = 6;
24028
+ break;
24029
+ }
24030
+
24031
+ return _context.abrupt("return", new ethers.ethers.utils.Interface(ICompoundV3Comet).encodeFunctionData("supply", [asset, amount]));
24032
+
24033
+ case 6:
24034
+ return _context.abrupt("return", new ethers.ethers.utils.Interface(IFToken).encodeFunctionData("deposit", [amount, pool.address]));
24035
+
24036
+ case 7:
24037
+ case "end":
24038
+ return _context.stop();
24039
+ }
24040
+ }
24041
+ }, _callee);
24042
+ }));
24043
+ return _getCompoundV3LendTxData.apply(this, arguments);
24044
+ }
24045
+
24046
+ function getCompoundV3WithdrawTxData(_x5, _x6, _x7, _x8) {
24047
+ return _getCompoundV3WithdrawTxData.apply(this, arguments);
24048
+ }
24049
+
24050
+ function _getCompoundV3WithdrawTxData() {
24051
+ _getCompoundV3WithdrawTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(pool, market, asset, amount) {
24052
+ return runtime_1.wrap(function _callee2$(_context2) {
24053
+ while (1) {
24054
+ switch (_context2.prev = _context2.next) {
24055
+ case 0:
24056
+ _context2.next = 2;
24057
+ return isCompoundV3Market(pool, market);
24058
+
24059
+ case 2:
24060
+ if (!_context2.sent) {
24061
+ _context2.next = 6;
24062
+ break;
24063
+ }
24064
+
24065
+ return _context2.abrupt("return", new ethers.ethers.utils.Interface(ICompoundV3Comet).encodeFunctionData("withdraw", [asset, amount]));
24066
+
24067
+ case 6:
24068
+ return _context2.abrupt("return", new ethers.ethers.utils.Interface(IFToken).encodeFunctionData("redeem", [amount, pool.address, pool.address]));
24069
+
24070
+ case 7:
24071
+ case "end":
24072
+ return _context2.stop();
24073
+ }
24074
+ }
24075
+ }, _callee2);
24076
+ }));
24077
+ return _getCompoundV3WithdrawTxData.apply(this, arguments);
23913
24078
  }
23914
- function getCompoundV3WithdrawTxData(asset, amount) {
23915
- return new ethers.ethers.utils.Interface(ICompoundV3Comet).encodeFunctionData("withdraw", [asset, amount]);
24079
+
24080
+ function isCompoundV3Market(_x9, _x10) {
24081
+ return _isCompoundV3Market.apply(this, arguments);
24082
+ }
24083
+
24084
+ function _isCompoundV3Market() {
24085
+ _isCompoundV3Market = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(pool, market) {
24086
+ var marketContract;
24087
+ return runtime_1.wrap(function _callee3$(_context3) {
24088
+ while (1) {
24089
+ switch (_context3.prev = _context3.next) {
24090
+ case 0:
24091
+ marketContract = new ethers.ethers.Contract(market, ICompoundV3Comet, pool.signer);
24092
+ _context3.prev = 1;
24093
+ _context3.next = 4;
24094
+ return marketContract.baseToken();
24095
+
24096
+ case 4:
24097
+ return _context3.abrupt("return", true);
24098
+
24099
+ case 7:
24100
+ _context3.prev = 7;
24101
+ _context3.t0 = _context3["catch"](1);
24102
+ return _context3.abrupt("return", false);
24103
+
24104
+ case 10:
24105
+ case "end":
24106
+ return _context3.stop();
24107
+ }
24108
+ }
24109
+ }, _callee3, null, [[1, 7]]);
24110
+ }));
24111
+ return _isCompoundV3Market.apply(this, arguments);
23916
24112
  }
23917
24113
 
23918
24114
  var ICometRewards = [
@@ -24404,7 +24600,10 @@ function _getOdosSwapTxData() {
24404
24600
 
24405
24601
  case 10:
24406
24602
  assembleResult = _context.sent;
24407
- return _context.abrupt("return", assembleResult.data.transaction.data);
24603
+ return _context.abrupt("return", {
24604
+ swapTxData: assembleResult.data.transaction.data,
24605
+ minAmountOut: assembleResult.data.outputTokens[0].amount
24606
+ });
24408
24607
 
24409
24608
  case 14:
24410
24609
  _context.prev = 14;
@@ -24545,66 +24744,111 @@ var ActionMiscV3Abi = [
24545
24744
  }
24546
24745
  ];
24547
24746
 
24747
+ var PTAbi = [
24748
+ {
24749
+ inputs: [
24750
+ ],
24751
+ name: "SY",
24752
+ outputs: [
24753
+ {
24754
+ internalType: "address",
24755
+ name: "",
24756
+ type: "address"
24757
+ }
24758
+ ],
24759
+ stateMutability: "view",
24760
+ type: "function"
24761
+ }
24762
+ ];
24763
+
24764
+ var SYAbi = [
24765
+ {
24766
+ inputs: [
24767
+ ],
24768
+ name: "exchangeRate",
24769
+ outputs: [
24770
+ {
24771
+ internalType: "uint256",
24772
+ name: "",
24773
+ type: "uint256"
24774
+ }
24775
+ ],
24776
+ stateMutability: "view",
24777
+ type: "function"
24778
+ }
24779
+ ];
24780
+
24548
24781
  var pendleBaseUrl = "https://api-v2.pendle.finance/core/v1";
24549
24782
  function getPendleSwapTxData(_x, _x2, _x3, _x4, _x5) {
24550
24783
  return _getPendleSwapTxData.apply(this, arguments);
24551
24784
  }
24552
24785
 
24553
24786
  function _getPendleSwapTxData() {
24554
- _getPendleSwapTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(pool, tokenIn, tokenOut, amountIn, slippage) {
24555
- var expiredMarket, params, market, swapResult;
24556
- return runtime_1.wrap(function _callee2$(_context2) {
24787
+ _getPendleSwapTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(pool, tokenIn, tokenOut, amountIn, slippage) {
24788
+ var expiredMarket, result, params, market, swapResult;
24789
+ return runtime_1.wrap(function _callee3$(_context3) {
24557
24790
  while (1) {
24558
- switch (_context2.prev = _context2.next) {
24791
+ switch (_context3.prev = _context3.next) {
24559
24792
  case 0:
24560
- _context2.next = 2;
24793
+ _context3.next = 2;
24561
24794
  return checkExitPostExpPT(pool, tokenIn, tokenOut);
24562
24795
 
24563
24796
  case 2:
24564
- expiredMarket = _context2.sent;
24797
+ expiredMarket = _context3.sent;
24565
24798
 
24566
24799
  if (!expiredMarket) {
24567
- _context2.next = 5;
24800
+ _context3.next = 8;
24568
24801
  break;
24569
24802
  }
24570
24803
 
24571
- return _context2.abrupt("return", getExitExpPTTxData(pool, tokenOut, amountIn, expiredMarket));
24804
+ _context3.next = 6;
24805
+ return getExitExpPTTxData(pool, tokenIn, tokenOut, amountIn, expiredMarket);
24572
24806
 
24573
- case 5:
24807
+ case 6:
24808
+ result = _context3.sent;
24809
+ return _context3.abrupt("return", {
24810
+ swapTxData: result.txData,
24811
+ minAmountOut: result.minAmountOut
24812
+ });
24813
+
24814
+ case 8:
24574
24815
  params = {
24575
24816
  receiver: pool.address,
24576
24817
  tokenIn: tokenIn,
24577
24818
  tokenOut: tokenOut,
24578
24819
  amountIn: amountIn.toString(),
24579
- slippage: slippage
24820
+ slippage: slippage / 100
24580
24821
  };
24581
- _context2.next = 8;
24822
+ _context3.next = 11;
24582
24823
  return getMarket(pool, tokenIn, tokenOut);
24583
24824
 
24584
- case 8:
24585
- market = _context2.sent;
24586
- _context2.prev = 9;
24587
- _context2.next = 12;
24825
+ case 11:
24826
+ market = _context3.sent;
24827
+ _context3.prev = 12;
24828
+ _context3.next = 15;
24588
24829
  return axios.get(pendleBaseUrl + "/sdk/" + networkChainIdMap[pool.network] + "/markets/" + market + "/swap", {
24589
24830
  params: params
24590
24831
  });
24591
24832
 
24592
- case 12:
24593
- swapResult = _context2.sent;
24594
- return _context2.abrupt("return", swapResult.data.tx.data);
24833
+ case 15:
24834
+ swapResult = _context3.sent;
24835
+ return _context3.abrupt("return", {
24836
+ swapTxData: swapResult.data.tx.data,
24837
+ minAmountOut: swapResult.data.data.amountOut
24838
+ });
24595
24839
 
24596
- case 16:
24597
- _context2.prev = 16;
24598
- _context2.t0 = _context2["catch"](9);
24599
- console.error("Error in Pendle API request:", _context2.t0);
24840
+ case 19:
24841
+ _context3.prev = 19;
24842
+ _context3.t0 = _context3["catch"](12);
24843
+ console.error("Error in Pendle API request:", _context3.t0);
24600
24844
  throw new ApiError("Pendle api request failed");
24601
24845
 
24602
- case 20:
24846
+ case 23:
24603
24847
  case "end":
24604
- return _context2.stop();
24848
+ return _context3.stop();
24605
24849
  }
24606
24850
  }
24607
- }, _callee2, null, [[9, 16]]);
24851
+ }, _callee3, null, [[12, 19]]);
24608
24852
  }));
24609
24853
  return _getPendleSwapTxData.apply(this, arguments);
24610
24854
  }
@@ -24620,26 +24864,26 @@ function getMarket(_x6, _x7, _x8) {
24620
24864
  }
24621
24865
 
24622
24866
  function _getMarket() {
24623
- _getMarket = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(pool, tokenIn, tokenOut) {
24867
+ _getMarket = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(pool, tokenIn, tokenOut) {
24624
24868
  var networkId, marketResult, allMarkets, markets;
24625
- return runtime_1.wrap(function _callee3$(_context3) {
24869
+ return runtime_1.wrap(function _callee4$(_context4) {
24626
24870
  while (1) {
24627
- switch (_context3.prev = _context3.next) {
24871
+ switch (_context4.prev = _context4.next) {
24628
24872
  case 0:
24629
24873
  networkId = networkChainIdMap[pool.network];
24630
- _context3.prev = 1;
24631
- _context3.next = 4;
24874
+ _context4.prev = 1;
24875
+ _context4.next = 4;
24632
24876
  return axios.get(pendleBaseUrl + "/" + networkId + "/markets/active");
24633
24877
 
24634
24878
  case 4:
24635
- marketResult = _context3.sent;
24636
- _context3.next = 11;
24879
+ marketResult = _context4.sent;
24880
+ _context4.next = 11;
24637
24881
  break;
24638
24882
 
24639
24883
  case 7:
24640
- _context3.prev = 7;
24641
- _context3.t0 = _context3["catch"](1);
24642
- console.error("Error in Pendle API request:", _context3.t0);
24884
+ _context4.prev = 7;
24885
+ _context4.t0 = _context4["catch"](1);
24886
+ console.error("Error in Pendle API request:", _context4.t0);
24643
24887
  throw new ApiError("Pendle api request failed");
24644
24888
 
24645
24889
  case 11:
@@ -24651,31 +24895,31 @@ function _getMarket() {
24651
24895
  });
24652
24896
 
24653
24897
  if (!markets[0]) {
24654
- _context3.next = 18;
24898
+ _context4.next = 18;
24655
24899
  break;
24656
24900
  }
24657
24901
 
24658
24902
  checkUnderlying(markets[0], tokenOut, networkId);
24659
- return _context3.abrupt("return", markets[0].address);
24903
+ return _context4.abrupt("return", markets[0].address);
24660
24904
 
24661
24905
  case 18:
24662
24906
  if (!markets[1]) {
24663
- _context3.next = 23;
24907
+ _context4.next = 23;
24664
24908
  break;
24665
24909
  }
24666
24910
 
24667
24911
  checkUnderlying(markets[1], tokenIn, networkId);
24668
- return _context3.abrupt("return", markets[1].address);
24912
+ return _context4.abrupt("return", markets[1].address);
24669
24913
 
24670
24914
  case 23:
24671
24915
  throw new Error("Can only trade PT assets");
24672
24916
 
24673
24917
  case 24:
24674
24918
  case "end":
24675
- return _context3.stop();
24919
+ return _context4.stop();
24676
24920
  }
24677
24921
  }
24678
- }, _callee3, null, [[1, 7]]);
24922
+ }, _callee4, null, [[1, 7]]);
24679
24923
  }));
24680
24924
  return _getMarket.apply(this, arguments);
24681
24925
  }
@@ -24743,13 +24987,52 @@ var checkExitPostExpPT = /*#__PURE__*/function () {
24743
24987
  };
24744
24988
  }();
24745
24989
 
24746
- var getExitExpPTTxData = function getExitExpPTTxData(pool, tokenOut, amountIn, market) {
24747
- var actionMiscV3 = new ethers.ethers.utils.Interface(ActionMiscV3Abi);
24748
- var txData = actionMiscV3.encodeFunctionData("exitPostExpToToken", [pool.address, market, amountIn.toString(), 0, [tokenOut, 0, tokenOut, ethers.ethers.constants.AddressZero, // swapData
24749
- [0, ethers.ethers.constants.AddressZero, ethers.ethers.constants.HashZero, false // needScale
24750
- ]]]);
24751
- return txData;
24752
- };
24990
+ var getExitExpPTTxData = /*#__PURE__*/function () {
24991
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(pool, tokenIn, tokenOut, amountIn, market) {
24992
+ var actionMiscV3, txData, PTcontract, SYcontract, exchangeRate, minAmountOut;
24993
+ return runtime_1.wrap(function _callee2$(_context2) {
24994
+ while (1) {
24995
+ switch (_context2.prev = _context2.next) {
24996
+ case 0:
24997
+ actionMiscV3 = new ethers.ethers.utils.Interface(ActionMiscV3Abi);
24998
+ txData = actionMiscV3.encodeFunctionData("exitPostExpToToken", [pool.address, market, amountIn.toString(), 0, [tokenOut, 0, tokenOut, ethers.ethers.constants.AddressZero, // swapData
24999
+ [0, ethers.ethers.constants.AddressZero, ethers.ethers.constants.HashZero, false // needScale
25000
+ ]]]); // Get the PT contract instance
25001
+
25002
+ PTcontract = new ethers.ethers.Contract(tokenIn, PTAbi, pool.signer); // Get the SY contract instance
25003
+
25004
+ _context2.t0 = ethers.ethers.Contract;
25005
+ _context2.next = 6;
25006
+ return PTcontract.SY();
25007
+
25008
+ case 6:
25009
+ _context2.t1 = _context2.sent;
25010
+ _context2.t2 = SYAbi;
25011
+ _context2.t3 = pool.signer;
25012
+ SYcontract = new _context2.t0(_context2.t1, _context2.t2, _context2.t3);
25013
+ _context2.next = 12;
25014
+ return SYcontract.exchangeRate();
25015
+
25016
+ case 12:
25017
+ exchangeRate = _context2.sent;
25018
+ minAmountOut = new BigNumber(amountIn.toString()).times(1e18).div(exchangeRate.toString()).decimalPlaces(0, BigNumber.ROUND_DOWN).toFixed(0);
25019
+ return _context2.abrupt("return", {
25020
+ txData: txData,
25021
+ minAmountOut: minAmountOut
25022
+ });
25023
+
25024
+ case 15:
25025
+ case "end":
25026
+ return _context2.stop();
25027
+ }
25028
+ }
25029
+ }, _callee2);
25030
+ }));
25031
+
25032
+ return function getExitExpPTTxData(_x12, _x13, _x14, _x15, _x16) {
25033
+ return _ref2.apply(this, arguments);
25034
+ };
25035
+ }();
24753
25036
 
24754
25037
  var Pool = /*#__PURE__*/function () {
24755
25038
  function Pool(network, signer, poolLogic, mangerLogic, utils, factory, isDhedge) {
@@ -25269,7 +25552,7 @@ var Pool = /*#__PURE__*/function () {
25269
25552
  /*#__PURE__*/
25270
25553
  function () {
25271
25554
  var _trade = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(dapp, assetFrom, assetTo, amountIn, slippage, options, estimateGas) {
25272
- var swapTxData, _yield$getOneInchSwap, iSynthetix, assets, daoAddress, iUniswapV2Router, minAmountOut, tx;
25555
+ var swapTxData, minAmountOut, _yield$getOneInchSwap, iSynthetix, assets, daoAddress, _yield$getOdosSwapTxD, _yield$getPendleSwapT, iUniswapV2Router, calculatedMinAmountOut, tx;
25273
25556
 
25274
25557
  return runtime_1.wrap(function _callee10$(_context10) {
25275
25558
  while (1) {
@@ -25287,94 +25570,100 @@ var Pool = /*#__PURE__*/function () {
25287
25570
  estimateGas = false;
25288
25571
  }
25289
25572
 
25573
+ minAmountOut = null;
25290
25574
  _context10.t0 = dapp;
25291
- _context10.next = _context10.t0 === exports.Dapp.ONEINCH ? 6 : _context10.t0 === exports.Dapp.BALANCER ? 11 : _context10.t0 === exports.Dapp.SYNTHETIX ? 15 : _context10.t0 === exports.Dapp.TOROS ? 22 : _context10.t0 === exports.Dapp.ODOS ? 26 : _context10.t0 === exports.Dapp.PENDLE ? 30 : 34;
25575
+ _context10.next = _context10.t0 === exports.Dapp.ONEINCH ? 7 : _context10.t0 === exports.Dapp.BALANCER ? 13 : _context10.t0 === exports.Dapp.SYNTHETIX ? 17 : _context10.t0 === exports.Dapp.TOROS ? 24 : _context10.t0 === exports.Dapp.ODOS ? 28 : _context10.t0 === exports.Dapp.PENDLE ? 34 : 40;
25292
25576
  break;
25293
25577
 
25294
- case 6:
25295
- _context10.next = 8;
25578
+ case 7:
25579
+ _context10.next = 9;
25296
25580
  return getOneInchSwapTxData(this, assetFrom, assetTo, amountIn, slippage);
25297
25581
 
25298
- case 8:
25582
+ case 9:
25299
25583
  _yield$getOneInchSwap = _context10.sent;
25300
25584
  swapTxData = _yield$getOneInchSwap.swapTxData;
25301
- return _context10.abrupt("break", 49);
25585
+ minAmountOut = _yield$getOneInchSwap.dstAmount;
25586
+ return _context10.abrupt("break", 55);
25302
25587
 
25303
- case 11:
25304
- _context10.next = 13;
25588
+ case 13:
25589
+ _context10.next = 15;
25305
25590
  return this.utils.getBalancerSwapTx(this, assetFrom, assetTo, amountIn, slippage);
25306
25591
 
25307
- case 13:
25592
+ case 15:
25308
25593
  swapTxData = _context10.sent;
25309
- return _context10.abrupt("break", 49);
25594
+ return _context10.abrupt("break", 55);
25310
25595
 
25311
- case 15:
25596
+ case 17:
25312
25597
  iSynthetix = new ethers.ethers.utils.Interface(ISynthetix.abi);
25313
25598
  assets = [assetFrom, assetTo].map(function (asset) {
25314
25599
  return ethers.ethers.utils.formatBytes32String(asset);
25315
25600
  });
25316
- _context10.next = 19;
25601
+ _context10.next = 21;
25317
25602
  return this.factory.owner();
25318
25603
 
25319
- case 19:
25604
+ case 21:
25320
25605
  daoAddress = _context10.sent;
25321
25606
  swapTxData = iSynthetix.encodeFunctionData(exports.Transaction.SWAP_SYNTHS, [assets[0], amountIn, assets[1], daoAddress, SYNTHETIX_TRACKING_CODE]);
25322
- return _context10.abrupt("break", 49);
25323
-
25324
- case 22:
25325
- _context10.next = 24;
25326
- return getEasySwapperTxData(this, assetFrom, assetTo, ethers.ethers.BigNumber.from(amountIn), slippage);
25607
+ return _context10.abrupt("break", 55);
25327
25608
 
25328
25609
  case 24:
25329
- swapTxData = _context10.sent;
25330
- return _context10.abrupt("break", 49);
25610
+ _context10.next = 26;
25611
+ return getEasySwapperTxData(this, assetFrom, assetTo, ethers.ethers.BigNumber.from(amountIn), slippage);
25331
25612
 
25332
25613
  case 26:
25333
- _context10.next = 28;
25334
- return getOdosSwapTxData(this, assetFrom, assetTo, amountIn, slippage);
25614
+ swapTxData = _context10.sent;
25615
+ return _context10.abrupt("break", 55);
25335
25616
 
25336
25617
  case 28:
25337
- swapTxData = _context10.sent;
25338
- return _context10.abrupt("break", 49);
25618
+ _context10.next = 30;
25619
+ return getOdosSwapTxData(this, assetFrom, assetTo, amountIn, slippage);
25339
25620
 
25340
25621
  case 30:
25341
- _context10.next = 32;
25622
+ _yield$getOdosSwapTxD = _context10.sent;
25623
+ swapTxData = _yield$getOdosSwapTxD.swapTxData;
25624
+ minAmountOut = _yield$getOdosSwapTxD.minAmountOut;
25625
+ return _context10.abrupt("break", 55);
25626
+
25627
+ case 34:
25628
+ _context10.next = 36;
25342
25629
  return getPendleSwapTxData(this, assetFrom, assetTo, amountIn, slippage);
25343
25630
 
25344
- case 32:
25345
- swapTxData = _context10.sent;
25346
- return _context10.abrupt("break", 49);
25631
+ case 36:
25632
+ _yield$getPendleSwapT = _context10.sent;
25633
+ swapTxData = _yield$getPendleSwapT.swapTxData;
25634
+ minAmountOut = _yield$getPendleSwapT.minAmountOut;
25635
+ return _context10.abrupt("break", 55);
25347
25636
 
25348
- case 34:
25637
+ case 40:
25349
25638
  iUniswapV2Router = new ethers.ethers.utils.Interface(IUniswapV2Router.abi);
25350
- _context10.next = 37;
25639
+ _context10.next = 43;
25351
25640
  return this.utils.getMinAmountOut(dapp, assetFrom, assetTo, amountIn, slippage);
25352
25641
 
25353
- case 37:
25354
- minAmountOut = _context10.sent;
25642
+ case 43:
25643
+ calculatedMinAmountOut = _context10.sent;
25355
25644
  _context10.t1 = iUniswapV2Router;
25356
25645
  _context10.t2 = exports.Transaction.SWAP;
25357
25646
  _context10.t3 = amountIn;
25358
- _context10.t4 = minAmountOut;
25647
+ _context10.t4 = calculatedMinAmountOut;
25359
25648
  _context10.t5 = [assetFrom, assetTo];
25360
25649
  _context10.t6 = this.address;
25361
- _context10.next = 46;
25650
+ _context10.next = 52;
25362
25651
  return getDeadline(this);
25363
25652
 
25364
- case 46:
25653
+ case 52:
25365
25654
  _context10.t7 = _context10.sent;
25366
25655
  _context10.t8 = [_context10.t3, _context10.t4, _context10.t5, _context10.t6, _context10.t7];
25367
25656
  swapTxData = _context10.t1.encodeFunctionData.call(_context10.t1, _context10.t2, _context10.t8);
25368
25657
 
25369
- case 49:
25370
- _context10.next = 51;
25371
- return getPoolTxOrGasEstimate(this, [routerAddress[this.network][dapp], swapTxData, options], estimateGas);
25658
+ case 55:
25659
+ _context10.next = 57;
25660
+ return getPoolTxOrGasEstimate(this, [routerAddress[this.network][dapp], swapTxData, options, minAmountOut], estimateGas);
25372
25661
 
25373
- case 51:
25662
+ case 57:
25374
25663
  tx = _context10.sent;
25375
25664
  return _context10.abrupt("return", tx);
25376
25665
 
25377
- case 53:
25666
+ case 59:
25378
25667
  case "end":
25379
25668
  return _context10.stop();
25380
25669
  }
@@ -25820,8 +26109,8 @@ var Pool = /*#__PURE__*/function () {
25820
26109
  return lend;
25821
26110
  }()
25822
26111
  /**
25823
- * Lend asset to a Compound V3 style lending pool
25824
- * @param {string} market Address of market e.g cUSDCv3 address
26112
+ * Lend asset to a Compound V3 or Fluid lending pool
26113
+ * @param {string} market Address of cToken or fToken
25825
26114
  * @param {string} asset Asset
25826
26115
  * @param {BigNumber | string} amount Amount of asset to lend
25827
26116
  * @param {any} options Transaction options
@@ -25847,15 +26136,19 @@ var Pool = /*#__PURE__*/function () {
25847
26136
  estimateGas = false;
25848
26137
  }
25849
26138
 
25850
- supplyTxData = getCompoundV3LendTxData(asset, amount);
25851
- _context18.next = 5;
26139
+ _context18.next = 4;
26140
+ return getCompoundV3LendTxData(this, market, asset, amount);
26141
+
26142
+ case 4:
26143
+ supplyTxData = _context18.sent;
26144
+ _context18.next = 7;
25852
26145
  return getPoolTxOrGasEstimate(this, [market, supplyTxData, options], estimateGas);
25853
26146
 
25854
- case 5:
26147
+ case 7:
25855
26148
  tx = _context18.sent;
25856
26149
  return _context18.abrupt("return", tx);
25857
26150
 
25858
- case 7:
26151
+ case 9:
25859
26152
  case "end":
25860
26153
  return _context18.stop();
25861
26154
  }
@@ -25921,8 +26214,8 @@ var Pool = /*#__PURE__*/function () {
25921
26214
  return withdrawDeposit;
25922
26215
  }()
25923
26216
  /**
25924
- * Witdraw asset from a COmpound V3 style lending pool
25925
- * @param {string} market Address of market e.g cUSDCv3 address
26217
+ * Witdraw asset from a Compound V3 or Fluid lending pool
26218
+ * @param {string} market Address of cToken or fToken
25926
26219
  * @param {string} asset Asset
25927
26220
  * @param {BigNumber | string} amount Amount of asset to withdraw
25928
26221
  * @param {any} options Transaction options
@@ -25948,15 +26241,19 @@ var Pool = /*#__PURE__*/function () {
25948
26241
  estimateGas = false;
25949
26242
  }
25950
26243
 
25951
- withdrawTxData = getCompoundV3WithdrawTxData(asset, amount);
25952
- _context20.next = 5;
26244
+ _context20.next = 4;
26245
+ return getCompoundV3WithdrawTxData(this, market, asset, amount);
26246
+
26247
+ case 4:
26248
+ withdrawTxData = _context20.sent;
26249
+ _context20.next = 7;
25953
26250
  return getPoolTxOrGasEstimate(this, [market, withdrawTxData, options], estimateGas);
25954
26251
 
25955
- case 5:
26252
+ case 7:
25956
26253
  tx = _context20.sent;
25957
26254
  return _context20.abrupt("return", tx);
25958
26255
 
25959
- case 7:
26256
+ case 9:
25960
26257
  case "end":
25961
26258
  return _context20.stop();
25962
26259
  }