From 3912daea292d83265cb0f588732ed292d72a862b Mon Sep 17 00:00:00 2001 From: Noah Prince Date: Mon, 2 Dec 2024 13:17:24 -0800 Subject: [PATCH 1/8] Implement HIP-138 emissions and ops fund switch --- Cargo.lock | 2 +- .../src/switch-mobile-ops-fund.ts | 80 +++++++++++++++++ programs/helium-sub-daos/Cargo.toml | 2 +- .../src/instructions/issue_rewards_v0.rs | 23 +++-- .../helium-sub-daos/src/instructions/mod.rs | 2 + .../instructions/switch_mobile_ops_fund.rs | 88 +++++++++++++++++++ programs/helium-sub-daos/src/lib.rs | 4 + programs/helium-sub-daos/src/state.rs | 7 ++ 8 files changed, 199 insertions(+), 9 deletions(-) create mode 100644 packages/helium-admin-cli/src/switch-mobile-ops-fund.ts create mode 100644 programs/helium-sub-daos/src/instructions/switch_mobile_ops_fund.rs diff --git a/Cargo.lock b/Cargo.lock index 88bc474ef..73d3a39f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1964,7 +1964,7 @@ dependencies = [ [[package]] name = "helium-sub-daos" -version = "0.1.10" +version = "0.1.11" dependencies = [ "anchor-lang", "anchor-spl", diff --git a/packages/helium-admin-cli/src/switch-mobile-ops-fund.ts b/packages/helium-admin-cli/src/switch-mobile-ops-fund.ts new file mode 100644 index 000000000..55e03182e --- /dev/null +++ b/packages/helium-admin-cli/src/switch-mobile-ops-fund.ts @@ -0,0 +1,80 @@ +import * as anchor from "@coral-xyz/anchor"; +import { daoKey, init as initHsd } from "@helium/helium-sub-daos-sdk"; +import { HNT_MINT, MOBILE_MINT } from "@helium/spl-utils"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; +import { PublicKey } from "@solana/web3.js"; +import Squads from "@sqds/sdk"; +import os from "os"; +import yargs from "yargs/yargs"; +import { loadKeypair, sendInstructionsOrSquads } from "./utils"; + +export async function run(args: any = process.argv) { + const yarg = yargs(args).options({ + wallet: { + alias: "k", + describe: "Anchor wallet keypair", + default: `${os.homedir()}/.config/solana/id.json`, + }, + url: { + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", + }, + multisig: { + type: "string", + describe: + "Address of the squads multisig to be authority. If not provided, your wallet will be the authority", + }, + authorityIndex: { + type: "number", + describe: "Authority index for squads. Defaults to 1", + default: 1, + }, + }); + + const argv = await yarg.argv; + process.env.ANCHOR_WALLET = argv.wallet; + process.env.ANCHOR_PROVIDER_URL = argv.url; + anchor.setProvider(anchor.AnchorProvider.local(argv.url)); + const provider = anchor.getProvider() as anchor.AnchorProvider; + + const wallet = new anchor.Wallet(loadKeypair(argv.wallet)); + const squads = Squads.endpoint(process.env.ANCHOR_PROVIDER_URL, wallet, { + commitmentOrConfig: "finalized", + }); + let multisig = argv.multisig ? new PublicKey(argv.multisig) : undefined; + + const hsdProgram = await initHsd(provider); + + const dao = daoKey(HNT_MINT)[0] + const daoAuth = (await hsdProgram.account.subDaoV0.fetch(dao)) + .authority; + const instructions = [ + await hsdProgram.methods + .switchMobileOpsFund() + .accounts({ + authority: daoAuth, + payer: daoAuth, + opsFundHnt: getAssociatedTokenAddressSync( + daoAuth, + HNT_MINT + ), + opsFundMobile: getAssociatedTokenAddressSync( + wallet.publicKey, + MOBILE_MINT + ), + dao, + }) + .instruction(), + ]; + + await sendInstructionsOrSquads({ + provider, + instructions, + signers: [], + executeTransaction: false, + squads, + multisig, + authorityIndex: argv.authorityIndex, + }); +} diff --git a/programs/helium-sub-daos/Cargo.toml b/programs/helium-sub-daos/Cargo.toml index 7fec0cba5..e50692cae 100644 --- a/programs/helium-sub-daos/Cargo.toml +++ b/programs/helium-sub-daos/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "helium-sub-daos" -version = "0.1.10" +version = "0.1.11" description = "Created with Anchor" edition = "2021" diff --git a/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs b/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs index 93f9c054e..827af90fa 100644 --- a/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs +++ b/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs @@ -6,7 +6,9 @@ use circuit_breaker::{ }; use shared_utils::precise_number::{InnerUint, PreciseNumber}; -use crate::{current_epoch, error::ErrorCode, state::*, OrArithError, EPOCH_LENGTH, TESTING}; +use crate::{ + current_epoch, dao_seeds, error::ErrorCode, state::*, OrArithError, EPOCH_LENGTH, TESTING, +}; #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] pub struct IssueRewardsArgsV0 { @@ -153,7 +155,7 @@ pub fn handler(ctx: Context, args: IssueRewardsArgsV0) -> Result .unwrap(); let total_rewards = PreciseNumber::new(emissions.into()).or_arith_error()?; let rewards_prec = percent_share.checked_mul(&total_rewards).or_arith_error()?; - let rewards_amount: u64 = rewards_prec + let mut rewards_amount: u64 = rewards_prec .floor() // Ensure we never overspend the defined rewards .or_arith_error()? .to_imprecise() @@ -220,13 +222,20 @@ pub fn handler(ctx: Context, args: IssueRewardsArgsV0) -> Result )?; } + // Until August 1st, 2025, emit the 2.9M HNT to the treasury. + // This contract will be deployed between December 3 and December 4 at UTC midnight. + // That means this will emit payment from December 3 to August 1st, 2025 (because epochs are paid in arrears). + // This is a total of 241 days. 2.9M HNT / 241 days = 12033.19502075 HNT per day. + if epoch_curr_ts < 1754006400 { + rewards_amount += 12_033_19502075; + } + msg!("Minting {} to treasury", rewards_amount); mint_v0( - ctx.accounts.mint_treasury_emissions_ctx().with_signer(&[&[ - b"dao", - ctx.accounts.hnt_mint.key().as_ref(), - &[ctx.accounts.dao.bump_seed], - ]]), + ctx + .accounts + .mint_treasury_emissions_ctx() + .with_signer(&[dao_seeds!(ctx.accounts.dao)]), MintArgsV0 { amount: rewards_amount, }, diff --git a/programs/helium-sub-daos/src/instructions/mod.rs b/programs/helium-sub-daos/src/instructions/mod.rs index eef24b5a5..3d6155c85 100644 --- a/programs/helium-sub-daos/src/instructions/mod.rs +++ b/programs/helium-sub-daos/src/instructions/mod.rs @@ -7,6 +7,7 @@ pub mod initialize_sub_dao_v0; pub mod issue_hst_pool_v0; pub mod issue_rewards_v0; pub mod issue_voting_rewards_v0; +pub mod switch_mobile_ops_fund; pub mod temp_update_sub_dao_epoch_info; pub mod track_dc_burn_v0; pub mod track_dc_onboarding_fees_v0; @@ -23,6 +24,7 @@ pub use initialize_sub_dao_v0::*; pub use issue_hst_pool_v0::*; pub use issue_rewards_v0::*; pub use issue_voting_rewards_v0::*; +pub use switch_mobile_ops_fund::*; pub use temp_update_sub_dao_epoch_info::*; pub use track_dc_burn_v0::*; pub use track_dc_onboarding_fees_v0::*; diff --git a/programs/helium-sub-daos/src/instructions/switch_mobile_ops_fund.rs b/programs/helium-sub-daos/src/instructions/switch_mobile_ops_fund.rs new file mode 100644 index 000000000..d3000bfff --- /dev/null +++ b/programs/helium-sub-daos/src/instructions/switch_mobile_ops_fund.rs @@ -0,0 +1,88 @@ +use std::str::FromStr; + +use anchor_lang::{prelude::*, solana_program::pubkey}; +use anchor_spl::{ + associated_token::AssociatedToken, + token::{burn, Burn, Mint, Token, TokenAccount}, +}; +use circuit_breaker::{ + cpi::{accounts::MintV0, mint_v0}, + CircuitBreaker, MintArgsV0, MintWindowedCircuitBreakerV0, +}; + +use crate::{dao_seeds, DaoV0}; + +#[derive(Accounts)] +pub struct SwitchMobileOpsFund<'info> { + #[account(mut)] + pub payer: Signer<'info>, + pub authority: Signer<'info>, + #[account( + init_if_needed, + payer = payer, + associated_token::mint = mobile_mint, + associated_token::authority = payer + )] + pub ops_fund_mobile: Account<'info, TokenAccount>, + #[account( + mut, + address = Pubkey::from_str("mb1eu7TzEc71KxDpsmsKoucSSuuoGLv1drys1oP2jh6").unwrap() + )] + pub mobile_mint: Account<'info, Mint>, + #[account( + init_if_needed, + payer = payer, + associated_token::mint = hnt_mint, + associated_token::authority = payer + )] + pub ops_fund_hnt: Account<'info, TokenAccount>, + #[account( + has_one = hnt_mint, + has_one = authority + )] + pub dao: Account<'info, DaoV0>, + #[account(mut)] + pub hnt_mint: Account<'info, Mint>, + #[account( + mut, + seeds = ["mint_windowed_breaker".as_bytes(), hnt_mint.key().as_ref()], + seeds::program = circuit_breaker_program.key(), + bump = hnt_circuit_breaker.bump_seed + )] + pub hnt_circuit_breaker: Box>, + pub circuit_breaker_program: Program<'info, CircuitBreaker>, + pub system_program: Program<'info, System>, + pub token_program: Program<'info, Token>, + pub associated_token_program: Program<'info, AssociatedToken>, +} + +pub fn handler(ctx: Context) -> Result<()> { + burn( + CpiContext::new( + ctx.accounts.token_program.to_account_info(), + Burn { + mint: ctx.accounts.mobile_mint.to_account_info(), + from: ctx.accounts.ops_fund_mobile.to_account_info(), + authority: ctx.accounts.authority.to_account_info(), + }, + ), + 18_197_425_725, + )?; + mint_v0( + CpiContext::new_with_signer( + ctx.accounts.circuit_breaker_program.to_account_info(), + MintV0 { + mint: ctx.accounts.hnt_mint.to_account_info(), + to: ctx.accounts.ops_fund_hnt.to_account_info(), + circuit_breaker: ctx.accounts.hnt_circuit_breaker.to_account_info(), + token_program: ctx.accounts.token_program.to_account_info(), + mint_authority: ctx.accounts.dao.to_account_info(), + }, + &[dao_seeds!(ctx.accounts.dao)], + ), + MintArgsV0 { + amount: 1_300_000_00000000, + }, + )?; + Ok(()) +} diff --git a/programs/helium-sub-daos/src/lib.rs b/programs/helium-sub-daos/src/lib.rs index 010400c95..8595675be 100644 --- a/programs/helium-sub-daos/src/lib.rs +++ b/programs/helium-sub-daos/src/lib.rs @@ -134,4 +134,8 @@ pub mod helium_sub_daos { ) -> Result<()> { issue_voting_rewards_v0::handler(ctx, args) } + + pub fn switch_mobile_ops_fund(ctx: Context) -> Result<()> { + switch_mobile_ops_fund::handler(ctx) + } } diff --git a/programs/helium-sub-daos/src/state.rs b/programs/helium-sub-daos/src/state.rs index 633294701..c53f1a83e 100644 --- a/programs/helium-sub-daos/src/state.rs +++ b/programs/helium-sub-daos/src/state.rs @@ -102,6 +102,13 @@ pub struct DaoV0 { pub bump_seed: u8, } +#[macro_export] +macro_rules! dao_seeds { + ( $s:expr ) => { + &[b"dao".as_ref(), $s.hnt_mint.as_ref(), &[$s.bump_seed]] + }; +} + #[account] #[derive(Default)] pub struct DaoEpochInfoV0 { From bc1efe918c52545fbbb866f1a3c71a88e5faa56c Mon Sep 17 00:00:00 2001 From: Noah Prince Date: Mon, 2 Dec 2024 13:20:21 -0800 Subject: [PATCH 2/8] Add check for MOBILE mint --- .../helium-sub-daos/src/instructions/issue_rewards_v0.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs b/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs index 827af90fa..d18e77372 100644 --- a/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs +++ b/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs @@ -1,3 +1,5 @@ +use std::str::FromStr; + use anchor_lang::prelude::*; use anchor_spl::token::{Mint, Token, TokenAccount}; use circuit_breaker::{ @@ -226,7 +228,10 @@ pub fn handler(ctx: Context, args: IssueRewardsArgsV0) -> Result // This contract will be deployed between December 3 and December 4 at UTC midnight. // That means this will emit payment from December 3 to August 1st, 2025 (because epochs are paid in arrears). // This is a total of 241 days. 2.9M HNT / 241 days = 12033.19502075 HNT per day. - if epoch_curr_ts < 1754006400 { + if epoch_curr_ts < 1754006400 + && ctx.accounts.dnt_mint.key() + == Pubkey::from_str("mb1eu7TzEc71KxDpsmsKoucSSuuoGLv1drys1oP2jh6").unwrap() + { rewards_amount += 12_033_19502075; } From 4bf70de72cb5cf17b5e83bb045e9b80ddc104892 Mon Sep 17 00:00:00 2001 From: Noah Prince Date: Mon, 2 Dec 2024 13:25:31 -0800 Subject: [PATCH 3/8] Fix script --- packages/helium-admin-cli/src/switch-mobile-ops-fund.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/helium-admin-cli/src/switch-mobile-ops-fund.ts b/packages/helium-admin-cli/src/switch-mobile-ops-fund.ts index 55e03182e..39e5f325c 100644 --- a/packages/helium-admin-cli/src/switch-mobile-ops-fund.ts +++ b/packages/helium-admin-cli/src/switch-mobile-ops-fund.ts @@ -60,7 +60,7 @@ export async function run(args: any = process.argv) { HNT_MINT ), opsFundMobile: getAssociatedTokenAddressSync( - wallet.publicKey, + daoAuth, MOBILE_MINT ), dao, From 39b3f67a872cd3c7a20c28349ba6b0c7d75aee42 Mon Sep 17 00:00:00 2001 From: Noah Prince Date: Mon, 2 Dec 2024 14:28:24 -0800 Subject: [PATCH 4/8] Fix tests --- .../src/instructions/issue_rewards_v0.rs | 1 + .../src/instructions/switch_mobile_ops_fund.rs | 3 ++- tests/helium-sub-daos.ts | 17 +++++++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs b/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs index d18e77372..92c25c29f 100644 --- a/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs +++ b/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs @@ -228,6 +228,7 @@ pub fn handler(ctx: Context, args: IssueRewardsArgsV0) -> Result // This contract will be deployed between December 3 and December 4 at UTC midnight. // That means this will emit payment from December 3 to August 1st, 2025 (because epochs are paid in arrears). // This is a total of 241 days. 2.9M HNT / 241 days = 12033.19502075 HNT per day. + #[allow(clippy::inconsistent_digit_grouping)] if epoch_curr_ts < 1754006400 && ctx.accounts.dnt_mint.key() == Pubkey::from_str("mb1eu7TzEc71KxDpsmsKoucSSuuoGLv1drys1oP2jh6").unwrap() diff --git a/programs/helium-sub-daos/src/instructions/switch_mobile_ops_fund.rs b/programs/helium-sub-daos/src/instructions/switch_mobile_ops_fund.rs index d3000bfff..ba2fc4ba4 100644 --- a/programs/helium-sub-daos/src/instructions/switch_mobile_ops_fund.rs +++ b/programs/helium-sub-daos/src/instructions/switch_mobile_ops_fund.rs @@ -56,6 +56,7 @@ pub struct SwitchMobileOpsFund<'info> { pub associated_token_program: Program<'info, AssociatedToken>, } +#[allow(clippy::inconsistent_digit_grouping)] pub fn handler(ctx: Context) -> Result<()> { burn( CpiContext::new( @@ -66,7 +67,7 @@ pub fn handler(ctx: Context) -> Result<()> { authority: ctx.accounts.authority.to_account_info(), }, ), - 18_197_425_725, + 18_197_425_725_000000, )?; mint_v0( CpiContext::new_with_signer( diff --git a/tests/helium-sub-daos.ts b/tests/helium-sub-daos.ts index 3ef836125..2793639a8 100644 --- a/tests/helium-sub-daos.ts +++ b/tests/helium-sub-daos.ts @@ -265,7 +265,20 @@ describe("helium-sub-daos", () => { pubkeys: { vetokenTracker: tracker }, } = await rewardsProgram.methods .initializeVetokenTrackerV0({ - votingRewardsTiers: [], + votingRewardsTiers: [ + { + numVetokens: new anchor.BN(0), + percent: delegatorRewardsPercent(0), + }, + { + numVetokens: new anchor.BN(10), + percent: delegatorRewardsPercent(50), + }, + { + numVetokens: new anchor.BN(1000000000000000), + percent: delegatorRewardsPercent(100), + }, + ], }) .accounts({ registrar: subDaoRegistrar, @@ -960,7 +973,7 @@ describe("helium-sub-daos", () => { ); expect( vsrEpochInfoAcc.rewardsAmount.toString() - ).to.eq((0.02 * SUB_DAO_EPOCH_REWARDS).toString()); + ).to.eq("0"); const acc = await program.account.subDaoEpochInfoV0.fetch( subDaoEpochInfo From 03857d0431f474699af9a157f645cfe518e4f7d6 Mon Sep 17 00:00:00 2001 From: Noah Prince Date: Mon, 2 Dec 2024 14:33:12 -0800 Subject: [PATCH 5/8] Lint --- .../helium-sub-daos/src/instructions/switch_mobile_ops_fund.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/helium-sub-daos/src/instructions/switch_mobile_ops_fund.rs b/programs/helium-sub-daos/src/instructions/switch_mobile_ops_fund.rs index ba2fc4ba4..76084e9f0 100644 --- a/programs/helium-sub-daos/src/instructions/switch_mobile_ops_fund.rs +++ b/programs/helium-sub-daos/src/instructions/switch_mobile_ops_fund.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use anchor_lang::{prelude::*, solana_program::pubkey}; +use anchor_lang::prelude::*; use anchor_spl::{ associated_token::AssociatedToken, token::{burn, Burn, Mint, Token, TokenAccount}, From 8ebe45e3b8f8824db8f5da8ff3473f6ed8e969c8 Mon Sep 17 00:00:00 2001 From: Noah Prince Date: Thu, 5 Dec 2024 10:37:37 -0800 Subject: [PATCH 6/8] Update math --- .../helium-sub-daos/src/instructions/issue_rewards_v0.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs b/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs index 92c25c29f..b35019cfb 100644 --- a/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs +++ b/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs @@ -225,15 +225,15 @@ pub fn handler(ctx: Context, args: IssueRewardsArgsV0) -> Result } // Until August 1st, 2025, emit the 2.9M HNT to the treasury. - // This contract will be deployed between December 3 and December 4 at UTC midnight. - // That means this will emit payment from December 3 to August 1st, 2025 (because epochs are paid in arrears). - // This is a total of 241 days. 2.9M HNT / 241 days = 12033.19502075 HNT per day. + // This contract will be deployed between December 6 and December 7 at UTC midnight. + // That means this will emit payment from December 7 to August 1st, 2025 (because epochs are paid in arrears). + // This is a total of 237 days. 2.9M HNT / 237 days = 12236.28691980 HNT per day. #[allow(clippy::inconsistent_digit_grouping)] if epoch_curr_ts < 1754006400 && ctx.accounts.dnt_mint.key() == Pubkey::from_str("mb1eu7TzEc71KxDpsmsKoucSSuuoGLv1drys1oP2jh6").unwrap() { - rewards_amount += 12_033_19502075; + rewards_amount += 12_236_28691980; } msg!("Minting {} to treasury", rewards_amount); From 554da441df300c8a474218dc0877bb8ef07b4c16 Mon Sep 17 00:00:00 2001 From: Noah Prince Date: Thu, 5 Dec 2024 11:44:05 -0800 Subject: [PATCH 7/8] Fix emissions amount. --- programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs b/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs index b35019cfb..299d21c2f 100644 --- a/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs +++ b/programs/helium-sub-daos/src/instructions/issue_rewards_v0.rs @@ -227,13 +227,13 @@ pub fn handler(ctx: Context, args: IssueRewardsArgsV0) -> Result // Until August 1st, 2025, emit the 2.9M HNT to the treasury. // This contract will be deployed between December 6 and December 7 at UTC midnight. // That means this will emit payment from December 7 to August 1st, 2025 (because epochs are paid in arrears). - // This is a total of 237 days. 2.9M HNT / 237 days = 12236.28691980 HNT per day. + // This is a total of 237 days. 2.9M HNT / 237 days = 12236.28691983 HNT per day. #[allow(clippy::inconsistent_digit_grouping)] if epoch_curr_ts < 1754006400 && ctx.accounts.dnt_mint.key() == Pubkey::from_str("mb1eu7TzEc71KxDpsmsKoucSSuuoGLv1drys1oP2jh6").unwrap() { - rewards_amount += 12_236_28691980; + rewards_amount += 12_236_28691983; } msg!("Minting {} to treasury", rewards_amount); From 8684b75e2d3fb433aed1a28f598b414aa6abcc69 Mon Sep 17 00:00:00 2001 From: Luis Perrone Date: Thu, 5 Dec 2024 15:42:11 -0500 Subject: [PATCH 8/8] Filter out sub nfts from migration service (#746) * Filter out sub nfts from migration service * Fix rust lint --- packages/migration-service/src/ledger.ts | 13 +++++++++---- utils/shared-utils/src/precise_number.rs | 7 +++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/migration-service/src/ledger.ts b/packages/migration-service/src/ledger.ts index 21661e2d5..89de426f3 100644 --- a/packages/migration-service/src/ledger.ts +++ b/packages/migration-service/src/ledger.ts @@ -44,7 +44,10 @@ export async function getMigrateTransactions( ): Promise { const assetApiUrl = process.env.ASSET_API_URL || provider.connection.rpcEndpoint; - const assets = await getAssetsByOwner(assetApiUrl, from.toBase58()); + // Filter out all subscriber NFTs + const assets = (await getAssetsByOwner(assetApiUrl, from.toBase58())).filter( + (asset) => asset?.content?.metadata?.symbol !== "SUBSCRIBER" + ); const uniqueAssets = new Set(assets.map((asset) => asset.id.toBase58())); const vsrProgram = await initVsr(provider); @@ -72,8 +75,10 @@ export async function getMigrateTransactions( proofPath.length - (canopyHeight || 0) ); if (anchorRemainingAccounts.length > 10) { - console.log(`Asset ${asset.id} skipped due to having insufficient canopy`) - continue + console.log( + `Asset ${asset.id} skipped due to having insufficient canopy` + ); + continue; } const ixn = createTransferInstruction( @@ -229,7 +234,7 @@ export async function getMigrateTransactions( return provider.wallet.signTransaction(tx); } - return tx + return tx; }) ); } diff --git a/utils/shared-utils/src/precise_number.rs b/utils/shared-utils/src/precise_number.rs index 1f3c51e0f..ee7e6eb23 100644 --- a/utils/shared-utils/src/precise_number.rs +++ b/utils/shared-utils/src/precise_number.rs @@ -72,7 +72,6 @@ pub const fn ln2hi() -> InnerUint { } pub const LN2HI: PreciseNumber = PreciseNumber { value: ln2hi() }; #[inline] - pub const fn ln2hi_scale() -> InnerUint { U192([7766279631452241920_u64, 5_u64, 0_u64]) } @@ -330,7 +329,7 @@ impl PreciseNumber { Some((frac, -bits)) } } else { - let bits = 128_i64.checked_sub(i64::from(self.to_imprecise()?.leading_zeros()))?; + let bits = (128_i64).checked_sub(i64::from(self.to_imprecise()?.leading_zeros()))?; let frac = PreciseNumber { value: self.value >> bits, }; @@ -443,7 +442,7 @@ impl PreciseNumber { let f = f1.signed().checked_sub(&PreciseNumber::one().signed())?; - let s_divisor = PreciseNumber { value: two() }.signed().checked_add(&f)?; + let s_divisor = (PreciseNumber { value: two() }).signed().checked_add(&f)?; let s = &f.checked_div(&s_divisor)?; let s2 = s.checked_mul(s)?.value; let s4 = s2.checked_mul(&s2)?; @@ -459,7 +458,7 @@ impl PreciseNumber { let r = t1.checked_add(&t2)?; let hfsq = f .checked_mul(&f)? - .checked_div(&PreciseNumber { value: two() }.signed())?; + .checked_div(&(PreciseNumber { value: two() }).signed())?; let k = SignedPreciseNumber { value: PreciseNumber::new(u128::try_from(ki.abs()).ok()?)?, is_negative: ki < 0,