-
Notifications
You must be signed in to change notification settings - Fork 44
docs(fassets): add auto-redemption documentation and examples #1043
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
Conversation
|
@AmadiaFlare please make a new section Layer Zero or Cross Chain in |
fassko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added bunch of comments, let's dicuss.
| - Bridge FXRP tokens from Coston2 to Hyperliquid EVM to prepare for auto-redemption | ||
| - Send FXRP from Hyperliquid back to Coston2 and auto-redeem to native XRP | ||
| - Execute the entire bridge-and-redeem flow with just one transaction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - Bridge FXRP tokens from Coston2 to Hyperliquid EVM to prepare for auto-redemption | |
| - Send FXRP from Hyperliquid back to Coston2 and auto-redeem to native XRP | |
| - Execute the entire bridge-and-redeem flow with just one transaction | |
| - Bridge FXRP tokens from Flare Testnet Coston2 to Hyperliquid EVM to prepare for auto-redemption. | |
| - Send FXRP from Hyperliquid back to Flare Testnet Coston2 and auto-redeem to native XRP. | |
| - Execute the entire bridge-and-redeem flow with just one transaction. |
|
|
||
| ## Introduction | ||
|
|
||
| This documentation covers a cross-chain bridge system that allows you to move FAssets (tokenized versions of non-smart contract tokens like XRP) between Flare Network's Coston2 testnet and Hyperliquid EVM Testnet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| This documentation covers a cross-chain bridge system that allows you to move FAssets (tokenized versions of non-smart contract tokens like XRP) between Flare Network's Coston2 testnet and Hyperliquid EVM Testnet. | |
| This documentation covers a cross-chain bridge system that allows you to move FAssets (tokenized versions of non-smart contract tokens like XRP) between Flare Testnet Coston2 and Hyperliquid EVM Testnet. |
| - LayerZero OFT (Omnichain Fungible Token) for cross-chain messaging | ||
| - Flare's FAsset system for tokenizing non-smart contract assets | ||
| - Composer pattern for automatic execution on the destination chain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - LayerZero OFT (Omnichain Fungible Token) for cross-chain messaging | |
| - Flare's FAsset system for tokenizing non-smart contract assets | |
| - Composer pattern for automatic execution on the destination chain | |
| - LayerZero OFT (Omnichain Fungible Token) for cross-chain messaging. | |
| - Flare's [FAsset](/fassets/overview) system for tokenizing non-smart contract assets. | |
| - Composer pattern for automatic execution on the destination chain. |
- Add link to LayerZero OFT to LayerZero docs.
- Is it LayerZero composer, needs a bit more explanation what is it.
| **IMPORTANT:** To successfully test the auto-redemption feature, you must run the scripts in the correct order: | ||
|
|
||
| ### Step 1: Bridge FXRP to Hyperliquid EVM (Required First) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to explain briefly what is OFT how it moves tokens.
| Run `bridgeToHyperEVM.ts` on **Coston2** network to transfer your FXRP tokens from Coston2 to Hyperliquid EVM Testnet. | ||
| This script does NOT involve auto-redemption - it simply moves your tokens to Hyperliquid where you can use them to prepare for the auto-redemption process. | ||
|
|
||
| **Why this is required:** You need FXRP tokens on Hyperliquid EVM before you can test the auto-redeem functionality. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this in info block
:::info
:::
| composeMsg: "0x", | ||
| oftCmd: "0x", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why these are 0x values? Add a comment
| function getAllV2TestnetEndpoints(): { name: string; eid: number }[] { | ||
| const endpoints: { name: string; eid: number }[] = []; | ||
|
|
||
| for (const [key, value] of Object.entries(EndpointId)) { | ||
| // Only include V2 testnet endpoints (they end with _V2_TESTNET and have numeric values) | ||
| if (key.endsWith("_V2_TESTNET") && typeof value === "number") { | ||
| // Convert key like "SEPOLIA_V2_TESTNET" to "Sepolia" | ||
| const name = key | ||
| .replace("_V2_TESTNET", "") | ||
| .split("_") | ||
| .map((word) => word.charAt(0) + word.slice(1).toLowerCase()) | ||
| .join(" "); | ||
| endpoints.push({ name, eid: value }); | ||
| } | ||
| } | ||
|
|
||
| // Sort by EID for consistent output | ||
| return endpoints.sort((a, b) => a.eid - b.eid); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use higher order function then there is no need to define empty array.
| function getAllV2TestnetEndpoints(): { name: string; eid: number }[] { | |
| const endpoints: { name: string; eid: number }[] = []; | |
| for (const [key, value] of Object.entries(EndpointId)) { | |
| // Only include V2 testnet endpoints (they end with _V2_TESTNET and have numeric values) | |
| if (key.endsWith("_V2_TESTNET") && typeof value === "number") { | |
| // Convert key like "SEPOLIA_V2_TESTNET" to "Sepolia" | |
| const name = key | |
| .replace("_V2_TESTNET", "") | |
| .split("_") | |
| .map((word) => word.charAt(0) + word.slice(1).toLowerCase()) | |
| .join(" "); | |
| endpoints.push({ name, eid: value }); | |
| } | |
| } | |
| // Sort by EID for consistent output | |
| return endpoints.sort((a, b) => a.eid - b.eid); | |
| } | |
| function getAllV2TestnetEndpoints(): { name: string; eid: number }[] { | |
| return Object.entries(EndpointId) | |
| .filter(([key, value]) => key.endsWith("_V2_TESTNET") && typeof value === "number") | |
| .map(([key, eid]) => ({ | |
| name: key | |
| .replace("_V2_TESTNET", "") | |
| .split("_") | |
| .map(w => w.charAt(0) + w.slice(1).toLowerCase()) | |
| .join(" "), | |
| eid, | |
| })) | |
| .sort((a, b) => a.eid - b.eid); | |
| } |
|
|
||
| for (const endpoint of V2_TESTNET_ENDPOINTS) { | ||
| try { | ||
| const peer = await oftAdapter.methods.peers(endpoint.eid).call(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar here , can convert to higher order function.
fassko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added bunch of comments, let's dicuss.
fassko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style improvements and lot calculation
|
|
||
| Once you have FXRP tokens on Hyperliquid (from Step 1), run `autoRedeemHyperEVM.ts` on **Hyperliquid Testnet** network to send them back to Coston2 with automatic redemption to native XRP. | ||
| This is the auto-redemption feature that converts FXRP back to native XRP in a single transaction. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK if the same private key works, then it is all good.
fassko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style improvements
Adds docs and examples for FAsset auto-redemption.