Skip to content

About

Frax <> LayerZero Upgradeable OFTs

Topics

Resources

Stars

2 stars

Watchers

4 watching

Forks

Latest commit

 

History

325 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frax Finance <> LayerZero OFTs

This repository contains all of the contracts and deployment code used to manage and operate Frax Protocol's LayerZero OFT network.

Contracts & Addresses

Admin

Proxy (upgradeable) OFTs

  • Chain: Sei, X-Layer, Ink, Sonic, Arbitrum, Optimism, Polygon, BSC, Avalanche, Worldchain, Unichain, Plume, Katana, Hyperliquid, Stable
    • OFTs
      • frxUSD: 0x80Eede496655FB9047dd39d9f418d5483ED600df
      • sfrxUSD: 0x5Bff88cA1442c2496f7E475E9e7786383Bc070c0
      • frxETH: 0x43eDD7f3831b08FE70B7555ddD373C8bF65a9050
      • sfrxETH: 0x3Ec3849C33291a9eF4c5dB86De593EB4A37fDe45
      • WFRAX: 0x64445f0aecC51E94aD52d8AC56b7190e764E561a
  • Chain: Ethereum
    • OFTs
      • WFRAX: 0x04ACaF8D2865c0714F79da09645C13FD2888977f
  • Chain: Base
    • OFTs
      • frxUSD: 0xe5020A6d073a794B6E7f05678707dE47986Fb0b6
      • sfrxUSD: 0x91A3f8a8d7a881fBDfcfEcd7A2Dc92a46DCfa14e
      • frxETH: 0x7eb8d1E4E2D0C8b9bEDA7a97b305cF49F3eeE8dA
      • sfrxETH: 0x192e0C7Cc9B263D93fa6d472De47bBefe1Fb12bA
      • WFRAX: 0x0CEAC003B0d2479BebeC9f4b2EBAd0a803759bbf
  • Chain: Linea
    • OFTs:
      • frxUSD: 0xC7346783f5e645aa998B106Ef9E7f499528673D8
      • sfrxUSD: 0x592a48c0FB9c7f8BF1701cB0136b90DEa2A5B7B6
      • frxETH: 0xB1aFD04774c02AE84692619448B08BA79F19b1ff
      • sfrxETH: 0x383Eac7CcaA89684b8277cBabC25BCa8b13B7Aa2
      • WFRAX: 0x5217Ab28ECE654Aab2C68efedb6A22739df6C3D5
  • Chain: ZkSync
    • OFTs:
      • frxUSD: 0xEa77c590Bb36c43ef7139cE649cFBCFD6163170d
      • sfrxUSD: 0x9F87fbb47C33Cd0614E43500b9511018116F79eE
      • frxETH: 0xc7Ab797019156b543B7a3fBF5A99ECDab9eb4440
      • sfrxETH: 0xFD78FD3667DeF2F1097Ed221ec503AE477155394
      • WFRAX: 0xAf01aE13Fb67AD2bb2D76f29A83961069a5F245F
  • Chain: Monad
    • OFTs:
      • frxUSD: 0x58e3ee6accd124642ddb5d3f91928816be8d8ed3
      • sfrxUSD: 0x137643f7b2c189173867b3391f6629cab46f0f1a
      • frxETH: 0x288f9d76019469bfeb56bb77d86afa2bf563b75b
      • sfrxETH: 0x3b4cf37a3335f21c945a40088404c715525fcb29
      • WFRAX: 0x29acc7c504665a5ea95344796f784095f0cfcc58
  • Chain: Tempo, Somnia, Robinhood
    • OFTs:
      • frxUSD: 0x00000000D61733e7A393A10A5B48c311AbE8f1E5
      • sfrxUSD: 0x00000000fD8C4B8A413A06821456801295921a71
      • frxETH: 0x000000008c3930dCA540bB9B3A5D0ee78FcA9A4c
      • sfrxETH: 0x00000000883279097A49dB1f2af954EAd0C77E3c
      • WFRAX: 0x00000000E9CE0f293D1Ce552768b187eBA8a56D4
      • (tempo specific)
        • FrxUSDPolicyAdminTempo : 0x766c2BD9C6dDc5BeE9ACd7D4C8ADD5b969952969
        • PolicyID : 5
        • frxUSD TIP20 : 0x20C0000000000000000000003554d28269E0f3c2

