-
Notifications
You must be signed in to change notification settings - Fork 1
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
Draft: eMode draft impl (WIP) #26
Open
0xxgen1
wants to merge
9
commits into
devel
Choose a base branch
from
feat/e-mode
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0c5ac21
eMode draft impl (WIP)
0xxgen1 354f05d
eMode draft impl
0xxgen1 ef586b5
Use VecMap to store emode ltvs
0xxgen1 a5430d4
Remove emode cross-margin
0xxgen1 1aed49b
- Refactored obligation methods borrow, repay, deposit, withdraw to a…
0xxgen1 77bd53f
Reserve config tests
0xxgen1 5cd2ea0
Obligation tests
0xxgen1 9692726
- Addressed review items
0xxgen1 f30f544
Nit
0xxgen1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -379,6 +379,30 @@ module suilend::lending_market { | |
obligation::zero_out_rewards_if_looped(obligation, &mut lending_market.reserves, clock); | ||
coin::from_balance(receive_balance, ctx) | ||
} | ||
|
||
/// Set emode for obligation - T is the deposit coin type | ||
public fun set_emode<P>( | ||
lending_market: &mut LendingMarket<P>, | ||
deposit_reserve_array_index: u64, | ||
borrow_reserve_array_index: u64, | ||
obligation_owner_cap: &ObligationOwnerCap<P>, | ||
) { | ||
assert!(lending_market.version == CURRENT_VERSION, EIncorrectVersion); | ||
|
||
let obligation = object_table::borrow_mut( | ||
&mut lending_market.obligations, | ||
obligation_owner_cap.obligation_id | ||
); | ||
|
||
let deposit_reserve = vector::borrow(&lending_market.reserves, deposit_reserve_array_index); | ||
let borrow_reserve = vector::borrow(&lending_market.reserves, borrow_reserve_array_index); | ||
|
||
obligation::set_emode( | ||
obligation, | ||
deposit_reserve, | ||
borrow_reserve, | ||
); | ||
} | ||
|
||
public fun withdraw_ctokens<P, T>( | ||
lending_market: &mut LendingMarket<P>, | ||
|
@@ -819,6 +843,22 @@ module suilend::lending_market { | |
reserve::update_reserve_config<P>(reserve, config); | ||
} | ||
|
||
public fun set_emode_for_pair<P, T>( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think it makes sense to get the type argument for the pair reserve as well, just as a sanity check. |
||
_: &LendingMarketOwnerCap<P>, | ||
lending_market: &mut LendingMarket<P>, | ||
reserve_array_index: u64, | ||
pair_reserve_array_index: u64, | ||
open_ltv_pct: u8, | ||
close_ltv_pct: u8, | ||
) { | ||
assert!(lending_market.version == CURRENT_VERSION, EIncorrectVersion); | ||
|
||
let reserve = vector::borrow_mut(&mut lending_market.reserves, reserve_array_index); | ||
assert!(reserve::coin_type(reserve) == type_name::get<T>(), EWrongType); | ||
|
||
reserve::set_emode_for_pair<P>(reserve, pair_reserve_array_index, open_ltv_pct, close_ltv_pct); | ||
} | ||
|
||
public fun add_pool_reward<P, RewardType>( | ||
_: &LendingMarketOwnerCap<P>, | ||
lending_market: &mut LendingMarket<P>, | ||
|
Oops, something went wrong.
Oops, something went wrong.
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.
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.
i don't think we need to know the reserve array indicies to set emode?
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.
an obligation is a valid emode obligation if it has 1 or less deposits and 1 or less borrows
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.
When we call deposit for an emode obligation we need to be able to know what the corresponding borrow reserve is in order to get the respective emode ltv