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

Composable flash loan implementation #70

Closed
wants to merge 11 commits into from

Conversation

0xkiplet
Copy link

@0xkiplet 0xkiplet commented Feb 9, 2022

A port of Hana's flash loan implementation into the Solend protocol. This is a proof of concept for adding this composable flash loan functionality.

For now only a single happy path test is written. More tests are needed.

ci/solana-version.sh Outdated Show resolved Hide resolved
};

let flash_loan_amount_decimal = Decimal::from(flash_loan_amount);
let (origination_fee, host_fee) = reserve
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to carry over the same fee options that exist for the existing flash loans, but we could change this.

@@ -40,5 +40,5 @@ crates=(

set -x
for crate in "${crates[@]}"; do
sed -i'' -e "s#\(${crate} = \"\)\(=\?\).*\(\"\)#\1\2$solana_ver\3#g" "${tomls[@]}"
sed -E -i'' -e "s#(${crate} = \")(=?).*#\1\2${solana_ver}\"#" "${tomls[@]}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this change upstream in solana-program-library and it allows this script to work on Macs.

@0xkiplet 0xkiplet force-pushed the 0xkiplet/instruction-flash-loans branch from 3177861 to b6105df Compare February 9, 2022 02:03
@0xkiplet 0xkiplet force-pushed the 0xkiplet/instruction-flash-loans branch from b6105df to 7160c00 Compare February 9, 2022 02:05
@0xkiplet 0xkiplet changed the title Instruction-based flash loan implementation Composable flash loan implementation Feb 9, 2022
@0xkiplet 0xkiplet force-pushed the 0xkiplet/instruction-flash-loans branch 2 times, most recently from af477f0 to 4e5719c Compare February 9, 2022 04:40
@0xkiplet 0xkiplet marked this pull request as ready for review February 9, 2022 04:53
@0xkiplet 0xkiplet force-pushed the 0xkiplet/instruction-flash-loans branch 2 times, most recently from 2ae3a83 to 78028d5 Compare February 10, 2022 18:09
@0xkiplet 0xkiplet force-pushed the 0xkiplet/instruction-flash-loans branch from 78028d5 to beb1e47 Compare February 10, 2022 18:10
@0xkiplet 0xkiplet force-pushed the 0xkiplet/instruction-flash-loans branch 2 times, most recently from 93f1a66 to fd289bf Compare February 11, 2022 21:03
@0xkiplet 0xkiplet force-pushed the 0xkiplet/instruction-flash-loans branch from fd289bf to a14e6b3 Compare February 12, 2022 00:01
@0xkiplet 0xkiplet force-pushed the 0xkiplet/instruction-flash-loans branch from c6a0bdf to aff68d4 Compare February 17, 2022 18:26
let token_program_id = next_account_info(account_info_iter)?;
let clock = &Clock::from_account_info(next_account_info(account_info_iter)?)?;

_refresh_reserve_interest(program_id, reserve_info, clock)?;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Modified this to always refresh the reserve

}

#[tokio::test]
async fn end_to_end_with_flash_borrow() {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this end-to-end test which verifies that the reserve has been force refreshed during flash borrow.

@0xkiplet 0xkiplet force-pushed the 0xkiplet/instruction-flash-loans branch from ceb8087 to 9d95e1a Compare February 18, 2022 01:39
@0xkiplet 0xkiplet force-pushed the 0xkiplet/instruction-flash-loans branch from 9d95e1a to 74a8d17 Compare February 18, 2022 02:05
@0xkiplet 0xkiplet force-pushed the 0xkiplet/instruction-flash-loans branch from 1bc509e to f8de57a Compare February 18, 2022 17:33
@wkshare
Copy link

wkshare commented Apr 8, 2022

@0xkiplet When deploy?

@nope-finance
Copy link
Member

@0xkiplet When deploy?

sadly not a priority at the moment ping me on discord to chat

@pindaroso
Copy link

Just checking on the progress here. Thanks!

@0xripleys 0xripleys mentioned this pull request Jul 28, 2022
@unordered-set
Copy link

Even though pull request is still open, it looks like the functionality was delivered

@nope-finance
Copy link
Member

@unordered-set true yeh will clean this up

@0xripleys 0xripleys deleted the 0xkiplet/instruction-flash-loans branch January 25, 2023 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants