src/Escrow.sol implements a small, trusted escrow used to swap Flying Tulip (FT) tokens for an ERC20 denomination token.
- Owner (Flying Tulip) funds the escrow with FT tokens.
- Recipient transfers the denomination token into the escrow.
- Once the escrow has received at least
amountDenomdenomination tokens (tracked even if the owner has already withdrawn them), the recipient can withdraw FT.
This design assumes a trusted flow: there is no price enforcement, timeouts, or partial-fill logic.
- FT token address is fixed (same on every network):
Escrow.FT()is hard-coded to0x5DD1A7A369e8273371d2DBf9d83356057088082c. - The escrow does not have deposit functions; funding is done via standard ERC20
transferto the escrow address. - Transfers use OpenZeppelin
SafeERC20to safely handle non-standard ERC20 return values. withdrawnAmountDenomtracks denomination tokens already withdrawn by the owner so the recipient can still withdraw FT after payment is received.
withdraw(address token, uint256 amount)(owner only): withdraw any token except the denomination token.withdrawDenom(uint256 amount)(owner only): withdraw denomination tokens and incrementwithdrawnAmountDenom.withdrawFT(uint256 amount)(recipient only): withdraw FT oncedenomination.balanceOf(escrow) + withdrawnAmountDenom >= amountDenom.
git submodule update --init --recursiveforge buildforge test -vvvforge coverageNote: src/Escrow.sol is excluded from forge fmt to preserve the audited source exactly.
Deployment uses script/DeployEscrow.s.sol:DeployEscrowScript.
Environment variables read by the script:
PRIVATE_KEY(deployer key)ESCROW_OWNERESCROW_RECIPIENTESCROW_DENOMINATIONESCROW_AMOUNT_DENOM
Example:
export PRIVATE_KEY=...
export ESCROW_OWNER=0x...
export ESCROW_RECIPIENT=0x...
export ESCROW_DENOMINATION=0x...
export ESCROW_AMOUNT_DENOM=100000000000000000000
forge script script/DeployEscrow.s.sol:DeployEscrowScript \
--rpc-url $RPC_URL \
--broadcast