Contract design

Overall, there are three types of LayerZero contracts that provide liquidity for users upon bridging:

  1. OFT
  • Operates as an ERC20
  • When tokens are sent to the chain, the OFT is minted
  • When tokens are sent from the chain, the OFT is burned
  1. Adapter (aka lockbox)
  • Holds a running balance of a Frax-protocol token
  • When tokens are sent to the chain, the Adapter sends the Frax token from its' balance to the recipient
  • When tokens are sent from the chain, the sender sends the Frax token to the Adapter
  1. Mintable Adapter (aka mint/burn lockbox)
  • Holds no balance of Frax-protocol token
  • When tokens are sent to the chain, the Mintable Adapter mints the Frax token to the recipient
  • When tokens are sent from the chain, the Mintable Adapter burns the Frax token

With the exception of Ethereum, Fraxtal and Tempo (frxUSD TIP20), Frax tokens are represented as an OFT. For Ethereum and Fraxtal, Frax tokens are utilized in the following:

frxUSD

  • Fraxtal (Mintable Adapter): 0x96A394058E2b84A89bac9667B19661Ed003cF5D4
  • Ethereum (Mintable Adapter): 0x566a6442A5A6e9895B9dCA97cC7879D632c6e4B0
  • Tempo (Mintable Adapter): 0x00000000D61733e7A393A10A5B48c311AbE8f1E5

sfrxUSD

  • Fraxtal (Mintable Adapter): 0x88Aa7854D3b2dAA5e37E7Ce73A1F39669623a361
  • Ethereum (Mintable Adapter): 0x7311CEA93ccf5f4F7b789eE31eBA5D9B9290E126

frxETH

  • Fraxtal (Adapter): 0x9aBFE1F8a999B0011ecD6116649AEe8D575F5604
  • Ethereum (Adapter): 0x1c1649A38f4A3c5A0c4a24070f688C525AB7D6E6

sfrxETH

  • Fraxtal (Adapter): 0x999dfAbe3b1cc2EF66eB032Eea42FeA329bBa168
  • Ethereum (Adapter): 0xbBc424e58ED38dd911309611ae2d7A23014Bd960

WFRAX

  • Fraxtal (Adapter): 0xd86fBBd0c8715d2C1f40e451e5C3514e65E7576A
  • Ethereum (OFT): 0x04ACaF8D2865c0714F79da09645C13FD2888977f

Tempo gas payment and fee refunds

Tempo runs LayerZero's EndpointV2Alt, which charges its messaging fee in an ERC-20 — LZEndpointDollar ("LZD") — rather than in chain-native value. LZD is a wrapper over a basket of whitelisted USD TIP-20s (currently pathUSD, USDC.e, USDT0).

On a send, the Tempo OFT and the frxUSD TIP-20 adapter:

  1. resolve the caller's gas token from TIP_FEE_MANAGER.userTokens(msg.sender), defaulting to pathUSD (or take the feeToken named to sendWithFeeCap, see below);
  2. if LZD whitelists that token, pull exactly fee.nativeFee of it; otherwise swap for the cheapest whitelisted token on the StablecoinDEX, applying a 50 bps allowance (feeSwapSlippageBps) because the DEX quote and its settlement round differently across order boundaries — anything the swap does not consume is returned to the caller in the same TIP-20;
  3. wrap exactly fee.nativeFee into LZD, minted directly to the endpoint.

Capping the TIP-20 debit. IOFT.send carries no ceiling on the TIP-20 pulled for the fee: only the caller's allowance bounds it, and a DEX-routed fee can move between quote and inclusion. sendWithFeeCap(sendParam, fee, refundAddress, feeToken, maxFeeTokenAmount) is the same send with the fee token named explicitly (independent of the FeeManager binding) and the debit capped: it reverts FeeAboveCap, keeping nothing, if the fee in feeToken — quoteUserTokenFee(feeToken, fee.nativeFee), headroom included — exceeds the cap. Approve exactly that figure and pass it as the cap; the unspent headroom is refunded in the same call. It takes no value.

