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

Draft: eMode draft impl (WIP) #26

Open
wants to merge 9 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contracts/sources/cell.move
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ module suilend::cell {
public fun get<Element>(cell: &Cell<Element>): &Element {
option::borrow(&cell.element)
}

public fun get_mut<Element>(cell: &mut Cell<Element>): &mut Element {
option::borrow_mut(&mut cell.element)
}

public fun destroy<Element>(cell: Cell<Element>): Element {
let Cell { element } = cell;
Expand Down
17 changes: 17 additions & 0 deletions contracts/sources/lending_market.move
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,23 @@ module suilend::lending_market {
reserve::update_reserve_config<P>(reserve, config);
}

// TODO:Consider taking EModeConfig as param..
public fun set_emode_for_pair<P, T>(
Copy link
Contributor

Choose a reason for hiding this comment

The 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>,
Expand Down
Loading
Loading