From 495c9432e4db0e446a23f93dda06b5d996773cf8 Mon Sep 17 00:00:00 2001 From: Richard Ramsden Date: Sat, 14 Aug 2021 14:13:15 +0900 Subject: [PATCH 1/3] Fix getCollaterals function --- src/facade/borrow/borrow.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/facade/borrow/borrow.ts b/src/facade/borrow/borrow.ts index f72dac7..ff12e4b 100644 --- a/src/facade/borrow/borrow.ts +++ b/src/facade/borrow/borrow.ts @@ -126,7 +126,7 @@ export class Borrow { const userBalance = await queryCustodyBorrower({ lcd: this._lcd, ...getCollateralsOption, - custody: getCollateralsOption.market, + custody: whitelist.custody_contract, })(this._addressProvider); if (userBalance.balance === '0') { From fe730f92e5fe5fe57eee9df33dcf59f7b74b42c3 Mon Sep 17 00:00:00 2001 From: Richard Ramsden Date: Sat, 14 Aug 2021 14:19:18 +0900 Subject: [PATCH 2/3] Remove nil check so we actually return a value --- src/facade/borrow/borrow.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/facade/borrow/borrow.ts b/src/facade/borrow/borrow.ts index ff12e4b..8e044be 100644 --- a/src/facade/borrow/borrow.ts +++ b/src/facade/borrow/borrow.ts @@ -88,7 +88,6 @@ export class Borrow { async getCollateralValue( getCollateralValueOption: BorrowQueriesOptions, ): Promise { - // only bLuna is supported now, and the below requests are only about bLuna const oraclePrice = await queryOraclePrices({ lcd: this._lcd, limit: 30 })( this._addressProvider, ); @@ -129,10 +128,6 @@ export class Borrow { custody: whitelist.custody_contract, })(this._addressProvider); - if (userBalance.balance === '0') { - return null; - } - return { collateral: whitelist.collateral_token, balance: new Dec(userBalance.balance).toString(), From 72151fa6799c2d7c7869b9a3cde689a367fadccb Mon Sep 17 00:00:00 2001 From: Richard Ramsden Date: Sat, 14 Aug 2021 14:22:34 +0900 Subject: [PATCH 3/3] Remove get collateral nil check --- src/facade/borrow/borrow.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/facade/borrow/borrow.ts b/src/facade/borrow/borrow.ts index 8e044be..2193d0a 100644 --- a/src/facade/borrow/borrow.ts +++ b/src/facade/borrow/borrow.ts @@ -93,10 +93,6 @@ export class Borrow { ); const collaterals = await this.getCollaterals(getCollateralValueOption); - if (collaterals.length === 1 && collaterals[0] === null) { - return new Dec(0).toString(); - } - const total = collaterals.reduce((sum, collateral) => { const collateralPrice = oraclePrice.prices.find( (p) => p.asset === collateral.collateral,