Skip to content

Conversation

@nazreen
Copy link
Contributor

@nazreen nazreen commented Aug 26, 2025

Motivation

Read: https://docs.layerzero.network/v2/developers/solana/oft/account#conditional-msgvalue-for-ata-creation

Changes

  • no longer recommending value in enforced options when sending to Solana
  • introduce conditional setting of value based on existence of Solana recipient's Associated Token Account existence AND based on whether there's already enforcedOptions.value set

Proof of Tests

First send - https://testnet.layerzeroscan.com/tx/0x028261e4cf2de488e3f73facf35ab5bd7ad1b6718116fe23d2c7a6eb90b9032f
(has value)

Subsequent send - https://testnet.layerzeroscan.com/tx/0x5ae75e635504975b97520601374ee9b1fae915489f204cecd98b0730cb2cdbd9
(no value)


EDIT: Enhanced to support Token2022 token accounts

Token2022 Mint: https://solscan.io/account/Dn6hECYyQQmeA7ZuWVQcYFdD5gjS1FEeKhpxu7YyohnL?cluster=devnet
Created with Permanent Delegate extension.
Created OFT in MABA mode.
Example token account: 4RzxArQWnhfAmS4j6Wv5vUvaAs3VLznqRXyCFFUCiSU4
Token account size: 170 bytes

Proof of Tests

Test recipient: 8yToDJqkD31aikucY1sPvCmKFAPQt6ZVZLyyUUH6M36N

First send to test recipient: https://testnet.layerzeroscan.com/tx/0xe5ce462c7f40145ab41378f02f6fc58c4b2e781e27878da73a9f6b40f242226e
Value provided

Second send to test recipient: https://testnet.layerzeroscan.com/tx/0x50831f7116589f037a4e08a39d11343795151cdeef73fe1c6bc8fe8c3de3269b
No value provided

@nazreen nazreen marked this pull request as ready for review August 26, 2025 12:35
@nazreen nazreen requested review from DanL0, St0rmBr3w, Copilot and shankars99 and removed request for St0rmBr3w August 26, 2025 13:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces conditional value handling for Solana Associated Token Account (ATA) creation when sending OFT tokens cross-chain. Instead of always including rent value in enforced options, the system now dynamically determines the required value based on whether the recipient's ATA exists.

  • Adds utility functions to check ATA existence and compute conditional value for Solana sends
  • Updates the send logic to dynamically set msg.value only when ATA creation is needed
  • Removes static value from Solana enforced options to avoid wasteful rent payments

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
examples/oft-solana/tasks/solana/utils.ts Adds functions to check ATA existence and compute conditional rent value for token account creation
examples/oft-solana/tasks/common/sendOFT.ts Implements conditional value logic for Solana sends and prevents double value setting
examples/oft-solana/layerzero.config.ts Removes static value from enforced options and updates comments to explain conditional approach
.changeset/two-cups-prove.md Documents the change for release notes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@nazreen nazreen marked this pull request as draft August 26, 2025 13:14
@nazreen
Copy link
Contributor Author

nazreen commented Aug 26, 2025

Converted to draft. We need to coordinate with Stargate as currently OFTs on Stargate are required to have enforcedOptions.

@nazreen nazreen changed the title feat(solana examples): conditional ata value DEVREL-599 feat(solana examples): conditional ata value Aug 26, 2025
@nazreen
Copy link
Contributor Author

nazreen commented Aug 27, 2025

Note: I will be amending this PR to first check enforcedOptions before adding value

@nazreen nazreen changed the title DEVREL-599 feat(solana examples): conditional ata value DEVREL-599 feat(oft-solana): conditional ata value Aug 27, 2025
@nazreen
Copy link
Contributor Author

nazreen commented Aug 28, 2025

Changes from original implementation

  • add check for enforcedOptions
  • sendOFT.ts now no longer responsible for attaching the value, but only helping evaluate what minimum value is needed lzReceive if/when sending to Solana
  • make the sendOFT backwards compatible (also works if enfocedOptions.value is set for send to Solana)
  • removed the comment "// Setting value both in the SOLANA_ENFORCED_OPTIONS and in the conditionalValue block below will result in redundant value being sent" as now the logic ensures no redundant value is added if enforced options or extra options already include the minimum value
  • before: throw if extraOptions and conditionalValue are both defined. now: no throwing. logic will help determine whether additional value is needed after combining enforcedOptions and extraOptions (if provided).
  • conditionalValue renamed to minimumLzReceiveValue
  • getConditionalValueForSendToSolana renamed to getMinimumValueForSendToSolana

@nazreen
Copy link
Contributor Author

nazreen commented Aug 28, 2025

note: I'll amend the PR with one last change: get token account size for Token2022 dynamically. will do this tomorrow.

EDIT: this is done

@nazreen
Copy link
Contributor Author

nazreen commented Nov 11, 2025

Currently blocked. We'll only merge after Stargate drops the requirement of having enforcedOptions.value for sends to Solana

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

🚨 E2E Tests Failed

The E2E tests failed during CI. These tests validate real blockchain interactions and may fail due to:

This is non-blocking and does not prevent merging. Check the action logs above for detailed failure information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants