Skip to content

Commit 0fb6522

Browse files
committed
chore: introduce README fixes
1 parent b6beeb3 commit 0fb6522

3 files changed

Lines changed: 78 additions & 38 deletions

File tree

examples/ovault-evm/README.md

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ MNEMONIC="your twelve word mnemonic here"
8282

8383
Update `hardhat.config.ts` to include your desired networks with required `ovault` configuration. Each network needs an `ovault` config object specifying which contracts to deploy and token details.
8484

85+
> **Note**: If your asset is already an OFT, you do not need to deploy a separate mesh. The only requirement is that the asset OFT supports the hub chain you are deploying to.
86+
8587
```typescript
8688
const config: HardhatUserConfig = {
8789
networks: {
@@ -148,6 +150,10 @@ Compile your contracts:
148150
pnpm compile
149151
```
150152

153+
> **Testing Note**: If you're deploying the asset OFT from scratch for testing purposes, you'll need to mint an initial supply. Uncomment the `_mint` line in the `MyAssetOFT` constructor to provide initial liquidity. This ensures you have tokens to test deposit and cross-chain transfer functionality.
154+
>
155+
> **⚠️ Warning**: Do NOT mint share tokens directly in `MyShareOFT`. Share tokens must only be minted by the vault contract during deposits to maintain the correct share-to-asset ratio. Manually minting share tokens breaks the vault's accounting and can lead to incorrect redemption values. The mint line in `MyShareOFT` should only be uncommented for UI/integration testing, never in production.
156+
151157
## Deploy
152158

