Skip to content

fix: authorize flash loan repayment (#315) and restore compilation - #362

Open
laurentketterle-hub wants to merge 1 commit into
Heliobond:mainfrom
laurentketterle-hub:fix/flash-loan-repayment-auth
Open

fix: authorize flash loan repayment (#315) and restore compilation#362
laurentketterle-hub wants to merge 1 commit into
Heliobond:mainfrom
laurentketterle-hub:fix/flash-loan-repayment-auth

Conversation

@laurentketterle-hub

Copy link
Copy Markdown

Summary

Two fixes in the investment_vault crate:

1. Flash loan repayment authorization (#315)

execute_flash_loan settled the repayment with Base::transfer(&env, &borrower, &vault, amount + fee).
Base::transfer calls borrower.require_auth(), which a contract borrower cannot satisfy once its
flash_loan_callback has 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::update primitive (the same primitive
Base::transfer/Base::burn use internally, minus require_auth). The borrower's consent is already
established by returning true from flash_loan_callback in the same transaction, and the entry point is
gated by initiator.require_auth().

2. Restore compilation (broken on main)

main currently does not compile (cargo check -p investment-vault fails). This PR restores the build:

  • Add missing closing braces to get_withdrawal_window, get_volume_fee_tier and check_deposit_lock in lib.rs.
  • Add missing closing braces to withdrawal_window_set and funding_round_ended in events.rs.
  • Add missing closing brace to test_volume_fee_tier_is_admin_only in test.rs.
  • Fix duplicate VaultError discriminants (FundingRoundActive = 42, InvestmentCapExceeded = 43; all three were 41).

Testing

cargo check -p investment-vault passes (the lib compiles). The full cargo test suite requires a fresh
stellar contract build (the wasm artifacts are gitignored and rebuilt by CI), so it could not be
exercised in the local environment.

Closes #315

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.

execute_flash_loan's repayment step cannot pass authorization on a real network (only works under mock_all_auths)

1 participant