-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement special asset pairs #2164
Conversation
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
func (ap *AccountPosition) BorrowedValue() sdk.Dec { | ||
return ap.borrowedValue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping all the fields on this struct private to prevent accidental misuse: this value should be immutable once the struct is initialized, so we don't expose it to be set from the keeper package (or others)
x/leverage/types/position.go
Outdated
// if no borrows remain after matching, user may have additional borrow limit available | ||
borrowLimit := ap.borrowedValue | ||
for _, c := range remainingCollateral { | ||
// the borrow limit calculation assumes no additional limitations based on borrow factor | ||
borrowLimit = borrowLimit.Add(c.Asset.Amount.Mul(c.Weight)) | ||
} | ||
return borrowLimit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the borrowed asset had a lower collateral weight than remaining collateral, the actual max borrow will be lower than is suggested here. We will have a separate helper function for MaxBorrow, or add parameters to this one to enable that calculation.
Converting back to draft - the AccountPosition struct is being moved to #2178 and will be tested extensively before I resume my work here, since I've been running into some unexpected complexity. |
Superseded by #2178 |
* isolate AccountPosition from #2164 * start test file * create wide range of position testing assets, special pairs * package change * ++ * ++ * ++fix * ++ * ++fix * ++ * ++ * ++ * ++ * ++ * ++fix * ++ * ++scenario * ++ EXAMPLES.md * fix merge * sorting of pairs breaks ties using denom (alphabetical) * maxBorrow step 1: surplus collateral * ++ * ++ * ++ * ++ * ++ * ++ * ++ * ++validate * ++ * max borrow can displace ordinary borrows * ++ * todo comments * todo comments * -- * --err * ++ * ++ * ++ * ++naive maxBorrow * ++ * ++ * ++fix * ++f * ++ * ++ * lint * ++ * ++ * ++ * ++ * ++ * ++ * ++ * ++ * ++ todo comments * ++ todo comments * sort function * ++ * misc * finish implementing MaxWithdraw * -- * apply new borrow limit to assertBorrowerHealth * switch module to new functions * move maxWithdraw and maxBorrow over * fix one price outage issue * fix another price outage issue * fix client test * ++ * ++ * ++ * ++ * ++ * ++ * ++ * finish * fix the lint and build issue * fix the tests * fix the markdown lint --------- Co-authored-by: Sai Kumar <sai@umee.cc>
Extension of #2150 (second try, since the first got a little messy with merge commits from main)