@aurigami/sdk 0.4.1 → 0.4.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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.4.1",
2
+ "version": "0.4.2",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
package/src/SDK.ts CHANGED
@@ -104,7 +104,12 @@ export class SdkRead extends BlockchainEntityRead {
104
104
  promises.push(this._tokenLock.lockedAmounts(userAddress));
105
105
  var values = await Promise.all(promises);
106
106
  accountLiquidity = values[0]; rewardBalancesMetadata = values[1]; lockedAmount = values[2];
107
- const borrowedvaluation: BigNumber = totalBorrowLimit.minus(new BigNumber(accountLiquidity[1].toString()).div(decimalFactor(18)));
107
+ var borrowedvaluation: BigNumber = totalBorrowLimit.minus(new BigNumber(accountLiquidity[1].toString()).div(decimalFactor(18)));
108
+
109
+ if (borrowedvaluation.lt("0.00001")) { // Igore dust, dust could be the result of network delay causing collateral valuation calc to be different on vs off chain
110
+ borrowedvaluation = new BigNumber(0);
111
+ }
112
+
108
113
  const bufferedBorrowLimit: BigNumber = totalBorrowLimit.multipliedBy(BORROW_LIMIT_BUFFER);
109
114
  const minimumBorrowLimitAllowed = borrowedvaluation.div(BORROW_LIMIT_BUFFER);
110
115
 
package/src/dummy.ts CHANGED
@@ -39,5 +39,6 @@ export const dummyUserMarketDetails: UserMarketDetails = {
39
39
  borrowBalance: dummyZeroTokenAmount,
40
40
  isCollateral: true,
41
41
  maxWithdrawableAmount: dummyTokenAmount,
42
- collateralRatio: 0.5
42
+ collateralRatio: 0.5,
43
+ underlyingPrice: "1"
43
44
  };
@@ -106,7 +106,7 @@ export async function fetchPrice(address: Address, provider: providers.Provider)
106
106
  }
107
107
  }
108
108
  export async function fetchValuation(tokenAmount: TokenAmount, provider: providers.Provider, price?: BigNumber): Promise<BigNumber> {
109
- if (price === null) {
109
+ if (price === undefined) {
110
110
  price = await fetchPrice(tokenAmount.token.address, provider);
111
111
  }
112
112
  return new BigNumber(tokenAmount.formattedAmount()).multipliedBy(price!);