From 29509141aec10beadb284427ba265c6e98bfe0b8 Mon Sep 17 00:00:00 2001 From: yugure <109891005+yugure-orca@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:49:47 +0900 Subject: [PATCH 1/5] use promptText to input priority fee I could not input 0.000001 --- legacy-sdk/cli/src/utils/transaction_sender.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/legacy-sdk/cli/src/utils/transaction_sender.ts b/legacy-sdk/cli/src/utils/transaction_sender.ts index a154cb965..03b6b8cff 100644 --- a/legacy-sdk/cli/src/utils/transaction_sender.ts +++ b/legacy-sdk/cli/src/utils/transaction_sender.ts @@ -7,7 +7,7 @@ import { } from "@orca-so/common-sdk"; import Decimal from "decimal.js"; import base58 from "bs58"; -import { promptConfirm, promptNumber } from "./prompt"; +import { promptConfirm, promptText } from "./prompt"; export async function sendTransaction( builder: TransactionBuilder, @@ -31,7 +31,7 @@ export async function sendTransaction( let priorityFeeInLamports = 0; while (true) { - const priorityFeeInSOL = await promptNumber("priorityFeeInSOL"); + const priorityFeeInSOL = await promptText("priorityFeeInSOL"); priorityFeeInLamports = DecimalUtil.toBN( new Decimal(priorityFeeInSOL), 9, From ce6ff2bfdf226fbb61e5a9619e3cfb0bf59bc4f2 Mon Sep 17 00:00:00 2001 From: yugure <109891005+yugure-orca@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:51:14 +0900 Subject: [PATCH 2/5] add setRewardEmissionsSuperAuthority --- .../set_reward_emissions_super_authority.ts | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 legacy-sdk/cli/src/commands/set_reward_emissions_super_authority.ts diff --git a/legacy-sdk/cli/src/commands/set_reward_emissions_super_authority.ts b/legacy-sdk/cli/src/commands/set_reward_emissions_super_authority.ts new file mode 100644 index 000000000..8cac23d5b --- /dev/null +++ b/legacy-sdk/cli/src/commands/set_reward_emissions_super_authority.ts @@ -0,0 +1,106 @@ +import { PublicKey } from "@solana/web3.js"; +import { WhirlpoolIx } from "@orca-so/whirlpools-sdk"; +import { TransactionBuilder } from "@orca-so/common-sdk"; +import { sendTransaction } from "../utils/transaction_sender"; +import { ctx } from "../utils/provider"; +import { promptConfirm, promptText } from "../utils/prompt"; + +console.info("set RewardEmissionsSuperAuthority..."); + +// prompt +const whirlpoolsConfigPubkeyStr = await promptText("whirlpoolsConfigPubkey"); +const newRewardEmissionsSuperAuthorityPubkeyStr = await promptText( + "newRewardEmissionsSuperAuthorityPubkey", +); +const newRewardEmissionsSuperAuthorityPubkeyAgainStr = await promptText( + "newRewardEmissionsSuperAuthorityPubkeyAgain", +); + +const whirlpoolsConfigPubkey = new PublicKey(whirlpoolsConfigPubkeyStr); +const newRewardEmissionsSuperAuthorityPubkey = new PublicKey( + newRewardEmissionsSuperAuthorityPubkeyStr, +); +const newRewardEmissionsSuperAuthorityPubkeyAgain = new PublicKey( + newRewardEmissionsSuperAuthorityPubkeyAgainStr, +); + +if ( + !newRewardEmissionsSuperAuthorityPubkey.equals( + newRewardEmissionsSuperAuthorityPubkeyAgain, + ) +) { + throw new Error( + "newRewardEmissionsSuperAuthorityPubkey and newRewardEmissionsSuperAuthorityPubkeyAgain must be the same", + ); +} + +const whirlpoolsConfig = await ctx.fetcher.getConfig(whirlpoolsConfigPubkey); +if (!whirlpoolsConfig) { + throw new Error("whirlpoolsConfig not found"); +} + +if ( + !whirlpoolsConfig.rewardEmissionsSuperAuthority.equals(ctx.wallet.publicKey) +) { + throw new Error( + `the current wallet must be the reward emissions super authority(${whirlpoolsConfig.rewardEmissionsSuperAuthority.toBase58()})`, + ); +} + +console.info( + "setting...", + "\n\trewardEmissionsSuperAuthority", + whirlpoolsConfig.rewardEmissionsSuperAuthority.toBase58(), + "\n\tnewRewardEmissionsSuperAuthority", + newRewardEmissionsSuperAuthorityPubkey.toBase58(), +); +console.info("\nif the above is OK, enter YES"); +console.info( + "\n>>>>> WARNING: authority transfer is highly sensitive operation, please double check new authority address <<<<<\n", +); +const yesno = await promptConfirm("yesno"); +if (!yesno) { + throw new Error("stopped"); +} + +const builder = new TransactionBuilder(ctx.connection, ctx.wallet); +builder.addInstruction( + WhirlpoolIx.setRewardEmissionsSuperAuthorityIx(ctx.program, { + whirlpoolsConfig: whirlpoolsConfigPubkey, + rewardEmissionsSuperAuthority: whirlpoolsConfig.rewardEmissionsSuperAuthority, + newRewardEmissionsSuperAuthority: newRewardEmissionsSuperAuthorityPubkey, + }), +); + +await sendTransaction(builder); + +/* + +SAMPLE EXECUTION LOG + +connection endpoint http://localhost:8899 +wallet 2v112XbwQXFrdqX438HUrfZF91qCZb7QRP4bwUiN7JF5 +set RewardEmissionsSuperAuthority... +✔ whirlpoolsConfigPubkey … FcrweFY1G9HJAHG5inkGB6pKg1HZ6x9UC2WioAfWrGkR +✔ newRewardEmissionsSuperAuthorityPubkey … 3otH3AHWqkqgSVfKFkrxyDqd2vK6LcaqigHrFEmWcGuo +✔ newRewardEmissionsSuperAuthorityPubkeyAgain … 3otH3AHWqkqgSVfKFkrxyDqd2vK6LcaqigHrFEmWcGuo +setting... + rewardEmissionsSuperAuthority 2v112XbwQXFrdqX438HUrfZF91qCZb7QRP4bwUiN7JF5 + newRewardEmissionsSuperAuthority 3otH3AHWqkqgSVfKFkrxyDqd2vK6LcaqigHrFEmWcGuo + +if the above is OK, enter YES + +>>>>> WARNING: authority transfer is highly sensitive operation, please double check new authority address <<<<< + +✔ yesno › Yes +estimatedComputeUnits: 102385 +✔ priorityFeeInSOL … 0.000002 +Priority fee: 0.000002 SOL +process transaction... +transaction is still valid, 150 blocks left (at most) +sending... +confirming... +✅successfully landed +signature 432eMv1tPRN6JU7b7ezFCSU1npEVudkmfXcVsUYEnyGep988oLraMP9cz7nMEcwzhh8xW3YfnHZa4eReHU5tfzfC + +*/ From be68ccc325013051194b3268b2b2f2229d98f064 Mon Sep 17 00:00:00 2001 From: yugure <109891005+yugure-orca@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:00:15 +0900 Subject: [PATCH 3/5] add SetRewardAuthority --- .../cli/src/commands/set_reward_authority.ts | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 legacy-sdk/cli/src/commands/set_reward_authority.ts diff --git a/legacy-sdk/cli/src/commands/set_reward_authority.ts b/legacy-sdk/cli/src/commands/set_reward_authority.ts new file mode 100644 index 000000000..b82640e25 --- /dev/null +++ b/legacy-sdk/cli/src/commands/set_reward_authority.ts @@ -0,0 +1,116 @@ +import { PublicKey } from "@solana/web3.js"; +import { + WhirlpoolIx, +} from "@orca-so/whirlpools-sdk"; +import { TransactionBuilder } from "@orca-so/common-sdk"; +import { sendTransaction } from "../utils/transaction_sender"; +import { ctx } from "../utils/provider"; +import { promptConfirm, promptText } from "../utils/prompt"; + +console.info("set RewardAuthority..."); + +// prompt +const whirlpoolPubkeyStr = await promptText("whirlpoolPubkey"); + +const whirlpoolPubkey = new PublicKey(whirlpoolPubkeyStr); +const whirlpool = await ctx.fetcher.getPool(whirlpoolPubkey); +if (!whirlpool) { + throw new Error("whirlpool not found"); +} + +const updatableRewardIndexes: number[] = []; +whirlpool.rewardInfos.forEach((ri, i) => { + const updatable = ri.authority.equals(ctx.wallet.publicKey); + if (updatable) updatableRewardIndexes.push(i); + console.log(`reward[${i}] authority: ${ri.authority.toBase58()} ${updatable ? " (Updatable)" : " (wallet is not authority)"}`); +}) + +if (updatableRewardIndexes.length === 0) { + throw new Error("This wallet is NOT reward authority for all reward indexes"); +} + +console.info("\nEnter new reward authority\n* If you don't want to update it, just type SKIP\n"); + +const newRewardAuthorities: (PublicKey|undefined)[] = []; +for (let i=0; i a === undefined)) { + throw new Error("No new reward authority"); +} + +console.info("setting..."); +for (let i=0; i ${newRewardAuthorities[i]!.toBase58()}`); + } else { + console.info(`\treward[${updatableRewardIndexes[i]}] ${whirlpool.rewardInfos[updatableRewardIndexes[i]].authority.toBase58()} (unchanged)`); + } +} +console.info("\nif the above is OK, enter YES"); +const yesno = await promptConfirm("yesno"); +if (!yesno) { + throw new Error("stopped"); +} + +const builder = new TransactionBuilder(ctx.connection, ctx.wallet); +for (let i=0; i 2v112XbwQXFrdqX438HUrfZF91qCZb7QRP4bwUiN7JF5 + +if the above is OK, enter YES +✔ yesno › Yes +estimatedComputeUnits: 103936 +✔ priorityFeeInSOL … 0.000001 +Priority fee: 0.000001 SOL +process transaction... +transaction is still valid, 150 blocks left (at most) +sending... +confirming... +✅successfully landed +signature 5iLophVC1xsk2MsCZQ5pW81Pa18ta7pe1FsNHQPUptdRh2kLDTHw54MQNwKd5HbVY9kzqNvEELrN4xB29gUhwAPx + +*/ From 61ff0ac76a75ce80dd47db7dc4f94d07e896dac3 Mon Sep 17 00:00:00 2001 From: yugure <109891005+yugure-orca@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:03:59 +0900 Subject: [PATCH 4/5] update README --- legacy-sdk/cli/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/legacy-sdk/cli/README.md b/legacy-sdk/cli/README.md index f157eae87..f5ae22377 100644 --- a/legacy-sdk/cli/README.md +++ b/legacy-sdk/cli/README.md @@ -29,7 +29,7 @@ Token-2022 tokens are acceptable 👍 - `yarn start setDefaultProtocolFeeRate`: set new default protocol fee rate on WhirlpoolsConfig - `yarn start setFeeAuthority`: set new fee authority on WhirlpoolsConfig - `yarn start setCollectProtocolFeesAuthority`: set new collect protocol fees authority on WhirlpoolsConfig -- TODO: set reward emissions super authority +- `yarn start setRewardEmissionsSuperAuthority`: set new reward emissions super authority on WhirlpoolsConfig - TODO: set config extension authority ## Whirlpool & TickArray @@ -41,6 +41,7 @@ Token-2022 tokens are acceptable 👍 - `yarn start deleteTokenBadge`: delete TokenBadge account ## Reward +- `yarn start setRewardAuthority`: set new reward authority of rewards on a whirlpool - `yarn start initializeReward`: initialize new reward for a whirlpool - TODO: set reward emission From 41b2dd4d1e4ef4808c0a89da3dee37ccefffe97d Mon Sep 17 00:00:00 2001 From: yugure <109891005+yugure-orca@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:37:07 +0900 Subject: [PATCH 5/5] fix lint error --- legacy-sdk/cli/src/commands/set_reward_authority.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/legacy-sdk/cli/src/commands/set_reward_authority.ts b/legacy-sdk/cli/src/commands/set_reward_authority.ts index b82640e25..62d7cebe4 100644 --- a/legacy-sdk/cli/src/commands/set_reward_authority.ts +++ b/legacy-sdk/cli/src/commands/set_reward_authority.ts @@ -22,7 +22,7 @@ const updatableRewardIndexes: number[] = []; whirlpool.rewardInfos.forEach((ri, i) => { const updatable = ri.authority.equals(ctx.wallet.publicKey); if (updatable) updatableRewardIndexes.push(i); - console.log(`reward[${i}] authority: ${ri.authority.toBase58()} ${updatable ? " (Updatable)" : " (wallet is not authority)"}`); + console.info(`reward[${i}] authority: ${ri.authority.toBase58()} ${updatable ? " (Updatable)" : " (wallet is not authority)"}`); }) if (updatableRewardIndexes.length === 0) { @@ -40,7 +40,7 @@ for (let i=0; i