Fix getCollaterals and getCollateralValue - #30
Open
rramsden wants to merge 3 commits into
Open
Conversation
|
Kudos, SonarCloud Quality Gate passed!
|
rramsden
commented
Aug 14, 2021
|
|
||
| if (userBalance.balance === '0') { | ||
| return null; | ||
| } |
Contributor
Author
There was a problem hiding this comment.
There was a balance check here which returns null. It's a bit weird since if this condition is met you get something like the following back when this function is called:
[ null ]Better to just return an actual entry e.g.
[
{
collateral: 'terra1....',
balance: '0.000000000000000000'
},
{
collateral: 'terra1....',
balance: '0.000000000000000000'
}
]
Contributor
Author
There was a problem hiding this comment.
Just my opinion but this was added to make these functions work properly again
rramsden
commented
Aug 14, 2021
|
|
||
| if (collaterals.length === 1 && collaterals[0] === null) { | ||
| return new Dec(0).toString(); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
This can be safely removed if the null return is removed, see other comment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








Context
I noticed since bETH was introduced Borrow class
getCollateralsandgetCollateralValueno longer function.A case statement was introduced which broke functionality for
AddressFromJsonProvider. Before this method just returned the custody contract address but now it can return a null value if the switch case oncollateraldoesn't match:anchor.js/src/address-provider/from-json.ts
Lines 64 to 73 in a4b3da7
For example, when Borrow calls
queryCustodyBorrowerthe parametercustodyis passed with an instance ofMARKET_DENOMSand not with the a collateral denomination:anchor.js/src/facade/borrow/borrow.ts
Lines 126 to 130 in a4b3da7
Then
custodyis type-casted to typeCOLLATERAL_DENOMSand we just get a null value back from our switch caseanchor.js/src/queries/money-market/custody-borrower.ts
Lines 20 to 37 in a4b3da7
How to reproduce
You can see master branch no longer works running the following from node console: