Skip to content

Commit

Permalink
Add "borrow" flag for the flashloan receiver method
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Abliazimov committed Sep 29, 2023
1 parent 70bd700 commit 6982595
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 70 deletions.
1 change: 1 addition & 0 deletions contracts/pool/src/methods/flash_loan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub fn flash_loan(
premium: fee
.mul_int(loan_asset.amount)
.ok_or(Error::MathOverflowError)?,
borrow: loan_asset.borrow,
});
}

Expand Down
140 changes: 70 additions & 70 deletions contracts/pool/src/tests/snapshots/budget_utilization.snap
Original file line number Diff line number Diff line change
@@ -1,180 +1,180 @@
['pool::tests::budget::account_position'] = {
"cpu_cost": 44283111,
"memory_cost": 6816095,
"cpu_cost": 44313061,
"memory_cost": 6818210,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::borrow'] = {
"cpu_cost": 64742112,
"memory_cost": 10733748,
"cpu_cost": 64771789,
"memory_cost": 10735863,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::collat_coeff'] = {
"cpu_cost": 36184723,
"memory_cost": 3876082,
"cpu_cost": 36206453,
"memory_cost": 3878197,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::configure_as_collateral'] = {
"cpu_cost": 35988361,
"memory_cost": 3867900,
"cpu_cost": 36016625,
"memory_cost": 3870015,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::debt_coeff'] = {
"cpu_cost": 35614308,
"memory_cost": 3827570,
"cpu_cost": 35640574,
"memory_cost": 3829685,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::deposit'] = {
"cpu_cost": 50709727,
"memory_cost": 6182323,
"cpu_cost": 50740091,
"memory_cost": 6184438,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::enable_borrowing_on_reserve'] = {
"cpu_cost": 35950310,
"memory_cost": 3866225,
"cpu_cost": 35985756,
"memory_cost": 3868340,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::flash_loan_fee'] = {
"cpu_cost": 35260751,
"memory_cost": 3798689,
"cpu_cost": 35290167,
"memory_cost": 3800804,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::flash_loan_with_borrow'] = {
"cpu_cost": 130792463,
"memory_cost": 24081096,
"cpu_cost": 130856778,
"memory_cost": 24087510,
"cpu_limit_exceeded": true,
"memory_limit_exceeded": false,
}
['pool::tests::budget::flash_loan_without_borrow'] = {
"cpu_cost": 80313620,
"memory_cost": 12081485,
"cpu_cost": 80424057,
"memory_cost": 12087899,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::get_reserve'] = {
"cpu_cost": 35340680,
"memory_cost": 3800435,
"cpu_cost": 35367054,
"memory_cost": 3802550,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::init_reserve'] = {
"cpu_cost": 373390,
"cpu_cost": 371590,
"memory_cost": 28587,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::ir_params'] = {
"cpu_cost": 35383875,
"memory_cost": 3811377,
"cpu_cost": 35412319,
"memory_cost": 3813492,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::liquidate_receive_stoken_when_borrower_has_one_debt'] = {
"cpu_cost": 125218368,
"memory_cost": 22572711,
"cpu_cost": 125231148,
"memory_cost": 22574826,
"cpu_limit_exceeded": true,
"memory_limit_exceeded": false,
}
['pool::tests::budget::liquidate_receive_stoken_when_borrower_has_two_debts'] = {
"cpu_cost": 98329767,
"memory_cost": 18108619,
"cpu_cost": 98365622,
"memory_cost": 18110734,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::liquidate_receive_underlying_when_borrower_has_one_debt'] = {
"cpu_cost": 84359621,
"memory_cost": 14597299,
"cpu_cost": 84369811,
"memory_cost": 14599414,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::liquidate_receive_underlying_when_borrower_has_two_debts'] = {
"cpu_cost": 77877714,
"memory_cost": 14119068,
"cpu_cost": 77882128,
"memory_cost": 14121183,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::paused'] = {
"cpu_cost": 35246679,
"memory_cost": 3798479,
"cpu_cost": 35276743,
"memory_cost": 3800594,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::price_feed'] = {
"cpu_cost": 35275824,
"memory_cost": 3799148,
"cpu_cost": 35307256,
"memory_cost": 3801263,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::repay_full'] = {
"cpu_cost": 45562298,
"memory_cost": 5841327,
"cpu_cost": 45607074,
"memory_cost": 5843442,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::repay_partial'] = {
"cpu_cost": 45600066,
"memory_cost": 5832085,
"cpu_cost": 45632766,
"memory_cost": 5834200,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::s_token_transfer'] = {
"cpu_cost": 56132172,
"memory_cost": 8926295,
"cpu_cost": 56166178,
"memory_cost": 8928410,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::set_as_collateral'] = {
"cpu_cost": 43027382,
"memory_cost": 6732903,
"cpu_cost": 43061502,
"memory_cost": 6735018,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::set_base_asset'] = {
"cpu_cost": 35704078,
"memory_cost": 3850733,
"cpu_cost": 35731190,
"memory_cost": 3852848,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::set_flash_loan_fee'] = {
"cpu_cost": 35696802,
"memory_cost": 3850327,
"cpu_cost": 35724886,
"memory_cost": 3852442,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::set_ir_params'] = {
"cpu_cost": 35741859,
"memory_cost": 3852438,
"cpu_cost": 35768755,
"memory_cost": 3854553,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::set_pause'] = {
"cpu_cost": 35687724,
"memory_cost": 3850287,
"cpu_cost": 35714548,
"memory_cost": 3852402,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::set_price_feed'] = {
"cpu_cost": 339687,
"cpu_cost": 338739,
"memory_cost": 23419,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::set_reserve_status'] = {
"cpu_cost": 35949259,
"memory_cost": 3866183,
"cpu_cost": 35976767,
"memory_cost": 3868298,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::stoken_underlying_balance'] = {
"cpu_cost": 35288033,
"memory_cost": 3801157,
"cpu_cost": 35316801,
"memory_cost": 3803272,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
Expand All @@ -185,38 +185,38 @@
"memory_limit_exceeded": false,
}
['pool::tests::budget::upgrade'] = {
"cpu_cost": 35594904,
"memory_cost": 3839157,
"cpu_cost": 35625250,
"memory_cost": 3841272,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::upgrade_debt_token'] = {
"cpu_cost": 41426230,
"memory_cost": 5437640,
"cpu_cost": 41453870,
"memory_cost": 5439755,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::upgrade_s_token'] = {
"cpu_cost": 47135672,
"memory_cost": 5862407,
"cpu_cost": 47158698,
"memory_cost": 5864522,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::user_configuration'] = {
"cpu_cost": 35002441,
"memory_cost": 3782165,
"cpu_cost": 35031551,
"memory_cost": 3784280,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::withdraw_full'] = {
"cpu_cost": 58672128,
"memory_cost": 9114962,
"cpu_cost": 58688103,
"memory_cost": 9117077,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
['pool::tests::budget::withdraw_partial'] = {
"cpu_cost": 58560853,
"memory_cost": 9105290,
"cpu_cost": 58591623,
"memory_cost": 9107405,
"cpu_limit_exceeded": false,
"memory_limit_exceeded": false,
}
1 change: 1 addition & 0 deletions interfaces/flash-loan-receiver-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub struct Asset {
pub asset: Address,
pub amount: i128,
pub premium: i128,
pub borrow: bool,
}

#[contractspecfn(name = "Spec", export = false)]
Expand Down

0 comments on commit 6982595

Please sign in to comment.