Overpaid fees are refunded in LZD, not in the TIP-20 the caller paid with. The endpoint prices the send when the transaction lands and compares it against its whole LZD balance; any surplus goes to _refundAddress as LZD. The contracts never wrap more than fee.nativeFee, so a surplus only arises when the caller's declared fee exceeds the endpoint's price at execution.

  • Recovering a refund: call unwrap(whitelistedToken, to, amount) on LZD. Note that if the fee was paid through a swap, the unwrap returns the whitelisted intermediate token, not the token originally paid. LZD is backed as a basket and not per token, so pick a token LZD holds enough of.
  • Quote as late as possible. The fee is denominated in USD but prices destination gas, so it moves with the destination's gas price and native-token price. The same frxUSD Tempo→Fraxtal send has quoted anywhere from 0.29 to 1.59 LZD within a few thousand blocks. Pass the freshest quote; padding guarantees LZD change, and under-quoting reverts the send.
  • Contract refund addresses must be able to move LZD — an ERC-20 transfer, or a direct unwrap. RemoteHopV201Tempo passes address(this), but it quotes in the same transaction as the send, so its surplus is always zero; it also inherits recoverERC20 as a backstop.

Converting the refund back to the caller's token inside the OFT is deliberately not done: it would run after the message is already committed, and both steps it needs are externally constrained — the unwrap depends on LZD's finite per-token reserves, and a reverse swap re-introduces the same quote-versus-settlement divergence on a dust-sized amount.

Legacy lockboxes

Prior to Upgradeable lockboxes, Frax operated immutable lockboxes on Ethereum. Liquidity can be unlocked via the Stargate UI:

  • LFRAX: 0x909DBdE1eBE906Af95660033e478D59EFe831fED
  • sFRAX: 0xe4796cCB6bB5DE2290C417Ac337F2b66CA2E770E
  • frxETH : 0xF010a7c8877043681D59AD125EbF575633505942
  • sfrxETH: 0x1f55a02A049033E3419a8E2975cF3F572F4e6E9A
  • FRAX: 0x23432452B720C80553458496D4D9d7C5003280d0
  • FPI: 0x6Eca253b102D41B6B69AC815B9CC6bD47eF1979d

