Skip to content
Open
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
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ RPC_URL_OPTIMISM=
RPC_URL_ETHEREUM_TESTNET=
RPC_URL_HYPEREVM_TESTNET=

# Use https://www.helius.dev/ for mainnet
RPC_URL_SOLANA=https://api.mainnet-beta.solana.com
RPC_URL_SOLANA_TESTNET=https://api.devnet.solana.com

# Hardhat.
MNEMONIC=
PRIVATE_KEY=
5 changes: 1 addition & 4 deletions Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ resolution = false
skip-lint = false

[programs.localnet]
oft = "G2BYTnfGCMQAErMZkTBCFSapKevzf6QCjizjXi8hFEtJ"
oft = "H5WWM7uWHbmZjThKyPbjNGvAagizKA9zzchZWwn79W99"

[registry]
url = "https://api.apr.dev"

[provider]
cluster = "localnet"
wallet = "./junk-id.json"

[scripts]
test = "npx jest test/anchor"
10 changes: 10 additions & 0 deletions consts/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@ export const OPTIONAL_DVNS: Record<string, Partial<Record<EndpointId, string>>>
[EndpointId.ETHEREUM_V2_MAINNET]: '0xa4fe5a5b9a846458a70cd0748228aed3bf65c2cd',
[EndpointId.HYPERLIQUID_V2_MAINNET]: '0x83342ec538df0460e730a8f543fe63063e2d44c4',
[EndpointId.OPTIMISM_V2_MAINNET]: '0x5b6735c66d97479ccd18294fc96b3084ecb2fa3f',
[EndpointId.SOLANA_V2_MAINNET]: '7jMeX5mzXnSSKYd8DxBDP4xMnkNFZZZm5W28FWUTbwU3',
},
DEUTSCHE_TELEKOM: {
[EndpointId.ETHEREUM_V2_MAINNET]: '0x373a6e5c0c4e89e24819f00aa37ea370917aaff4',
[EndpointId.HYPERLIQUID_V2_MAINNET]: '0x32ffd21260172518a8844fec76a88c8f239c384b',
[EndpointId.OPTIMISM_V2_MAINNET]: '0x427bd19a0463fc4edc2e247d35eb61323d7e5541',
[EndpointId.SOLANA_V2_MAINNET]: 'FxFxe8j7e2xgpP9bw8LUehmz7DoQXaNFadJMEUKwBcRs',
},
LUGANODES: {
[EndpointId.ETHEREUM_V2_MAINNET]: '0x58249a2ec05c1978bf21df1f5ec1847e42455cf4',
[EndpointId.HYPERLIQUID_V2_MAINNET]: '0x9e451905f65ef78d62b93dac3513486da8429d0a',
[EndpointId.OPTIMISM_V2_MAINNET]: '0xd841a741addcb6dea735d3b8c9faf96ba3f3d30d',
[EndpointId.SOLANA_V2_MAINNET]: '41QAdzUraTcvk1P2B6fcs5nQ4EeEKEGnQy5EPpCQ5AdX',
},
P2P: {
[EndpointId.ETHEREUM_V2_MAINNET]: '0x06559ee34d85a88317bf0bfe307444116c631b67',
[EndpointId.HYPERLIQUID_V2_MAINNET]: '0xc7423626016bc40375458bc0277f28681ec91c8e',
[EndpointId.OPTIMISM_V2_MAINNET]: '0x539008c98b17803a273edf98aba2d4414ee3f4d7',
[EndpointId.SOLANA_V2_MAINNET]: '29EKzmCscUg8mf4f5uskwMqvu2SXM8hKF1gWi1cCBoKT',
},
}

Expand All @@ -32,6 +36,7 @@ export const CONFIRMATIONS: Partial<Record<EndpointId, number>> = {
[EndpointId.ETHEREUM_V2_MAINNET]: 15,
[EndpointId.HYPERLIQUID_V2_MAINNET]: 1,
[EndpointId.OPTIMISM_V2_MAINNET]: 20,
[EndpointId.SOLANA_V2_MAINNET]: 32,
}

