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

flash loans #95

Merged
merged 27 commits into from
Aug 31, 2022
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1ddb124
copying kiplet's code
0xripleys Jul 22, 2022
0b9fd66
make flash loans more conservative
0xripleys Jul 22, 2022
881259a
happy case test
0xripleys Jul 25, 2022
6452238
adding more tests, fixed a bug
0xripleys Jul 26, 2022
029fdd6
moar tests
0xripleys Jul 26, 2022
7159325
clippy lints
0xripleys Jul 26, 2022
76ef3f6
fix assert
0xripleys Jul 26, 2022
ddd1662
remove clock
0xripleys Jul 26, 2022
c1be59b
remove old flash loan instruction, but keep the instruction packing code
0xripleys Jul 26, 2022
69d6be3
saner flash loan fee calculation
0xripleys Jul 26, 2022
55a156e
add flash borrow ix arg to flash repay
0xripleys Jul 27, 2022
901f969
cargo fmt
0xripleys Jul 27, 2022
baa1c1e
add cpi repay test
0xripleys Jul 27, 2022
667a225
bump compute units, no idea why github actions is failing
0xripleys Jul 27, 2022
e1cd85a
test for malicious use case
0xripleys Jul 28, 2022
9a85b30
remove unused variable
0xripleys Jul 29, 2022
f632317
fix coverage, check reserve borrow limit in flash borrow
0xripleys Aug 1, 2022
6a44638
mark reserves as stale in flash borrow and repay
0xripleys Aug 1, 2022
2b98769
revert back to old nightly version, install grcov with stable
0xripleys Aug 1, 2022
0b68bf7
fix for [repay, borrow, repay]
0xripleys Aug 2, 2022
fd385b9
refactor CPI
0xripleys Aug 9, 2022
df2be24
recheck stuff in flash repay
0xripleys Aug 9, 2022
70370a2
explicitly check for out of bounds in flash borrow loop
0xripleys Aug 9, 2022
7bfea26
0xripleys remove clock (#99)
0xripleys Aug 12, 2022
7b944e6
Merge branch 'upcoming' into 0xripleys_flash_loan
0xripleys Aug 19, 2022
67510c6
add stack height check
0xripleys Aug 19, 2022
c108e99
fmt
0xripleys Aug 19, 2022
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
Prev Previous commit
Next Next commit
recheck stuff in flash repay
  • Loading branch information
0xripleys committed Aug 9, 2022
commit df2be24e81b8237e7a822cfbca2778a6c30e5b88
14 changes: 12 additions & 2 deletions token-lending/program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2431,8 +2431,18 @@ fn _flash_repay_reserve_liquidity<'a>(

let unpacked = LendingInstruction::unpack(ixn.data.as_slice())?;
match unpacked {
// don't need to check anything here because we've checked correctness in the flash borrow
LendingInstruction::FlashBorrowReserveLiquidity { .. } => {}
LendingInstruction::FlashBorrowReserveLiquidity { liquidity_amount: borrow_liquidity_amount } => {
// re-check everything here out of paranoia
if ixn.accounts[2].pubkey != *reserve_info.key {
msg!("Invalid reserve account on flash repay");
return Err(LendingError::InvalidFlashRepay.into());
}

if liquidity_amount != borrow_liquidity_amount {
msg!("Liquidity amount for flash repay doesn't match borrow");
return Err(LendingError::InvalidFlashRepay.into());
}
}
_ => {
msg!("Flash repay: Supplied borrow instruction index is not a flash borrow");
return Err(LendingError::InvalidFlashRepay.into());
Expand Down