Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions examples/ovault-evm/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-'
#
# Example environment configuration
#
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-'

# By default, the examples support both mnemonic-based and private key-based authentication
#
# You don't need to set both of these values, just pick the one that you prefer and set that one
MNEMONIC=
PRIVATE_KEY=
PRIVATE_KEY_HYPERLIQUID=

RPC_HYPEREVM_MAINNET=https://rpc.hyperliquid.xyz/evm
RPC_HYPEREVM_TESTNET=https://rpc.hyperliquid-testnet.xyz/evm

HYPEREVM_COMPOSER=
HYPEREVM_OFT=
SRC_OFT=
SRC_EID=
DST_EID=
10 changes: 10 additions & 0 deletions examples/ovault-evm/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
artifacts
cache
dist
node_modules
out
*.log
*.sol
*.yaml
*.lock
package-lock.json
12 changes: 12 additions & 0 deletions examples/ovault-evm/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require('@rushstack/eslint-patch/modern-module-resolution');

module.exports = {
root: true,
extends: ['@layerzerolabs/eslint-config-next/recommended'],
rules: {
// @layerzerolabs/eslint-config-next defines rules for turborepo-based projects
// that are not relevant for this particular project
'turbo/no-undeclared-env-vars': 'off',
'import/no-unresolved': 'warn', // Updated to warn to avoid erratic popping up of this particular error for '@layerzerolabs/metadata-tools' even when the package has been installed correctly
},
};
27 changes: 27 additions & 0 deletions examples/ovault-evm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts


# LayerZero specific files
.layerzero

# foundry test compilation files
out

# pnpm
pnpm-error.log

# Editor and OS files
.DS_Store
.idea

broadcast
deployments
1 change: 1 addition & 0 deletions examples/ovault-evm/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.18.0
11 changes: 11 additions & 0 deletions examples/ovault-evm/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
artifacts/
cache/
dist/
node_modules/
out/
*.log
*ignore
*.yaml
*.lock
package-lock.json
package.json
3 changes: 3 additions & 0 deletions examples/ovault-evm/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
...require('@layerzerolabs/prettier-config-next'),
};
621 changes: 621 additions & 0 deletions examples/ovault-evm/README.md

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions examples/ovault-evm/contracts/MyAssetOFT.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;

import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { OFT } from "@layerzerolabs/oft-evm/contracts/OFT.sol";

contract MyAssetOFT is OFT {
constructor(
string memory _name,
string memory _symbol,
address _lzEndpoint,
address _delegate
) OFT(_name, _symbol, _lzEndpoint, _delegate) Ownable(_delegate) {}

function mint(address to, uint256 amount) external {
_mint(to, amount);
}

function burn(address from, uint256 amount) external {
_burn(from, amount);
}
}
19 changes: 19 additions & 0 deletions examples/ovault-evm/contracts/MyOVault.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;

import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

import { OVault } from "@layerzerolabs/ovault-evm/contracts/OVault.sol";
import { OFTAdapter } from "@layerzerolabs/oft-evm/contracts/OFTAdapter.sol";

contract MyOVault is OVault {
constructor(string memory name, string memory symbol, address asset) OVault(name, symbol, asset) {}
}

contract MyShareOFTAdapter is OFTAdapter {
constructor(
address _token,
address _lzEndpoint,
address _delegate
) OFTAdapter(_token, _lzEndpoint, _delegate) Ownable(_delegate) {}
}
8 changes: 8 additions & 0 deletions examples/ovault-evm/contracts/MyOVaultComposer.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;

import { OVaultComposer } from "@layerzerolabs/ovault-evm/contracts/OVaultComposer.sol";

contract MyOVaultComposer is OVaultComposer {
constructor(address _ovault, address _assetOFT, address _shareOFT) OVaultComposer(_ovault, _assetOFT, _shareOFT) {}
}
14 changes: 14 additions & 0 deletions examples/ovault-evm/contracts/MyShareOFT.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;

import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { OFT } from "@layerzerolabs/oft-evm/contracts/OFT.sol";

contract MyShareOFT is OFT {
constructor(
string memory _name,
string memory _symbol,
address _lzEndpoint,
address _delegate
) OFT(_name, _symbol, _lzEndpoint, _delegate) Ownable(_delegate) {}
}
39 changes: 39 additions & 0 deletions examples/ovault-evm/deploy/MyAssetOFT.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import assert from 'assert'

import { type DeployFunction } from 'hardhat-deploy/types'

export const assetOFTContractName = 'MyAssetOFT'
const tokenName = 'MyMockAssetOFT'
const tokenSymbol = 'MockAsset'

const deploy: DeployFunction = async (hre) => {
const { getNamedAccounts, deployments } = hre

const { deploy } = deployments
const { deployer } = await getNamedAccounts()

assert(deployer, 'Missing named deployer account')

console.log(`Network: ${hre.network.name}`)
console.log(`Deployer: ${deployer}`)

const endpointV2Deployment = await hre.deployments.get('EndpointV2')

const { address } = await deploy(assetOFTContractName, {
from: deployer,
args: [
tokenName, // name
tokenSymbol, // symbol
endpointV2Deployment.address, // LayerZero's EndpointV2 address
deployer, // owner
],
log: true,
skipIfAlreadyDeployed: true,
})

console.log(`Deployed contract: ${assetOFTContractName}, network: ${hre.network.name}, address: ${address}`)
}

deploy.tags = ['asset']

export default deploy
61 changes: 61 additions & 0 deletions examples/ovault-evm/deploy/MyOVault.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import assert from 'assert'

import { type DeployFunction } from 'hardhat-deploy/types'

import { assetOFTContractName } from './MyAssetOFT'

export const ovaultContractName = 'MyOVault'
const tokenName = 'MyMockShareOFT'
const tokenSymbol = 'MockShare'

const shareOFTAdapterContractName = 'MyShareOFTAdapter'
const composerContractName = 'MyOVaultComposer'

const deploy: DeployFunction = async (hre) => {
const { getNamedAccounts, deployments } = hre

const { deploy } = deployments
const { deployer } = await getNamedAccounts()

assert(deployer, 'Missing named deployer account')

console.log(`Network: ${hre.network.name}`)
console.log(`Deployer: ${deployer}`)

const assetOFTDeployment = await hre.deployments.get(assetOFTContractName)

const { address: ovaultAddress } = await deploy(ovaultContractName, {
from: deployer,
args: [tokenName, tokenSymbol, assetOFTDeployment.address],
log: true,
skipIfAlreadyDeployed: true,
})

console.log(`Deployed contract: ${ovaultContractName}, network: ${hre.network.name}, address: ${ovaultAddress}`)

const endpointV2Deployment = await hre.deployments.get('EndpointV2')

const { address: shareOFTAdapterAddress } = await deploy(shareOFTAdapterContractName, {
from: deployer,
args: [ovaultAddress, endpointV2Deployment.address, deployer],
log: true,
skipIfAlreadyDeployed: true,
})

console.log(
`Deployed contract: ${shareOFTAdapterContractName}, network: ${hre.network.name}, address: ${shareOFTAdapterAddress}`
)

const { address: composerAddress } = await deploy(composerContractName, {
from: deployer,
args: [ovaultAddress, assetOFTDeployment.address, shareOFTAdapterAddress],
log: true,
skipIfAlreadyDeployed: true,
})

console.log(`Deployed contract: ${composerContractName}, network: ${hre.network.name}, address: ${composerAddress}`)
}

deploy.tags = ['ovault']

export default deploy
48 changes: 48 additions & 0 deletions examples/ovault-evm/deploy/MyShareOFT.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import assert from 'assert'

import { type DeployFunction } from 'hardhat-deploy/types'

import { ovaultContractName } from './MyOVault'

const shareOFTContractName = 'MyShareOFT'
const tokenName = 'MyMockShareOFT'
const tokenSymbol = 'MockShare'

const deploy: DeployFunction = async (hre) => {
const { getNamedAccounts, deployments } = hre

const { deploy } = deployments
const { deployer } = await getNamedAccounts()

assert(deployer, 'Missing named deployer account')

console.log(`Network: ${hre.network.name}`)
console.log(`Deployer: ${deployer}`)

const ovaultDeployment = await hre.deployments.getOrNull(ovaultContractName)
if (ovaultDeployment) {
throw new Error(
`OVault contract deployed on network ${hre.network.name}. This network can only support ShareOFTAdapter`
)
}

const endpointV2Deployment = await hre.deployments.get('EndpointV2')

const { address } = await deploy(shareOFTContractName, {
from: deployer,
args: [
tokenName, // name
tokenSymbol, // symbol
endpointV2Deployment.address, // LayerZero's EndpointV2 address
deployer, // owner
],
log: true,
skipIfAlreadyDeployed: true,
})

console.log(`Deployed contract: ${shareOFTContractName}, network: ${hre.network.name}, address: ${address}`)
}

deploy.tags = ['share']

export default deploy
34 changes: 34 additions & 0 deletions examples/ovault-evm/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[profile.default]
solc-version = '0.8.22'
src = 'contracts'
out = 'out'
test = 'test'
cache_path = 'cache/foundry'
verbosity = 3
optimizer = true
optimizer_runs = 20_000

libs = [
# We provide a set of useful contract utilities
# in the lib directory of @layerzerolabs/toolbox-foundry:
#
# - forge-std
# - ds-test
# - solidity-bytes-utils
'node_modules/@layerzerolabs/toolbox-foundry/lib',
'node_modules',
]

remappings = [
# Due to a misconfiguration of solidity-bytes-utils, an outdated version
# of forge-std is being dragged in
#
# To remedy this, we'll remap the ds-test and forge-std imports to our own versions
'ds-test/=node_modules/@layerzerolabs/toolbox-foundry/lib/ds-test',
'forge-std/=node_modules/@layerzerolabs/toolbox-foundry/lib/forge-std',
'@layerzerolabs/=node_modules/@layerzerolabs/',
'@openzeppelin/=node_modules/@openzeppelin/',
]

[fuzz]
runs = 1000
Loading