const DEFAULT_ENFORCED_OPTIONS: OAppEnforcedOption[] = [
Expand All @@ -43,12 +48,17 @@ const DEFAULT_ENFORCED_OPTIONS: OAppEnforcedOption[] = [
export const ENFORCED_OPTIONS: Partial<Record<EndpointId, OAppEnforcedOption[]>> = {
[EndpointId.ETHEREUM_V2_MAINNET]: DEFAULT_ENFORCED_OPTIONS,
[EndpointId.HYPERLIQUID_V2_MAINNET]: DEFAULT_ENFORCED_OPTIONS,
[EndpointId.SOLANA_V2_MAINNET]: [
{ msgType: 1, optionType: ExecutorOptionType.LZ_RECEIVE, gas: 200_000, value: 2_500_000 },
{ msgType: 2, optionType: ExecutorOptionType.LZ_RECEIVE, gas: 200_000, value: 2_500_000 },
],
}

export const OWNERS: Partial<Record<EndpointId, string>> = {
[EndpointId.ETHEREUM_V2_MAINNET]: '0xfA633B67b1d9371eBa32cf3476F275D75C75ce77',
[EndpointId.HYPERLIQUID_V2_MAINNET]: '0xfA633B67b1d9371eBa32cf3476F275D75C75ce77',
[EndpointId.OPTIMISM_V2_MAINNET]: '0xfA633B67b1d9371eBa32cf3476F275D75C75ce77',
[EndpointId.SOLANA_V2_MAINNET]: 'FPg2KxupxTMNFk4PwBXBVF2PSvVfKyL9QBWi21huA47E',
} as const

export const getRequiredDVNs = (_eid: EndpointId): string[] => {
Expand Down
20 changes: 14 additions & 6 deletions consts/testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { ExecutorOptionType } from '@layerzerolabs/lz-v2-utilities'
import { OAppEnforcedOption } from '@layerzerolabs/toolbox-hardhat'

// These are not the selected DVNs, but they are used to mimic the 2/4 optional DVNs
// set-up as best as possible, as only 3 DVNs support Sepolia <-> HyperEVM Testnet.
// set-up as best as possible, as only 3 DVNs support Sepolia <-> HyperEVM Testnet
// and only 2 DVNs that supports Solana <-> *.
export const OPTIONAL_DVNS: Record<string, Partial<Record<EndpointId, string>>> = {
LAYERZERO_LABS: {
[EndpointId.SEPOLIA_V2_TESTNET]: '0x8eebf8b423b73bfca51a1db4b7354aa0bfca9193',
[EndpointId.HYPERLIQUID_V2_TESTNET]: '0x91e698871030d0e1b6c9268c20bb57e2720618dd',
[EndpointId.SOLANA_V2_TESTNET]: '4VDjp6XQaxoZf5RGwiPU9NR1EXSZn2TP4ATMmiSzLfhb',
},
MANTLE01: {
[EndpointId.SEPOLIA_V2_TESTNET]: '0x6943872cfc48f6b18f8b81d57816733d4545eca3',
Expand All @@ -16,6 +18,7 @@ export const OPTIONAL_DVNS: Record<string, Partial<Record<EndpointId, string>>>
P2P: {
[EndpointId.SEPOLIA_V2_TESTNET]: '0x9efba56c8598853e5b40fd9a66b54a6c163742d7',
[EndpointId.HYPERLIQUID_V2_TESTNET]: '0x4c90f152707c6eab6cd801e326d25b0591e449a2',
[EndpointId.SOLANA_V2_TESTNET]: '29EKzmCscUg8mf4f5uskwMqvu2SXM8hKF1gWi1cCBoKT',
},
}

Expand All @@ -25,6 +28,7 @@ export const OPTIONAL_DVNS_THRESHOLD = 2
export const CONFIRMATIONS: Partial<Record<EndpointId, number>> = {
[EndpointId.SEPOLIA_V2_TESTNET]: 2,
[EndpointId.HYPERLIQUID_V2_TESTNET]: 1,
[EndpointId.SOLANA_V2_TESTNET]: 10,
}

const DEFAULT_ENFORCED_OPTIONS: OAppEnforcedOption[] = [
Expand All @@ -35,23 +39,27 @@ const DEFAULT_ENFORCED_OPTIONS: OAppEnforcedOption[] = [
export const ENFORCED_OPTIONS: Partial<Record<EndpointId, OAppEnforcedOption[]>> = {
[EndpointId.SEPOLIA_V2_TESTNET]: DEFAULT_ENFORCED_OPTIONS,
[EndpointId.HYPERLIQUID_V2_TESTNET]: DEFAULT_ENFORCED_OPTIONS,
[EndpointId.SOLANA_V2_TESTNET]: [
{ msgType: 1, optionType: ExecutorOptionType.LZ_RECEIVE, gas: 200_000, value: 2_500_000 },
{ msgType: 2, optionType: ExecutorOptionType.LZ_RECEIVE, gas: 200_000, value: 2_500_000 },
],
}

export const OWNERS: Partial<Record<EndpointId, string>> = {
[EndpointId.SEPOLIA_V2_TESTNET]: '0xa4B4c951E9Fae331c65700C9BB6A21c236fcF165',
[EndpointId.HYPERLIQUID_V2_TESTNET]: '0xa4B4c951E9Fae331c65700C9BB6A21c236fcF165',
[EndpointId.SOLANA_V2_TESTNET]: 'Hy6h65XTsDkR6DBcGjr33WTpCJpM9dyLywYyu81vPKob', // $SQUADS_VAULT_ADDR
} as const

export const getRequiredDVNs = (_eid: EndpointId): string[] => {
return [] as string[]
}

export const getOptionalDVNs = (eid: EndpointId): string[] => {
return Object.values(OPTIONAL_DVNS)
.map((dvnMap) => dvnMap[eid])
export const getOptionalDVNs = (fromEid: EndpointId, toEid: EndpointId): string[] =>
Object.values(OPTIONAL_DVNS)
// Gets optional dvn only if it supports both eids
.map((dvnMap) => (dvnMap[toEid] ? dvnMap[fromEid] : null))
.filter(Boolean) as string[]
}

export const getEnforcedOptions = (eid: EndpointId): OAppEnforcedOption[] => {
return ENFORCED_OPTIONS[eid] ?? DEFAULT_ENFORCED_OPTIONS
}
Expand Down
4 changes: 2 additions & 2 deletions deploy/WXRPMintBurnOFTAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const deployMaba = async (hre: HardhatRuntimeEnvironment) => {

// This contract requires >1.5M gas to deploy. Switching to big blocks in HyperEVM.
const deployment = await hre.deployments.getOrNull(contractName)
if (isHyperEvm && !deployment) await useBigBlock(wallet!, isHyperEvmTestnet, logLevel)
if (isHyperEvm && !deployment) await useBigBlock(wallet!, isHyperEvmTestnet, logLevel, true)

const result = await deploy(contractName, {
from: signer.address,
Expand All @@ -41,7 +41,7 @@ export const deployMaba = async (hre: HardhatRuntimeEnvironment) => {
skipIfAlreadyDeployed: false,
})

if (isHyperEvm && !deployment) await useSmallBlock(wallet!, isHyperEvmTestnet, logLevel)
if (isHyperEvm && !deployment) await useSmallBlock(wallet!, isHyperEvmTestnet, logLevel, true)

return result
}
Expand Down
7 changes: 7 additions & 0 deletions deployments/solana-mainnet/OFT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"programId": "H5WWM7uWHbmZjThKyPbjNGvAagizKA9zzchZWwn79W99",
"mint": "6UpQcMAb5xMzxc7ZfPaVMgx3KqsvKZdT5U718BzD5We2",
"mintAuthority": "E5GXVzJbuN7iPJAfNB23SMXgQLXWGkqRWgvsq4Dg156o",
"escrow": "GCBEb6WBHu6dkd8hZfkucWvoyycBo57qVpn2DuKgSovR",
"oftStore": "FwF2zxV5MaFZfq3pgfcgzJqKWBRyYsiVNVEXqxgshKaH"
}
7 changes: 7 additions & 0 deletions deployments/solana-testnet/OFT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"programId": "ANBPMYzXfRt5xwwGDzakyjHCeCr2jkLJrN5E8z8vSspD",
"mint": "3KndFCxLqndtfnY7uafEZ6iDg9dTAWXiFGrkhf8TQi2z",
"mintAuthority": "8vWTyXD3rVza9Fvr5oN7QuhASGEyMYi6Dzj7pZGRXCCG",
"escrow": "CrqF8RJUVP9fH5rNsk9xUhSX66HAZ6dGVui7eYJN5Xvp",
"oftStore": "2pkdQ9UWzgLAJ77KZ6avHHWtTVYE7gq1kQV67j8xzDNV"
}
2 changes: 2 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { EndpointId } from '@layerzerolabs/lz-definitions'
import './tasks/transferErc20AdminRole'
import './tasks/transferProxyAdminRole'

import './tasks/index'

// Set your preferred authentication method
//
// If you prefer using a mnemonic, set a MNEMONIC environment variable
Expand Down
2 changes: 2 additions & 0 deletions layerzero.mainnet.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import {
getOwnerAddress,
getRequiredDVNs,
} from './consts/mainnet'
import { getOftStoreAddress } from './tasks/solana'

// Define all contracts.
export const CONTRACTS: OmniPointHardhat[] = [
{ eid: EndpointId.ETHEREUM_V2_MAINNET, contractName: 'WXRPMintBurnOFTAdapter' },
{ eid: EndpointId.HYPERLIQUID_V2_MAINNET, contractName: 'WXRPMintBurnOFTAdapter' },
{ eid: EndpointId.OPTIMISM_V2_MAINNET, contractName: 'WXRPMintBurnOFTAdapter' },
{ eid: EndpointId.SOLANA_V2_MAINNET, address: getOftStoreAddress(EndpointId.SOLANA_V2_MAINNET) },
]

// Generate all possible connections.
Expand Down
54 changes: 54 additions & 0 deletions layerzero.mainnet.dewire.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Note:
*
* This config is part of the migration to the new spl token solana OFT.
* It can be deleted once de-wiring of the outdated token2022 OFT is successfully completed.
*/
import { EndpointId } from '@layerzerolabs/lz-definitions'
import { OmniPointHardhat } from '@layerzerolabs/toolbox-hardhat'

const previousSolanaOftStoreAddress = 'GKzT5jtvcysvWoRN7Kgro1nqriS6QhHjyqrtL6UNK89t'
const blockedMsgLibOnSolana = '2XrYqmhBMPJgDsb4SVbjV1PnJBprurd5bzRCkHwiFCJB'

// Define all contracts.
export const CONTRACTS: OmniPointHardhat[] = [
{ eid: EndpointId.ETHEREUM_V2_MAINNET, contractName: 'WXRPMintBurnOFTAdapter' },
{ eid: EndpointId.HYPERLIQUID_V2_MAINNET, contractName: 'WXRPMintBurnOFTAdapter' },
{ eid: EndpointId.OPTIMISM_V2_MAINNET, contractName: 'WXRPMintBurnOFTAdapter' },
{ eid: EndpointId.SOLANA_V2_MAINNET, address: previousSolanaOftStoreAddress },
]

// Generate connections only from Solana to EVM chains
export const generateConnections = async () => {
const connections = []
const solanaContract = CONTRACTS.find((contract) => contract.eid === EndpointId.SOLANA_V2_MAINNET)
const evmContracts = CONTRACTS.filter((contract) => contract.eid !== EndpointId.SOLANA_V2_MAINNET)

if (!solanaContract) {
throw new Error('Solana contract not found in CONTRACTS')
}

// Generate connections from Solana to all EVM chains.
for (const evmContract of evmContracts) {
connections.push({
from: solanaContract,
to: evmContract,
config: {
sendLibrary: blockedMsgLibOnSolana,
},
})
}

return connections
}

export default async function () {
const connections = await generateConnections()

return {
contracts: CONTRACTS.map((contract) => ({
contract,
})),
connections,
}
}
6 changes: 4 additions & 2 deletions layerzero.testnet.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import {
getOwnerAddress,
getRequiredDVNs,
} from './consts/testnet'
import { getOftStoreAddress } from './tasks/solana'

// Define all contracts.
export const CONTRACTS: OmniPointHardhat[] = [
{ eid: EndpointId.SEPOLIA_V2_TESTNET, contractName: 'WXRPMintBurnOFTAdapter' },
{ eid: EndpointId.HYPERLIQUID_V2_TESTNET, contractName: 'WXRPMintBurnOFTAdapter' },
{ eid: EndpointId.SOLANA_V2_TESTNET, address: getOftStoreAddress(EndpointId.SOLANA_V2_TESTNET) },
]

// Generate all possible connections.
Expand Down Expand Up @@ -42,15 +44,15 @@ export const generateConnections = async () => {
ulnConfig: {
confirmations: CONFIRMATIONS[from.eid],
requiredDVNs: getRequiredDVNs(from.eid),
optionalDVNs: getOptionalDVNs(from.eid),
optionalDVNs: getOptionalDVNs(from.eid, to.eid),
optionalDVNThreshold: OPTIONAL_DVNS_THRESHOLD,
},
},
receiveConfig: {
ulnConfig: {
confirmations: CONFIRMATIONS[to.eid],
requiredDVNs: getRequiredDVNs(from.eid),
optionalDVNs: getOptionalDVNs(from.eid),
optionalDVNs: getOptionalDVNs(from.eid, to.eid),
optionalDVNThreshold: OPTIONAL_DVNS_THRESHOLD,
},
},
Expand Down
53 changes: 53 additions & 0 deletions layerzero.testnet.dewire.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Note:
*
* This config is part of the migration to the new spl token solana OFT.
* It can be deleted once de-wiring of the outdated token2022 OFT is successfully completed.
*/
import { EndpointId } from '@layerzerolabs/lz-definitions'
import { OmniPointHardhat } from '@layerzerolabs/toolbox-hardhat'

const previousSolanaOftStoreAddress = '44F6EuNhHYmt7JRXvjzw5vJjGogdeVHRw1BQBEQ9NxBT'
const blockedMsgLibOnSolana = '2XrYqmhBMPJgDsb4SVbjV1PnJBprurd5bzRCkHwiFCJB'

// Define all contracts.
export const CONTRACTS: OmniPointHardhat[] = [
{ eid: EndpointId.SEPOLIA_V2_TESTNET, contractName: 'WXRPMintBurnOFTAdapter' },
{ eid: EndpointId.HYPERLIQUID_V2_TESTNET, contractName: 'WXRPMintBurnOFTAdapter' },
{ eid: EndpointId.SOLANA_V2_TESTNET, address: previousSolanaOftStoreAddress },
]

// Generate connections only from Solana devnet to EVM testnet chains
export const generateConnections = async () => {
const connections = []
const solanaContract = CONTRACTS.find((contract) => contract.eid === EndpointId.SOLANA_V2_TESTNET)
const evmContracts = CONTRACTS.filter((contract) => contract.eid !== EndpointId.SOLANA_V2_TESTNET)

if (!solanaContract) {
throw new Error('Solana contract not found in CONTRACTS')
}

// Generate connections from Solana to all EVM chains.
for (const evmContract of evmContracts) {
connections.push({
from: solanaContract,
to: evmContract,
config: {
sendLibrary: blockedMsgLibOnSolana,
},
})
}

return connections
}

export default async function () {
const connections = await generateConnections()

return {
contracts: CONTRACTS.map((contract) => ({
contract,
})),
connections,
}
}
Loading