Skip to content

[flashloan] build_flashloan_calldata encodes empty params — executeOperation will always revert on decoding #138

@obchain

Description

@obchain

Refs #39

File: crates/charon-flashloan/src/aave.rs — build_flashloan_calldata()

Problem

The adapter encodes flashLoanSimple(receiver, asset, amount, params=0x, referralCode=0). Aave V3 passes the params bytes verbatim into executeOperation(asset, amount, premium, initiator, params) on the receiver.

CharonLiquidator.sol (landed in PR #37) ABI-decodes params inside executeOperation to extract the borrower address, collateral vtoken, debt vtoken, repay amount, and swap-route data. With params = 0x (empty), abi.decode reverts on every call. This means every call produced by build_flashloan_calldata will revert at the contract, making the entire flash-loan liquidation path non-functional.

Impact: Complete functional failure of the liquidation execution path. Every on-chain liquidation attempt will revert.

Fix

Update the FlashLoanProvider trait signature to accept the encoded liquidation params:

fn build_flashloan_calldata(
    &self,
    asset: Address,
    amount: U256,
    liquidation_params: &[u8],
) -> Result<Bytes>;

The caller passes in the output of LendingProtocol::build_liquidation_calldata (already ABI-encoded). The adapter forwards this slice into the params slot of flashLoanSimple.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglayer:rustRust crates (core / scanner / protocols / executor / cli)priority:p1-coreCore MVP scope

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions