Skip to content

Conversation

@shankars99
Copy link
Collaborator

@shankars99 shankars99 commented Oct 3, 2025

This PR introduces composers for StargateAssets:

  1. StargatePool - USDC or USDT (no new composer just tests for equivalence)
  2. StargatePoolNative - ETH

VaultComposerSync

A refactor of VaultComposerSync was made (and also required) to improve the code that would be created for these assets since they break several assumptions:

  1. OFT.token == vault.asset() breaks with PoolNative
  2. OFT.approvalRequired() returns True when approval is not required - StargatePoolNative

Updating certain functions to also being virtual and splitting _send() into _sendLocal() and _sendRemote() are non-functional changes that let us override _sendRemote() in the StargateAssetComposers.

The constructor now calls an internal function _initializeAssetToken(assetOFT,vault) and this is overridable which helps us work around (1) and (2)

VaultComposerSyncPoolNative

Stargate's nativepool asset's inner token is ETH - address(0) while the vault.asset() is WETH. This means that we need to change the functionality to wrap ETH that we receive from the NativePool when talking to the Vault. On refunds due to failed deposits (Pool gives us ETH) we want to have identical behavior against a redemption (vault gives us WETH). We override receive() to wrap ETH to WETH when the sender is the Pool. This only happens on lzReceive().

Stargate's NativePools also has approvalRequired() set to True which is incorrect.

These are addressed by overriding _initializeAssetToken() to validate the token and approve WETH.

@shankars99 shankars99 changed the title Feat/ovault stargate assets feat/ovault stargate assets Oct 3, 2025
@shankars99 shankars99 force-pushed the feat/ovault-stargate-assets branch from 9c5ec72 to f5e888a Compare October 12, 2025 19:04
@shankars99 shankars99 self-assigned this Oct 17, 2025
@shankars99 shankars99 changed the title feat/ovault stargate assets feat/native-sync-vault-composer Oct 26, 2025
@shankars99 shankars99 added ready to review in a state where CI passes and the PR is quite upto date with main and you need reviews and removed pending_audit labels Oct 30, 2025
@shankars99 shankars99 marked this pull request as ready for review October 30, 2025 16:33
Comment on lines +129 to +132
If you are staking in Stargate's native pools you will need a slightly different setup. As the asset is the native token there is not
really an OFT or an ERC20 address. So for the asset OFT and ERC20 address you need to supply the Native Pool and `0x0`(or some other 0 value hex string).
The Native Pool implements the OFT interface, and the `0x0` address will let the library know that it should handle it as a native pool. Other than that
it is the same. If you are using wETH, you can supply arguments normally. This is just for ETH or other native tokens specifically.
Copy link
Contributor

Choose a reason for hiding this comment

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

One line?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@arekLZ can you help with this?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is so it is compatible with more editors. Many don't wrap markdown and single line breaks like this will show as a single line when rendering markdown.

Example:
Screenshot 2025-11-04 at 1 29 09 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

Run prettier on this file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cc: @arekLZ

Copy link
Contributor

Choose a reason for hiding this comment

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

What styling is off?

it.skip('Redeem A->B->B', async () => {
const srcChain = chainInputs['arbitrum']!
const dstChain = chainInputs[hubChain]!
describe.skip('OFT Vaulting', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are those tests skipped? Should we be adding a comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i believe its cuz these are vape tests that actually send transactions. @arekLZ can confirm

Copy link
Contributor

Choose a reason for hiding this comment

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

These are not tests that regularly run. They are more for verification and regression and should be run manually. They actually send transactions as Shankar mentioned.

Comment on lines +272 to +277
if (hexToBigInt(tokenAddress) === 0n) {
// If sending native tokens, we need to account for slippage
const amountDst = await this.getOutputAmount(input)
const slippageAmount = (amountDst * BigInt(Number(slippage.toFixed(3)) * 1000)) / 1000n
minAmountLD = amountDst - slippageAmount
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we only account for slippage here for native tokens?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cc: @arekLZ

Copy link
Contributor

Choose a reason for hiding this comment

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

Only native tokens should have slippage. If we are sending OFTs, there should be 0 slippage.

@shankars99 shankars99 mentioned this pull request Nov 4, 2025
shankars99 and others added 3 commits November 4, 2025 13:19
Signed-off-by: shankar <[email protected]>
Co-authored-by: Tino Martínez Molina <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to review in a state where CI passes and the PR is quite upto date with main and you need reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants