-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayerzero.config.ts
More file actions
111 lines (102 loc) · 4.13 KB
/
layerzero.config.ts
File metadata and controls
111 lines (102 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { EndpointId } from '@layerzerolabs/lz-definitions'
import { ExecutorOptionType } from '@layerzerolabs/lz-v2-utilities'
import { generateConnectionsConfig } from '@layerzerolabs/metadata-tools'
import { OAppEnforcedOption, OmniPointHardhat } from '@layerzerolabs/toolbox-hardhat'
import { getOftStoreAddress } from './tasks/solana'
// Note: Do not use address for EVM OmniPointHardhat contracts. Contracts are loaded using hardhat-deploy.
// If you do use an address, ensure artifacts exists.
const sepoliaContract: OmniPointHardhat = {
eid: EndpointId.SEPOLIA_V2_TESTNET,
contractName: 'AlphaOFT',
}
const holeskyContract: OmniPointHardhat = {
eid: EndpointId.HOLESKY_V2_TESTNET,
contractName: 'AlphaOFT',
}
const solanaContract: OmniPointHardhat = {
eid: EndpointId.SOLANA_V2_TESTNET,
address: getOftStoreAddress(EndpointId.SOLANA_V2_TESTNET),
}
const EVM_ENFORCED_OPTIONS: OAppEnforcedOption[] = [
{
msgType: 1,
optionType: ExecutorOptionType.LZ_RECEIVE,
gas: 80000,
value: 0,
},
{
msgType: 2,
optionType: ExecutorOptionType.LZ_RECEIVE,
gas: 250000,
value: 0,
},
{
msgType: 2,
optionType: ExecutorOptionType.COMPOSE,
index: 0,
gas: 150000,
value: 0,
},
]
const CU_LIMIT = 200000 // This represents the CU limit for executing the `lz_receive` function on Solana.
const SPL_TOKEN_ACCOUNT_RENT_VALUE = 2039280 // This figure represents lamports (https://solana.com/docs/references/terminology#lamport) on Solana. Read below for more details.
/*
* Elaboration on `value` when sending OFTs to Solana:
* When sending OFTs to Solana, SOL is needed for rent (https://solana.com/docs/core/accounts#rent) to initialize the recipient's token account.
* The `2039280` lamports value is the exact rent value needed for SPL token accounts (0.00203928 SOL).
* For Token2022 token accounts, you will need to increase `value` to a higher amount, which depends on the token account size, which in turn depends on the extensions that you enable.
*/
const SOLANA_ENFORCED_OPTIONS: OAppEnforcedOption[] = [
{
msgType: 1,
optionType: ExecutorOptionType.LZ_RECEIVE,
gas: CU_LIMIT,
value: SPL_TOKEN_ACCOUNT_RENT_VALUE,
},
{
msgType: 2,
optionType: ExecutorOptionType.LZ_RECEIVE,
gas: CU_LIMIT,
value: SPL_TOKEN_ACCOUNT_RENT_VALUE,
},
{
msgType: 2,
optionType: ExecutorOptionType.COMPOSE,
index: 0,
gas: 80000,
value: 0,
},
]
// Learn about Message Execution Options: https://docs.layerzero.network/v2/developers/solana/oft/account#message-execution-options
// Learn more about the Simple Config Generator - https://docs.layerzero.network/v2/developers/evm/technical-reference/simple-config
export default async function () {
// note: pathways declared here are automatically bidirectional
// if you declare A,B there's no need to declare B,A
const connections = await generateConnectionsConfig([
[
sepoliaContract, // Chain A contract
solanaContract, // Chain B contract
[['LayerZero Labs'], []], // [ requiredDVN[], [ optionalDVN[], threshold ] ]
[2, 2], // [A to B confirmations, B to A confirmations]
[SOLANA_ENFORCED_OPTIONS, EVM_ENFORCED_OPTIONS], // Chain B enforcedOptions, Chain A enforcedOptions
],
[
holeskyContract, // Chain A contract
solanaContract, // Chain B contract
[['LayerZero Labs'], []], // [ requiredDVN[], [ optionalDVN[], threshold ] ]
[2, 2], // [A to B confirmations, B to A confirmations]
[SOLANA_ENFORCED_OPTIONS, EVM_ENFORCED_OPTIONS], // Chain B enforcedOptions, Chain A enforcedOptions
],
[
sepoliaContract,
holeskyContract,
[['LayerZero Labs'], []],
[2, 2],
[EVM_ENFORCED_OPTIONS, EVM_ENFORCED_OPTIONS],
],
])
return {
contracts: [{ contract: sepoliaContract }, { contract: solanaContract }, { contract: holeskyContract }],
connections,
}
}