|
5 | 5 | SYSVAR_RENT_PUBKEY,
|
6 | 6 | SYSVAR_CLOCK_PUBKEY,
|
7 | 7 | AccountMeta,
|
| 8 | + SystemProgram, |
| 9 | + LAMPORTS_PER_SOL, |
8 | 10 | } from "@solana/web3.js";
|
9 | 11 | import { program } from "commander";
|
10 | 12 | import {
|
@@ -360,6 +362,47 @@ multisigCommand("propose-token-transfer", "Propose token transfer")
|
360 | 362 | await proposeInstructions(squad, vault, [proposalInstruction], false);
|
361 | 363 | });
|
362 | 364 |
|
| 365 | +multisigCommand("propose-sol-transfer", "Propose sol transfer") |
| 366 | + .requiredOption("-a, --amount <number>", "amount in sol") |
| 367 | + .requiredOption("-d, --destination <pubkey>", "destination address") |
| 368 | + .action(async (options: any) => { |
| 369 | + const wallet = await loadHotWalletOrLedger( |
| 370 | + options.wallet, |
| 371 | + options.ledgerDerivationAccount, |
| 372 | + options.ledgerDerivationChange |
| 373 | + ); |
| 374 | + |
| 375 | + const cluster: PythCluster = options.cluster; |
| 376 | + const isRemote = isRemoteCluster(cluster); |
| 377 | + const destination: PublicKey = new PublicKey(options.destination); |
| 378 | + const vault: PublicKey = new PublicKey(options.vault); |
| 379 | + const amount: number = options.amount; |
| 380 | + |
| 381 | + const squad = SquadsMesh.endpoint( |
| 382 | + getPythClusterApiUrl(getMultisigCluster(cluster)), |
| 383 | + wallet |
| 384 | + ); |
| 385 | + const msAccount = await squad.getMultisig(vault); |
| 386 | + const vaultAuthority = squad.getAuthorityPDA( |
| 387 | + msAccount.publicKey, |
| 388 | + msAccount.authorityIndex |
| 389 | + ); |
| 390 | + |
| 391 | + const proposalInstruction: TransactionInstruction = SystemProgram.transfer({ |
| 392 | + fromPubkey: isRemote ? mapKey(vaultAuthority) : vaultAuthority, |
| 393 | + toPubkey: destination, |
| 394 | + lamports: amount * LAMPORTS_PER_SOL, |
| 395 | + }); |
| 396 | + |
| 397 | + await proposeInstructions( |
| 398 | + squad, |
| 399 | + vault, |
| 400 | + [proposalInstruction], |
| 401 | + isRemote, |
| 402 | + WORMHOLE_ADDRESS[getMultisigCluster(cluster)] |
| 403 | + ); |
| 404 | + }); |
| 405 | + |
363 | 406 | /**
|
364 | 407 | * Activate proposal, mostly useful for cleaning up draft proposals that happen when the browser wallet fails to send all transactions succesfully
|
365 | 408 | */
|
|
0 commit comments