153159
### 1. Deploy Asset OFTs
@@ -353,27 +359,8 @@ export default async function () {
353359

354360
- **Hub Chain**: In this example, Base is the hub (uses `MyShareOFTAdapter`)
355361
- **Contract Types**: Only the hub chain uses `MyShareOFTAdapter`; all other chains use `MyShareOFT`
356-
- **Auto-Detection**: The `lz:ovault:send` task automatically detects the hub by finding the contract with "Adapter" in the name
357-
358-
### 3. Wire Asset OFT Network
359-
360-
Configure and wire the Asset OFT connections:
361-
362-
```bash
363-
# Wire Asset OFT network
364-
pnpm hardhat lz:oapp:wire --oapp-config layerzero.asset.config.ts
365-
```
366362

367-
### 4. Wire Share OFT Network
368-
369-
Configure and wire the Share OFT connections:
370-
371-
```bash
372-
# Wire Share OFT network
373-
pnpm hardhat lz:oapp:wire --oapp-config layerzero.share.config.ts
374-
```
375-
376-
### 5. Customizing for Your Networks
363+
### 3. Customizing for Your Networks
377364

378365
To use different chains or network configurations:
379366

@@ -393,6 +380,25 @@ To use different chains or network configurations:
393380
- Add pathway configurations between the new chain and existing chains
394381
- Deploy Asset OFTs and Share OFTs to the new chains
395382

383+
384+
### 4. Wire Asset OFT Network
385+
386+
Configure and wire the Asset OFT connections:
387+
388+
```bash
389+
# Wire Asset OFT network
390+
pnpm hardhat lz:oapp:wire --oapp-config layerzero.asset.config.ts
391+
```
392+
393+
### 5. Wire Share OFT Network
394+
395+
Configure and wire the Share OFT connections:
396+
397+
```bash
398+
# Wire Share OFT network
399+
pnpm hardhat lz:oapp:wire --oapp-config layerzero.share.config.ts
400+
```
401+
396402
## Cross-Chain Operations
397403

398404
The `lz:ovault:send` task handles four different operation types automatically based on source and destination chains. Here's how to use each:
@@ -628,19 +634,6 @@ After completing your deployment:
628634
- [ ] Set up vault access controls and admin functions
629635
- [ ] Test vault preview functions (`previewDeposit`/`previewRedeem`)
630636

631-
- [ ] **Error Recovery**
632-
633-
- [ ] Document error recovery procedures for failed operations
634-
- [ ] Set up monitoring for failed compose messages
635-
- [ ] Test refund and retry mechanisms
636-
- [ ] Configure alerts for stuck transactions
637-
638-
- [ ] **Network Configuration**
639-
- [ ] Verify all peer configurations are correct
640-
- [ ] Test message delivery on all supported routes
641-
- [ ] Confirm rate limiting settings are appropriate
642-
- [ ] Validate pathway configurations
643-
644637
## Appendix
645638

646639
### Running Tests
@@ -706,4 +699,4 @@ pnpm hardhat lz:deploy # Deploy contracts
706699

707700
---
708701

709-
**Need help?** Reach out in the [LayerZero Discord](https://discord-layerzero.netlify.app/discord) or check the [Developer Docs](https://docs.layerzero.network/).
702+
**Need help?** Reach out in the [LayerZero Discord](https://discord-layerzero.netlify.app/discord) or check the [Developer Docs](https://docs.layerzero.network/).

examples/ovault-evm/contracts/MyAssetOFT.sol

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,33 @@ pragma solidity ^0.8.20;
44
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
55
import { OFT } from "@layerzerolabs/oft-evm/contracts/OFT.sol";
66

7+
/**
8+
* @title MyAssetOFT
9+
* @notice ERC20 representation of the vault's asset token on a spoke chain for cross-chain functionality
10+
* @dev This contract represents the vault's underlying asset on spoke chains. It inherits from
11+
* LayerZero's OFT (Omnichain Fungible Token) to enable seamless cross-chain transfers of the
12+
* vault's asset tokens between the hub chain and spoke chains.
13+
*
14+
* The asset OFT acts as a bridgeable ERC20 representation of the vault's collateral asset, allowing
15+
* users to move their assets across supported chains while maintaining fungibility.
16+
*/
717
contract MyAssetOFT is OFT {
18+
/**
19+
* @notice Constructs the Asset OFT contract
20+
* @dev Initializes the OFT with LayerZero endpoint and sets up ownership
21+
* @param _name The name of the asset token
22+
* @param _symbol The symbol of the asset token
23+
* @param _lzEndpoint The address of the LayerZero endpoint on this chain
24+
* @param _delegate The address that will have owner privileges
25+
*/
826
constructor(
927
string memory _name,
1028
string memory _symbol,
1129
address _lzEndpoint,
1230
address _delegate
13-
) OFT(_name, _symbol, _lzEndpoint, _delegate) Ownable(_delegate) {}
14-
}
31+
) OFT(_name, _symbol, _lzEndpoint, _delegate) Ownable(_delegate) {
32+
// NOTE: Uncomment the line below if you need to mint initial supply
33+
// This can be useful for testing or if the asset needs initial liquidity
34+
// _mint(msg.sender, 1 ether);
35+
}
36+
}

examples/ovault-evm/contracts/MyShareOFT.sol

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,36 @@ pragma solidity ^0.8.20;
44
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
55
import { OFT } from "@layerzerolabs/oft-evm/contracts/OFT.sol";
66

7+
/**
8+
* @title MyShareOFT
9+
* @notice ERC20 representation of the vault's share token on a spoke chain for cross-chain functionality
10+
* @dev This contract represents the vault's share tokens on spoke chains. It inherits from
11+
* LayerZero's OFT (Omnichain Fungible Token) to enable seamless cross-chain transfers of
12+
* vault shares between the hub chain and spoke chains. This contract is designed to work
13+
* with ERC4626-compliant vaults, enabling standardized cross-chain vault interactions.
14+
*
15+
* Share tokens represent ownership in the vault and can be redeemed for the underlying
16+
* asset on the hub chain. The OFT mechanism ensures that shares maintain their value and can be freely
17+
* moved across supported chains while preserving the vault's accounting integrity.
18+
*/
719
contract MyShareOFT is OFT {
20+
/**
21+
* @notice Constructs the Share OFT contract
22+
* @dev Initializes the OFT with LayerZero endpoint and sets up ownership
23+
* @param _name The name of the share token
24+
* @param _symbol The symbol of the share token
25+
* @param _lzEndpoint The address of the LayerZero endpoint on this chain
26+
* @param _delegate The address that will have owner privileges
27+
*/
828
constructor(
929
string memory _name,
1030
string memory _symbol,
1131
address _lzEndpoint,
1232
address _delegate
13-
) OFT(_name, _symbol, _lzEndpoint, _delegate) Ownable(_delegate) {}
14-
}
33+
) OFT(_name, _symbol, _lzEndpoint, _delegate) Ownable(_delegate) {
34+
// WARNING: Do NOT mint share tokens directly as this breaks the vault's share-to-asset ratio
35+
// Share tokens should only be minted by the vault contract during deposits to maintain
36+
// the correct relationship between shares and underlying assets
37+
// _mint(msg.sender, 1 ether); // ONLY uncomment for testing UI/integration, never in production
38+
}
39+
}

0 commit comments

Comments
 (0)