fix: authorize flash loan repayment (#315) and restore compilation - #362
Open
laurentketterle-hub wants to merge 1 commit into
Open
fix: authorize flash loan repayment (#315) and restore compilation#362laurentketterle-hub wants to merge 1 commit into
laurentketterle-hub wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes in the
investment_vaultcrate:1. Flash loan repayment authorization (#315)
execute_flash_loansettled the repayment withBase::transfer(&env, &borrower, &vault, amount + fee).Base::transfercallsborrower.require_auth(), which a contract borrower cannot satisfy once itsflash_loan_callbackhas already returned — the authorization window is tied to the callback invocation,so the repayment only worked under
mock_all_auths()and would fail on a real network.The fix moves the shares directly with the unauthenticated
Base::updateprimitive (the same primitiveBase::transfer/Base::burnuse internally, minusrequire_auth). The borrower's consent is alreadyestablished by returning
truefromflash_loan_callbackin the same transaction, and the entry point isgated by
initiator.require_auth().2. Restore compilation (broken on
main)maincurrently does not compile (cargo check -p investment-vaultfails). This PR restores the build:get_withdrawal_window,get_volume_fee_tierandcheck_deposit_lockinlib.rs.withdrawal_window_setandfunding_round_endedinevents.rs.test_volume_fee_tier_is_admin_onlyintest.rs.VaultErrordiscriminants (FundingRoundActive = 42,InvestmentCapExceeded = 43; all three were41).Testing
cargo check -p investment-vaultpasses (the lib compiles). The fullcargo testsuite requires a freshstellar contract build(the wasm artifacts are gitignored and rebuilt by CI), so it could not beexercised in the local environment.
Closes #315