@aurigami/sdk 0.6.4 → 0.6.5

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.
@@ -2845,14 +2845,45 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
2845
2845
  while (1) {
2846
2846
  switch (_context15.prev = _context15.next) {
2847
2847
  case 0:
2848
- if (new BigNumber(amount.rawAmount()).lt(0)) {
2849
- repayAmount = INF;
2850
- } else {
2851
- repayAmount = ethers.BigNumber.from(amount.rawAmount());
2848
+ if (!new BigNumber(amount.rawAmount()).lt(0)) {
2849
+ _context15.next = 16;
2850
+ break;
2852
2851
  }
2853
2852
 
2854
2853
  if (!isSameAddress(amount.token.address, ETHAddress)) {
2855
- _context15.next = 5;
2854
+ _context15.next = 13;
2855
+ break;
2856
+ }
2857
+
2858
+ _context15.t0 = ethers.BigNumber;
2859
+ _context15.t1 = this;
2860
+ _context15.next = 6;
2861
+ return this._networkConnection.signer.getAddress();
2862
+
2863
+ case 6:
2864
+ _context15.t2 = _context15.sent;
2865
+ _context15.next = 9;
2866
+ return _context15.t1.getUserBorrowBalance.call(_context15.t1, _context15.t2);
2867
+
2868
+ case 9:
2869
+ _context15.t3 = _context15.sent.rawAmount();
2870
+ repayAmount = _context15.t0.from.call(_context15.t0, _context15.t3);
2871
+ _context15.next = 14;
2872
+ break;
2873
+
2874
+ case 13:
2875
+ repayAmount = INF;
2876
+
2877
+ case 14:
2878
+ _context15.next = 17;
2879
+ break;
2880
+
2881
+ case 16:
2882
+ repayAmount = ethers.BigNumber.from(amount.rawAmount());
2883
+
2884
+ case 17:
2885
+ if (!isSameAddress(amount.token.address, ETHAddress)) {
2886
+ _context15.next = 21;
2856
2887
  break;
2857
2888
  }
2858
2889
 
@@ -2860,10 +2891,10 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
2860
2891
  value: repayAmount
2861
2892
  }));
2862
2893
 
2863
- case 5:
2894
+ case 21:
2864
2895
  return _context15.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(repayAmount));
2865
2896
 
2866
- case 6:
2897
+ case 22:
2867
2898
  case "end":
2868
2899
  return _context15.stop();
2869
2900
  }
@@ -3016,7 +3047,7 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3016
3047
  var _getUserDetails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(userAddress) {
3017
3048
  var _this2 = this;
3018
3049
 
3019
- var marketCount, userMarketDetails, assetsIn, promises, totalBorrowLimit, pricePromises, _loop2, _iterator, _step, underlyingPrices, depositValues, _loop, i, accountLiquidity, rewardBalancesMetadata, lockedAmount, values, borrowedvaluation, bufferedBorrowLimit, minimumBorrowLimitAllowed, borrowableAmount, auToken, moneyMarket, maxWithdrawCap;
3050
+ var marketCount, userMarketDetails, assetsIn, promises, totalBorrowLimit, pricePromises, _loop2, _iterator, _step, underlyingPrices, depositValues, _loop, i, accountLiquidity, rewardBalancesMetadata, lockedAmount, values, borrowedvaluation, bufferedBorrowLimit, minimumBorrowLimitAllowed, borrowableAmount, auToken, moneyMarket, borrowLimitMargin, maxWithdrawCap;
3020
3051
 
3021
3052
  return runtime_1.wrap(function _callee2$(_context2) {
3022
3053
  while (1) {
@@ -3125,7 +3156,8 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3125
3156
  for (i = 0; i < marketCount; i++) {
3126
3157
  auToken = networkAddresses.auTokens[i];
3127
3158
  moneyMarket = new MoneyMarketRead(this._networkConnection, auToken.address, auToken.underlying);
3128
- maxWithdrawCap = totalBorrowLimit.minus(minimumBorrowLimitAllowed).div(userMarketDetails[i].collateralRatio).div(underlyingPrices[i]);
3159
+ borrowLimitMargin = totalBorrowLimit.minus(minimumBorrowLimitAllowed).gt(0) ? totalBorrowLimit.minus(minimumBorrowLimitAllowed) : new BigNumber(0);
3160
+ maxWithdrawCap = borrowLimitMargin.div(userMarketDetails[i].collateralRatio).div(underlyingPrices[i]);
3129
3161
  userMarketDetails[i].maxWithdrawableAmount = userMarketDetails[i].isCollateral && maxWithdrawCap.lt(userMarketDetails[i].depositBalance.formattedAmount()) ? new TokenAmount(moneyMarket.underlying, maxWithdrawCap.toFixed(24), false) : new TokenAmount(moneyMarket.underlying, userMarketDetails[i].depositBalance.rawAmount());
3130
3162
  }
3131
3163