-
Notifications
You must be signed in to change notification settings - Fork 80
added PolymerCCTPFacet + deploy scripts, docs, etc. [PolymerCCTPFacet v1.0.0, ITokenMessenger v1.0.0] #1456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
0xDEnYO
wants to merge
21
commits into
main
Choose a base branch
from
polymer-cctp-facet
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
bd3632f
added PolymerCCTPFacet + deploy scripts, docs, etc.
0xDEnYO 33923d2
deployed to ARB/OPT staging
0xDEnYO 8328e43
added demoscript (not yet finalized)
0xDEnYO 4ca412a
update config
0xDEnYO bb6e94b
update deploy scripts to expect polymerFeeReceiver to be an EOA
0xDEnYO 8ad7765
remove BSC from supported destination chains
0xDEnYO 6310451
add calls to Polymer quote API to demoscript
0xDEnYO d3acf5f
rename TokenMessenger to TokenMessengerV2
0xDEnYO 14c52fe
adjust docs
0xDEnYO 2d1848e
rename TokenMessenger in test case
0xDEnYO 15b0678
Merge branch 'main' of github.com:lifinance/contracts into polymer-cc…
0xDEnYO d9a2c3b
add testnet API
0xDEnYO b6f0dce
update demoScript and create helper function to log bridgeDataStruct
0xDEnYO b1e7618
Merge branch 'main' of github.com:lifinance/contracts into polymer-cc…
0xDEnYO f371607
remove bsc from config and todo comments from facet
0xDEnYO 248dd3d
add comment in config file
0xDEnYO 4404861
remove Polymer zksync scripts (zksync not supported)
0xDEnYO 2393371
reorder modifiers and add onlyAllowSourceToken to swapAnd.. function
0xDEnYO 150ae80
removed payable and refundExcessNative modifier from startBridge.. fu…
0xDEnYO e6bd1db
removed unused error
0xDEnYO 605f7e1
removed ethers from demoscript
0xDEnYO File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| { | ||
| "Note: Networks with missing polymerFeeReceiver are not supported by Polymer yet and will be added later": {}, | ||
| "mainnet": { | ||
| "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d", | ||
| "usdc": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", | ||
| "polymerFeeReceiver": "0x64ED4dE33769349F8C4bD6e8d1866f19D29bef79" | ||
| }, | ||
| "arbitrum": { | ||
| "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d", | ||
| "usdc": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", | ||
| "polymerFeeReceiver": "0x64ED4dE33769349F8C4bD6e8d1866f19D29bef79" | ||
| }, | ||
| "avalanche": { | ||
| "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d", | ||
| "usdc": "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E", | ||
| "polymerFeeReceiver": "0x64ED4dE33769349F8C4bD6e8d1866f19D29bef79" | ||
| }, | ||
| "base": { | ||
| "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d", | ||
| "usdc": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", | ||
| "polymerFeeReceiver": "0x64ED4dE33769349F8C4bD6e8d1866f19D29bef79" | ||
| }, | ||
| "hyperevm": { | ||
| "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d", | ||
| "usdc": "0xb88339CB7199b77E23DB6E890353E22632Ba630f", | ||
| "polymerFeeReceiver": "" | ||
| }, | ||
| "ink": { | ||
| "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d", | ||
| "usdc": "0x2D270e6886d130D724215A266106e6832161EAEd", | ||
| "polymerFeeReceiver": "" | ||
| }, | ||
| "linea": { | ||
| "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d", | ||
| "usdc": "0x176211869cA2b568f2A7D4EE941E073a821EE1ff", | ||
| "polymerFeeReceiver": "" | ||
| }, | ||
| "optimism": { | ||
| "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d", | ||
| "usdc": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85", | ||
| "polymerFeeReceiver": "0x64ED4dE33769349F8C4bD6e8d1866f19D29bef79" | ||
| }, | ||
| "plume": { | ||
| "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d", | ||
| "usdc": "0x222365EF19F7947e5484218551B56bb3965Aa7aF", | ||
| "polymerFeeReceiver": "" | ||
| }, | ||
| "polygon": { | ||
| "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d", | ||
| "usdc": "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359", | ||
| "polymerFeeReceiver": "0x64ED4dE33769349F8C4bD6e8d1866f19D29bef79" | ||
| }, | ||
| "sei": { | ||
| "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d", | ||
| "usdc": "0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392", | ||
| "polymerFeeReceiver": "" | ||
| }, | ||
| "sonic": { | ||
| "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d", | ||
| "usdc": "0x29219dd400f2Bf60E5a23d13Be72B486D4038894", | ||
| "polymerFeeReceiver": "" | ||
| }, | ||
| "unichain": { | ||
| "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d", | ||
| "usdc": "0x078D782b760474a361dDA0AF3839290b0EF57AD6", | ||
| "polymerFeeReceiver": "0x64ED4dE33769349F8C4bD6e8d1866f19D29bef79" | ||
| }, | ||
| "worldchain": { | ||
| "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d", | ||
| "usdc": "0x79A02482A880bCe3F13E09da970dC34dB4cD24D1", | ||
| "polymerFeeReceiver": "" | ||
| }, | ||
| "xdc": { | ||
| "tokenMessengerV2": "0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d", | ||
| "usdc": "0xfA2958CB79b0491CC627c1557F441eF849Ca8eb1", | ||
| "polymerFeeReceiver": "" | ||
| }, | ||
| "---------- TEST NETWORKS -----------": {}, | ||
| "arbitrumSepolia": { | ||
| "tokenMessengerV2": "0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA", | ||
| "usdc": "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d", | ||
| "polymerFeeReceiver": "0x3d1ed7307Ee6dEB2e1cEA9D96C33574fA2a35Bb6" | ||
| }, | ||
| "baseSepolia": { | ||
| "tokenMessengerV2": "0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA", | ||
| "usdc": "0x036CbD53842c5426634e7929541eC2318f3dCF7e", | ||
| "polymerFeeReceiver": "0x3d1ed7307Ee6dEB2e1cEA9D96C33574fA2a35Bb6" | ||
| }, | ||
| "optimismSepolia": { | ||
| "tokenMessengerV2": "0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA", | ||
| "usdc": "0x5fd84259d66Cd46123540766Be93DFE6D43130D7", | ||
| "polymerFeeReceiver": "0x3d1ed7307Ee6dEB2e1cEA9D96C33574fA2a35Bb6" | ||
| }, | ||
| "sepolia": { | ||
| "tokenMessengerV2": "0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA", | ||
| "usdc": "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238", | ||
| "polymerFeeReceiver": "0x3d1ed7307Ee6dEB2e1cEA9D96C33574fA2a35Bb6" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| # Polymer CCTP Facet | ||
|
|
||
| Polymer CCTP Facet provides functionality for bridging USDC through Polymer's CCTP (Cross-Chain Transfer Protocol) integration. CCTP is a permissionless on-chain utility that can burn native USDC on a source chain and mint native USDC of the same amount on a destination chain. | ||
|
|
||
| ## How it works | ||
|
|
||
| The Polymer CCTP Facet works by forwarding transfers directly to Polymer's TokenMessenger contract, which is an implementation of Circle's CCTP protocol. The facet handles USDC transfers and supports both EVM and non-EVM destination chains. | ||
|
|
||
| ```mermaid | ||
| graph LR; | ||
| D{LiFiDiamond}-- DELEGATECALL -->PolymerCCTPFacet; | ||
| PolymerCCTPFacet -- CALL --> TM(TokenMessenger) | ||
| ``` | ||
|
|
||
| ## Public Methods | ||
|
|
||
| - `function startBridgeTokensViaPolymerCCTP(BridgeData memory _bridgeData, PolymerCCTPData calldata _polymerData)` | ||
| - Simply bridges USDC using Polymer CCTP | ||
| - `function swapAndStartBridgeTokensViaPolymerCCTP(BridgeData memory _bridgeData, SwapData[] calldata _swapData, PolymerCCTPData calldata _polymerData)` | ||
| - Performs swap(s) before bridging USDC using Polymer CCTP | ||
|
|
||
| ## Polymer CCTP Specific Parameters | ||
|
|
||
| The methods listed above take a variable labeled `_polymerData`. This data is specific to Polymer CCTP and is represented as the following struct type: | ||
|
|
||
| ```solidity | ||
| struct PolymerCCTPData { | ||
| // Token fee taken in USDC by the facet (optional; should be zero for slow path ) | ||
| uint256 polymerTokenFee; | ||
| // maximum fee to paid on the destination domain through the difference between burned tokens on src chain and minted token on dest chain, specified in units of burnToken | ||
| uint256 maxCCTPFee; | ||
| // Should only be nonzero if submitting to a nonEVM chain | ||
| bytes32 nonEVMReceiver; | ||
| // the minimum finality at which a burn message will be attested to, will be passed directly to tokenMessenger.depositForBurn method. | ||
| // 1000 = fast path, 2000 = standard path | ||
| uint32 minFinalityThreshold; | ||
| } | ||
| ``` | ||
|
|
||
| ## Swap Data | ||
|
|
||
| Some methods accept a `SwapData _swapData` parameter. | ||
|
|
||
| Swapping is performed by a swap specific library that expects an array of calldata to can be run on various DEXs (i.e. Uniswap) to make one or multiple swaps before performing another action. | ||
|
|
||
| The swap library can be found [here](../src/Libraries/LibSwap.sol). | ||
|
|
||
| ## LiFi Data | ||
|
|
||
| Some methods accept a `BridgeData _bridgeData` parameter. | ||
|
|
||
| This parameter is strictly for analytics purposes. It's used to emit events that we can later track and index in our subgraphs and provide data on how our contracts are being used. `BridgeData` and the events we can emit can be found [here](../src/Interfaces/ILiFi.sol). | ||
|
|
||
| ## Getting Sample Calls to interact with the Facet | ||
|
|
||
| In the following some sample calls are shown that allow you to retrieve a populated transaction that can be sent to our contract via your wallet. | ||
|
|
||
| All examples use our [/quote endpoint](https://apidocs.li.fi/reference/get_quote) to retrieve a quote which contains a `transactionRequest`. This request can directly be sent to your wallet to trigger the transaction. | ||
|
|
||
| The quote result looks like the following: | ||
|
|
||
| ```javascript | ||
| const quoteResult = { | ||
| id: '0x...', // quote id | ||
| type: 'lifi', // the type of the quote (all lifi contract calls have the type "lifi") | ||
| tool: 'polymercctp', // the bridge tool used for the transaction | ||
| action: {}, // information about what is going to happen | ||
| estimate: {}, // information about the estimated outcome of the call | ||
| includedSteps: [], // steps that are executed by the contract as part of this transaction, e.g. a swap step and a cross step | ||
| transactionRequest: { | ||
| // the transaction that can be sent using a wallet | ||
| data: '0x...', | ||
| to: '0x...', | ||
| value: '0x00', | ||
| from: '{YOUR_WALLET_ADDRESS}', | ||
| chainId: 100, | ||
| gasLimit: '0x...', | ||
| gasPrice: '0x...', | ||
| }, | ||
| } | ||
| ``` | ||
|
|
||
| A detailed explanation on how to use the /quote endpoint and how to trigger the transaction can be found [here](https://docs.li.fi/products/more-integration-options/li.fi-api/transferring-tokens-example). | ||
|
|
||
| **Hint**: Don't forget to replace `{YOUR_WALLET_ADDRESS}` with your real wallet address in the examples. | ||
|
|
||
| ### Cross Only | ||
|
|
||
| To get a transaction for a transfer from 20 USDC on Ethereum to USDC on Base you can execute the following request: | ||
|
|
||
| ```shell | ||
| curl 'https://li.quest/v1/quote?fromChain=ETH&fromAmount=20000000&fromToken=USDC&toChain=BAS&toToken=USDC&slippage=0.03&allowBridges=polymercctp&fromAddress={YOUR_WALLET_ADDRESS}' | ||
| ``` | ||
|
|
||
| ### Swap & Cross | ||
|
|
||
| To get a transaction for a transfer from 10 USDT on Ethereum to USDC on Base you can execute the following request: | ||
|
|
||
| ```shell | ||
| curl 'https://li.quest/v1/quote?fromChain=ETH&fromAmount=10000000&fromToken=USDT&toChain=BAS&toToken=USDC&slippage=0.03&allowBridges=polymercctp&fromAddress={YOUR_WALLET_ADDRESS}' | ||
| ``` | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.