Common Patterns
The SendParam in the following pattern are based on LayerZero patterns extensions: https://docs.layerzero.network/v2/developers/evm/oft/oft-patterns-extensions
Integration Patterns
Pattern 1: Same-Chain Deposit (Hub Only)
Fastest and cheapest—no LayerZero fees.
// Direct deposit on hub chain
uint256 usdtAmount = 1000 * 1e6;
uint256 minShares = 990 * 1e18;
IERC20(usdt).approve(depositPipe, usdtAmount);
uint256 shares = IDepositPipe(depositPipe).deposit(
usdtAmount,
msg.sender,
msg.sender,
minShares
);
// Shares minted instantlyNote: The deposit function signatures are:
deposit(uint256 assets, address receiver)- ERC4626 standarddeposit(uint256 assets, address receiver, address controller)- With controllerdeposit(uint256 assets, address receiver, uint256 minShares)- With slippage protectiondeposit(uint256 assets, address receiver, address controller, uint256 minShares)- Full control
The mint function signatures are:
mint(uint256 shares, address receiver)- ERC4626 standardmint(uint256 shares, address receiver, address controller)- With controllermint(uint256 shares, address receiver, uint256 maxAssets)- With slippage protectionmint(uint256 shares, address receiver, address controller, uint256 maxAssets)- Full control
Pattern 2: Cross-Chain Deposit (Spoke → Hub)
Deposit from any spoke, receive shares on hub.
Pattern 3: Cross-Chain Deposit (Spoke → Hub → Different Spoke)
Deposit on one spoke, receive shares on another spoke.
Pattern 4: Same-Chain Instant Redemption
Fastest redemption with highest fee.
Alternative: Withdraw specific asset amount
Note:
Instant redemption (
redeem) applies a fee (instantRedeemFeeBps) which is deducted from the assets received. The fee stays with the liquidity provider.withdrawcalculates the required shares based on the net asset amount (after fees), whileredeemburns a specific number of shares.
Pattern 5: Cross-Chain Redemption (Spoke → Hub → Spoke)
Redeem shares on spoke for assets on hub or different spoke.
Pattern 6: Transfer Shares Between Spokes
Simple cross-chain share transfer (no vault operation).
Pattern 7: Direct Composer Methods (Hub Only)
For same-chain operations on the hub, you can use direct composer methods:
Pattern 8: Standard Redemption Request (Hub Only)
Standard redemption requests are fulfilled later by the protocol.
Developer Guide
1. Reading NAV and Share Prices
2. Handling Different Asset Decimals
All internal calculations use 18 decimals, but deposit assets may vary.
Example:
3. Slippage Protection Best Practices
Always use slippage protection for better UX.
4. Gas Estimation for LayerZero Operations
Always get fee quotes before cross-chain operations.
5. Error Handling
Common errors and how to handle them:
6. Monitoring Cross-Chain Transactions
Track LayerZero messages using the GUID.
Frontend Integration:
7. Important Limits and Constraints
8. Fee Information
9. Operator Pattern
The ShareManager supports an operator pattern for contract-based integrations:
10. Blacklist Handling
Users can be blacklisted, preventing deposits, redemptions, and transfers:
11. Pause Handling
All contracts support emergency pause:
12. Composer Message Structure Reference
ACTION_DEPOSIT_ASSET (1):
ACTION_REDEEM_SHARES (2):
13. Helper Functions
Last updated