Skip to content

Commit f62676d

Browse files
authored
Add send sol command (#715)
1 parent 02638fd commit f62676d

File tree

1 file changed

+43
-0
lines changed
  • governance/xc_admin/packages/xc_admin_cli/src

1 file changed

+43
-0
lines changed

governance/xc_admin/packages/xc_admin_cli/src/index.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
SYSVAR_RENT_PUBKEY,
66
SYSVAR_CLOCK_PUBKEY,
77
AccountMeta,
8+
SystemProgram,
9+
LAMPORTS_PER_SOL,
810
} from "@solana/web3.js";
911
import { program } from "commander";
1012
import {
@@ -360,6 +362,47 @@ multisigCommand("propose-token-transfer", "Propose token transfer")
360362
await proposeInstructions(squad, vault, [proposalInstruction], false);
361363
});
362364

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+
363406
/**
364407
* Activate proposal, mostly useful for cleaning up draft proposals that happen when the browser wallet fails to send all transactions succesfully
365408
*/

0 commit comments

Comments
 (0)