Solana

  • Admin: Chain-respective msig
  • OFT program (all tokens): E1ht9dUh1ZkgWWRRPCuN3kExEoF2FXiyADXeN3XyMHaQ
  • The bytes32 values below are the OFT store PDAs — the LayerZero OApp each EVM adapter holds in peers(30168) — not the SPL mints. Full account sets are in deployments/solana-mainnet/*OFT.json.
  • frxUSD
    • SPL Token: GzX1ireZDU865FiMaKrdVB1H6AE8LAqWYCg6chrMrfBw
    • OFT store: 7LS6y37WXXCyBHkBU6zVpiqaqbkXLr4P85ZhQi3eonSp
      • As bytes32 (EVM peer): 0x5e208a73d5bb1c78e9dbf53badd7299afd6bee9acacdcd4fd668833e53c538ad
  • sfrxUSD
    • SPL Token: DUvWQMyASSkLNJFwsMDA4kwxEvmfaqpPGrvUVKtitX45
    • OFT store: A28EK6j1euK4e6taP1KLFpGEoR1mDpXR4vtfiyCE1Nxv
      • As bytes32 (EVM peer): 0x8602f005ca65b6da46a3c6ce66ecd1d15be911ca650d5f418d369df184b584cf
  • frxETH
    • SPL Token: 5sDrwVNiHMM2jC78hRBH1CtysDQYiNKihubgW2zNu8tf
    • OFT store: 4pyqBQFhzsuL7ED76x3AyzT4bCVpMpQWXhS1LqEsfQtz
      • As bytes32 (EVM peer): 0x38dd9e11bbf63835dc61d3cbf259f4221f5987ac92982c96609b99634662dfb3
  • sfrxETH
    • SPL Token: 58zpC9acE6F4FBtd88L64NoWHJcmzLsQSy5bjz35Ydgv
    • OFT store: DsJYjDF5yVSopMC15q9W42v833MhWGhCxcU2J39oS3wN
      • As bytes32 (EVM peer): 0xbf2f1fc27286a43f25b05bd843a74a5478c4246343fa90c1fcb641a1caf46c61
  • WFRAX
    • SPL Token: zZbQjiRg8uSxZaPu996XuviuZeSY6nsaMuutKZQBJga
    • OFT store: 5vqBiG7nxNnoCst8mEVVS6ax7C1ypEEenPfcZ4kLgj9B
      • As bytes32 (EVM peer): 0x4939035f8dd13d15a9386e28b6705519aa6f488791323466a3c0116a201e51aa

Address lookup tables

A Fraxtal-hop send from Solana (lz:oft:send:fraxtalhopv2: HopMessage compose + lzCompose native drop) references 51 accounts and only fits Solana's 1232-byte packet with two lookup tables:

  • LayerZero's: AokBxha6VMLLgf97B5VYHEtqztamWmYERBmmFvjuTzJB (endpoint, ULN, executor, LayerZero Labs DVN)
  • Frax's: AxK5myLkGReGSzEywXUM7hnbQ4n1ccnbR7VL7MqPBxFy, authority 53dNdHXc7uruWqELhWtpx4f4UvpPk5SaT1upQNoKdi7y (the fraxOFTWallet). It was created with frxUSD's accounts only; pnpm exec hardhat lz:oft:solana:extend-hop-lookup-table --eid 30168 computes what every token's hop send still needs (dry run) and --execute appends it with SOLANA_PRIVATE_KEY, after which each token's hop send is ~780 bytes. Tables only grow: re-run after adding a token or changing the DVN set.

Testnet

Frax operates a lightweight LZ stack on testnets, replicating the dual-lockbox approach. Below are the following addresses:

Ethereum Sepolia

Fraxtal Testnet

Arbitrum Sepolia

Legacy (non-upgradeable) OFTs

  • Chain: Ethereum, Base
  • Chain to convert from native token into OFT: Ethereum
  • Admin: Chain-respective msig
  • OFTs
    • LFRAX: 0x909DBdE1eBE906Af95660033e478D59EFe831fED
    • sFRAX: 0xe4796cCB6bB5DE2290C417Ac337F2b66CA2E770E
    • frxETH : 0xF010a7c8877043681D59AD125EbF575633505942
    • sfrxETH: 0x1f55a02A049033E3419a8E2975cF3F572F4e6E9A
    • FRAX: 0x23432452B720C80553458496D4D9d7C5003280d0
    • FPI: 0x6Eca253b102D41B6B69AC815B9CC6bD47eF1979d

New Chain Deployment

  • Ensure PK_OFT_DEPLOYER and PK_CONFIG_DEPLOYER are the private keys for 0x9C9dD956b413cdBD81690c9394a6B4D22afe6745 and 0x0990be6dB8c785FBbF9deD8bAEc612A10CaE814b, respectively.
  • Modify .env RPC_URL to the new chain RPC
  • Add an item to scripts/L0Config.json:Proxy with the new chain details (incorrect data will cause the script to fail).
  • source .env && forge script scripts/DeployFraxOFTProtocol.s.sol --rpc-url $RPC_URL
  • Verify files created within scripts/txs/{SOURCE_CHAIN_ID}-{DESTINATION_CHAIN_ID}.json are correct peers, config
  • source .env && forge script scripts/DeployFraxOFTProtocol.s.sol --rpc-url $RPC_URL --broadcast
  • Verify each contract on the deployed chain (do not need to verify ImplementationMock)
    • v1.2.0 implementations link external libraries: forge verify-contract <implementation> <path>:<Contract> --chain <chainid> --libraries <path>:<Library>:<address> …, one --libraries per entry in the broadcast file's libraries list (see scripts/ops/V120/destinations/README.md)
  • Submit each newly crafted json to the respective DESTINATION_CHAIN_ID msig.

About

Frax <> LayerZero Upgradeable OFTs

Topics

Resources

Stars

2 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages