@aurigami/sdk 0.7.1 → 0.7.3

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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.7.1",
2
+ "version": "0.7.3",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -210,7 +210,11 @@ export class MoneyMarketReadWrite extends MoneyMarketRead {
210
210
  public async repay(amount: TokenAmount): Promise<TransactionResponse> {
211
211
  var repayAmount: BN;
212
212
  if (new BigNumber(amount.rawAmount()).lt(0)) {
213
- repayAmount = INF;
213
+ if (isSameAddress(amount.token.address, ETHAddress)) {
214
+ repayAmount = BN.from((await this.getUserBorrowBalance(await this._networkConnection.signer!.getAddress())).rawAmount());
215
+ } else {
216
+ repayAmount = INF;
217
+ }
214
218
  } else {
215
219
  repayAmount = BN.from(amount.rawAmount());
216
220
  }
package/src/SDK.ts CHANGED
@@ -128,7 +128,8 @@ export class SdkRead extends BlockchainEntityRead {
128
128
  for (var i = 0; i < marketCount; i ++) {
129
129
  const auToken = networkAddresses.auTokens[i];
130
130
  const moneyMarket: MoneyMarketRead = new MoneyMarketRead(this._networkConnection, auToken.address, auToken.underlying);
131
- const maxWithdrawCap: BigNumber = (totalBorrowLimit.minus(minimumBorrowLimitAllowed)).div(userMarketDetails[i].collateralRatio).div(underlyingPrices[i]);
131
+ const borrowLimitMargin = totalBorrowLimit.minus(minimumBorrowLimitAllowed).gt(0) ? totalBorrowLimit.minus(minimumBorrowLimitAllowed) : new BigNumber(0);
132
+ const maxWithdrawCap: BigNumber = borrowLimitMargin.div(userMarketDetails[i].collateralRatio).div(underlyingPrices[i]);
132
133
  userMarketDetails[i].maxWithdrawableAmount = userMarketDetails[i].isCollateral && maxWithdrawCap.lt(userMarketDetails[i].depositBalance.formattedAmount())
133
134
  ? new TokenAmount(
134
135
  moneyMarket.underlying,