Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#526): Remove digit shift from VSR #527

Merged
merged 5 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions packages/helium-admin-cli/src/create-dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ export async function run(args: any = process.argv) {
await heliumVsrProgram.methods
.configureVotingMintV0({
idx: 0, // idx
digitShift: 0, // digit shift
baselineVoteWeightScaledFactor: new anchor.BN(BASELINE * 1e9),
maxExtraLockupVoteWeightScaledFactor: new anchor.BN(SCALE * 1e9),
genesisVotePowerMultiplier: GENESIS_MULTIPLIER,
Expand All @@ -351,16 +350,6 @@ export async function run(args: any = process.argv) {
await sendInstructions(provider, instructions, []);
instructions = [];

console.log('Creating max voter record');
instructions.push(
await heliumVsrProgram.methods
.updateMaxVoterWeightV0()
.accounts({
registrar,
realmGoverningTokenMint: hntKeypair.publicKey,
})
.instruction()
);
console.log(registrar.toString());
await sendInstructions(provider, instructions, []);
instructions = [];
Expand Down
12 changes: 0 additions & 12 deletions packages/helium-admin-cli/src/create-subdao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ export async function run(args: any = process.argv) {
await heliumVsrProgram.methods
.configureVotingMintV0({
idx: 0, // idx
digitShift: -1, // digit shift
baselineVoteWeightScaledFactor: new anchor.BN(BASELINE * 1e9),
maxExtraLockupVoteWeightScaledFactor: new anchor.BN(SCALE * 1e9),
genesisVotePowerMultiplier: 0,
Expand All @@ -370,17 +369,6 @@ export async function run(args: any = process.argv) {

await sendInstructions(provider, instructions, []);
instructions = [];

console.log('Creating max voter record');
instructions.push(
await heliumVsrProgram.methods
.updateMaxVoterWeightV0()
.accounts({
registrar,
realmGoverningTokenMint: subdaoKeypair.publicKey,
})
.instruction()
);
}

await sendInstructions(provider, instructions, []);
Expand Down
124 changes: 0 additions & 124 deletions packages/helium-admin-cli/src/reset-vsr-max-voter-record.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/helium-admin-cli/src/reset-vsr-voting-mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export async function run(args: any = process.argv) {
await hvsrProgram.methods
.configureVotingMintV0({
idx: 0,
digitShift: 0,
baselineVoteWeightScaledFactor: new anchor.BN(0 * 1e9),
maxExtraLockupVoteWeightScaledFactor: new anchor.BN(100 * 1e9),
lockupSaturationSecs: new anchor.BN(MAX_LOCKUP),
Expand Down Expand Up @@ -132,7 +131,6 @@ export async function run(args: any = process.argv) {
await hvsrProgram.methods
.configureVotingMintV0({
idx: 0,
digitShift: -1,
baselineVoteWeightScaledFactor: new anchor.BN(0 * 1e9),
maxExtraLockupVoteWeightScaledFactor: new anchor.BN(100 * 1e9),
lockupSaturationSecs: new anchor.BN(MAX_LOCKUP),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub fn handler(ctx: Context<ClaimRewardsV0>, args: ClaimRewardsArgsV0) -> Result
// calculate the position's share of that epoch's rewards
// rewards = staking_rewards_issued * staked_vehnt_at_epoch / total_vehnt
let rewards = u64::try_from(
(delegated_vehnt_at_epoch as u128)
delegated_vehnt_at_epoch
.checked_mul(ctx.accounts.sub_dao_epoch_info.delegation_rewards_issued as u128)
.unwrap()
.checked_div(ctx.accounts.sub_dao_epoch_info.vehnt_at_epoch_start as u128)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,11 @@ pub fn handler(ctx: Context<CloseDelegationV0>) -> Result<()> {
}
// If the position was staked before this epoch, remove it.
if current_epoch(delegated_position.start_ts) < curr_epoch {
let vehnt_at_start = position.voting_power(
let vehnt_at_start = u64::try_from(position.voting_power(
voting_mint_config,
ctx.accounts.sub_dao_epoch_info.start_ts(),
)?;
)?)
.unwrap();
msg!(
"Removing {} vehnt from this epoch for this subdao, which currently has {} vehnt",
vehnt_at_start,
Expand Down
16 changes: 8 additions & 8 deletions programs/helium-sub-daos/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ pub trait PrecisePosition {
fn voting_power_precise_locked_precise(
&self,
curr_ts: i64,
max_locked_vote_weight: u64,
max_locked_vote_weight: u128,
lockup_saturation_secs: u64,
) -> Result<u128>;

fn voting_power_precise_cliff_precise(
&self,
curr_ts: i64,
max_locked_vote_weight: u64,
max_locked_vote_weight: u128,
lockup_saturation_secs: u64,
) -> Result<u128>;
}
Expand All @@ -184,9 +184,9 @@ impl PrecisePosition for PositionV0 {
curr_ts: i64,
) -> Result<u128> {
let baseline_vote_weight = (voting_mint_config
.baseline_vote_weight(self.amount_deposited_native)? as u128)
.checked_mul(FALL_RATE_FACTOR)
.unwrap();
.baseline_vote_weight(self.amount_deposited_native)?)
.checked_mul(FALL_RATE_FACTOR)
.unwrap();
let max_locked_vote_weight =
voting_mint_config.max_extra_lockup_vote_weight(self.amount_deposited_native)?;
let genesis_multiplier =
Expand All @@ -213,7 +213,7 @@ impl PrecisePosition for PositionV0 {
fn voting_power_precise_locked_precise(
&self,
curr_ts: i64,
max_locked_vote_weight: u64,
max_locked_vote_weight: u128,
lockup_saturation_secs: u64,
) -> Result<u128> {
if self.lockup.expired(curr_ts) || (max_locked_vote_weight == 0) {
Expand All @@ -238,12 +238,12 @@ impl PrecisePosition for PositionV0 {
fn voting_power_precise_cliff_precise(
&self,
curr_ts: i64,
max_locked_vote_weight: u64,
max_locked_vote_weight: u128,
lockup_saturation_secs: u64,
) -> Result<u128> {
let remaining = min(self.lockup.seconds_left(curr_ts), lockup_saturation_secs);
Ok(
(max_locked_vote_weight as u128)
(max_locked_vote_weight)
.checked_mul(remaining as u128)
.unwrap()
.checked_mul(FALL_RATE_FACTOR)
Expand Down
2 changes: 1 addition & 1 deletion programs/voter-stake-registry/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "voter-stake-registry"
version = "0.2.5"
version = "0.3.0"
description = "Heliums voter weight plugin for spl-governance"
license = "GPL-3.0-or-later"
homepage = "https://github.com/helium/helium-program-library"
Expand Down
Loading
Loading