Skip to content
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

Closed
wants to merge 78 commits into from
Closed

feat: implement special asset pairs #2164

wants to merge 78 commits into from

Conversation

toteki
Copy link
Member

@toteki toteki commented Jul 21, 2023

Extension of #2150 (second try, since the first got a little messy with merge commits from main)

@toteki toteki changed the base branch from main to adam/special July 21, 2023 20:28
Comment on lines +146 to +148
func (ap *AccountPosition) BorrowedValue() sdk.Dec {
return ap.borrowedValue
}
Copy link
Member Author

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)

Comment on lines 219 to 225
// 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
Copy link
Member Author

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.

Base automatically changed from adam/special to main August 1, 2023 03:41
x/leverage/types/position.go Fixed Show fixed Hide fixed
x/leverage/types/position.go Fixed Show fixed Hide fixed
toteki added a commit that referenced this pull request Aug 2, 2023
@toteki toteki marked this pull request as draft August 2, 2023 12:45
@toteki
Copy link
Member Author

toteki commented Aug 2, 2023

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.

@toteki
Copy link
Member Author

toteki commented Aug 8, 2023

Superseded by #2178

@toteki toteki closed this Aug 8, 2023
github-merge-queue bot pushed a commit that referenced this pull request Aug 11, 2023
* 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>
@toteki toteki deleted the adam/special3 branch September 5, 2023 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant