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

Refactor emode #30

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 3 additions & 4 deletions contracts/Move.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# @generated by Move, please check-in and do not edit manually.

[move]
version = 0
manifest_digest = "667CAF0D3D7F67111BBA2FB5C7B9EFED4C333E603A88143E94897078FB470F12"
version = 2
manifest_digest = "79B589BBC119EA681F64EAE2725A7901477AC90DBE9DB24686754C3BDAF2B161"
deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600"

dependencies = [
{ name = "Pyth" },
{ name = "Sui" },
Expand Down Expand Up @@ -40,6 +39,6 @@ dependencies = [
]

[move.toolchain-version]
compiler-version = "1.31.1"
compiler-version = "1.34.1"
edition = "2024.beta"
flavor = "sui"
14 changes: 6 additions & 8 deletions contracts/sources/lending_market.move
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ module suilend::lending_market {

let (receive_balance, borrow_amount_with_fees) = reserve::borrow_liquidity<P, T>(reserve, amount);
let origination_fee_amount = borrow_amount_with_fees - balance::value(&receive_balance);
obligation::borrow<P>(obligation, reserve, clock, borrow_amount_with_fees);
obligation::borrow<P>(obligation, &mut lending_market.reserves, reserve_array_index, clock, borrow_amount_with_fees);

let reserve = vector::borrow_mut(&mut lending_market.reserves, reserve_array_index);

let borrow_value = reserve::market_value_upper_bound(reserve, decimal::from(borrow_amount_with_fees));
rate_limiter::process_qty(
Expand All @@ -383,9 +385,8 @@ module suilend::lending_market {
/// 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>,
clock: &Clock
) {
assert!(lending_market.version == CURRENT_VERSION, EIncorrectVersion);

Expand All @@ -394,13 +395,10 @@ module suilend::lending_market {
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,
&mut lending_market.reserves,
clock,
);
}

Expand Down
Loading
Loading