- CCIP/trustless bridge contracts, GRU tokens, DEX/PMM tests, reserve vault. - Token-aggregation service routes, planner, chain config, relay env templates. - Config snapshots and multi-chain deployment markdown updates. - gitignore services/btc-intake/dist/ (tsc output); do not track dist. Run forge build && forge test before deploy (large solc graph). Made-with: Cursor
34 lines
1.1 KiB
Solidity
34 lines
1.1 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.20;
|
|
|
|
import {IERC3156FlashBorrower} from "@openzeppelin/contracts/interfaces/IERC3156FlashBorrower.sol";
|
|
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
|
|
/**
|
|
* @title MinimalERC3156FlashBorrower
|
|
* @notice Repays vault via ERC-20 transfer in `onFlashLoan`. Pre-fund this contract with at least `flashFee` of the loan token before calling `flashLoan` (vault sends `amount` only before the callback).
|
|
*/
|
|
contract MinimalERC3156FlashBorrower is IERC3156FlashBorrower {
|
|
bytes32 private constant _RETURN_VALUE = keccak256("ERC3156FlashBorrower.onFlashLoan");
|
|
|
|
address public immutable trustedLender;
|
|
|
|
error UntrustedLender();
|
|
|
|
constructor(address trustedLender_) {
|
|
trustedLender = trustedLender_;
|
|
}
|
|
|
|
function onFlashLoan(
|
|
address,
|
|
address token,
|
|
uint256 amount,
|
|
uint256 fee,
|
|
bytes calldata
|
|
) external override returns (bytes32) {
|
|
if (msg.sender != trustedLender) revert UntrustedLender();
|
|
IERC20(token).transfer(msg.sender, amount + fee);
|
|
return _RETURN_VALUE;
|
|
}
|
|
}
|