-
Notifications
You must be signed in to change notification settings - Fork 270
Expand file tree
/
Copy pathquoteSendOFT.ts
More file actions
48 lines (41 loc) · 1.58 KB
/
quoteSendOFT.ts
File metadata and controls
48 lines (41 loc) · 1.58 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
import { Options } from '@layerzerolabs/lz-v2-utilities'
import { EndpointId } from '@layerzerolabs/lz-definitions'
import { hexAddrToAptosBytesAddr, basexToBytes32, TaskContext } from '@layerzerolabs/devtools-move'
async function quoteSendOFT(
taskContext: TaskContext,
amountLd: number,
minAmountLd: number,
toAddress: string,
gasLimit: number,
dstEid: EndpointId,
srcAddress: string
) {
// Pad EVM address to 64 chars and convert Solana address to Aptos address
toAddress = basexToBytes32(toAddress)
const toAddressBytes = hexAddrToAptosBytesAddr(toAddress)
const options = Options.newOptions().addExecutorLzReceiveOption(BigInt(gasLimit))
console.log(`Attempting to quote send ${amountLd} units`)
console.log(`Using OFT at address: ${taskContext.oAppAddress}`)
console.log(`From account: ${srcAddress}`)
console.log(`To account: ${toAddress}`)
console.log(`dstEid: ${dstEid}`)
const extra_options = options.toBytes()
const compose_message = new Uint8Array([])
const oft_cmd = new Uint8Array([])
const [nativeFee, zroFee] = await taskContext.oft.quoteSend(
srcAddress,
dstEid,
toAddressBytes,
amountLd,
minAmountLd,
extra_options,
compose_message,
oft_cmd,
false // pay_in_zro: false to pay in native tokens
)
console.log('\nQuote received:')
console.log('- Native fee:', nativeFee)
console.log('- ZRO fee:', zroFee)
console.log('If the above fees are acceptable, the wiring is confirmed to be successful.')
}
export { quoteSendOFT }