-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26859cf
commit d7a3675
Showing
10 changed files
with
174 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ | |
"@/tasks/*": ["./tasks/*"] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { INewOperation } from '@layerzerolabs/devtools-extensible-cli' | ||
|
||
import { quoteSendOFTFA } from '../../tasks/quoteSendOFTFA' | ||
|
||
class QuoteSendOFTFA implements INewOperation { | ||
vm = 'move' | ||
operation = 'quoteSend' | ||
description = 'Quote send an OFT with FA' | ||
reqArgs = ['amount_ld', 'min_amount_ld', 'to_address', 'gas_limit', 'dst_eid'] | ||
|
||
addArgs = [ | ||
{ | ||
name: '--dst-eid', | ||
arg: { | ||
help: 'destination endpoint id', | ||
required: true, | ||
}, | ||
}, | ||
{ | ||
name: '--gas-limit', | ||
arg: { | ||
help: 'gas limit', | ||
required: true, | ||
}, | ||
}, | ||
{ | ||
name: '--min-amount-ld', | ||
arg: { | ||
help: 'minimum amount to receive', | ||
required: true, | ||
}, | ||
}, | ||
{ | ||
name: '--to-address', | ||
arg: { | ||
help: 'to address', | ||
required: true, | ||
}, | ||
}, | ||
{ | ||
name: '--amount-ld', | ||
arg: { | ||
help: 'amount to send', | ||
required: true, | ||
}, | ||
}, | ||
] | ||
|
||
async impl(args: any): Promise<void> { | ||
await quoteSendOFTFA(args.amount_ld, args.min_amount_ld, args.to_address, args.gas_limit, args.dst_eid) | ||
} | ||
} | ||
|
||
const NewOperation = new QuoteSendOFTFA() | ||
export { NewOperation } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Aptos, AptosConfig } from '@aptos-labs/ts-sdk' | ||
|
||
import { EndpointId } from '@layerzerolabs/lz-definitions' | ||
import { Options } from '@layerzerolabs/lz-v2-utilities' | ||
|
||
import { OFT } from '@layerzerolabs/devtools-move/sdk/oft' | ||
import { hexAddrToAptosBytesAddr } from '@layerzerolabs/devtools-move/sdk/utils' | ||
|
||
import { getLzNetworkStage, parseYaml } from '@layerzerolabs/devtools-move/tasks/move/utils/aptosNetworkParser' | ||
import { getMoveVMOftAddress } from '@layerzerolabs/devtools-move/tasks/move/utils/utils' | ||
|
||
async function quoteSendOFTFA( | ||
amountLd: number, | ||
minAmountLd: number, | ||
toAddress: string, | ||
gasLimit: number, | ||
dstEid: EndpointId | ||
) { | ||
const { account_address, private_key, network } = await parseYaml() | ||
console.log(`Using aptos network ${network}`) | ||
|
||
const aptosConfig = new AptosConfig({ network: network }) | ||
const aptos = new Aptos(aptosConfig) | ||
|
||
const lzNetworkStage = getLzNetworkStage(network) | ||
const aptosOftAddress = getMoveVMOftAddress(lzNetworkStage) | ||
|
||
const oft = new OFT(aptos, aptosOftAddress, account_address, private_key) | ||
|
||
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: ${aptosOftAddress}`) | ||
console.log(`From account: ${account_address}`) | ||
console.log(`To account: ${toAddress}`) | ||
|
||
const extra_options = options.toBytes() | ||
const compose_message = new Uint8Array([]) | ||
const oft_cmd = new Uint8Array([]) | ||
|
||
const [nativeFee, zroFee] = await oft.quoteSend( | ||
account_address, | ||
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 { quoteSendOFTFA } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.