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

More bugfixes for HIP-138 #758

Merged
merged 3 commits into from
Dec 16, 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 packages/helium-admin-cli/src/create-dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ export async function run(args: any = process.argv) {
netEmissionsCap: null,
proposalNamespace: organizationKey("Helium")[0],
delegatorRewardsPercent: delegatorRewardsPercent(argv.delegatorRewardsPercent),
rewardsEscrow,
rewardsEscrow: rewardsEscrow ? rewardsEscrow : null,
})
.accounts({
dao,
Expand Down
3 changes: 1 addition & 2 deletions packages/helium-admin-cli/src/migrate-to-hip-138.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,14 @@ export async function run(args: any = process.argv) {
.instruction()
);

if (!daoAcc.rewardsEscrow || daoAcc.rewardsEscrow.equals(PublicKey.default)) {
if (!daoAcc.delegatorPool || daoAcc.delegatorPool.equals(PublicKey.default)) {
instructions.push(
await hsdProgram.methods
.initializeHntDelegatorPool()
.accounts({
dao,
payer: daoAcc.authority,
delegatorPool: getAssociatedTokenAddressSync(hntMint, dao, true),
rewardsEscrow: getAssociatedTokenAddressSync(hntMint, ld, true),
authority: daoAcc.authority,
})
.instruction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ pub fn handler(

// Apply a 90 day smooth
let utility_score_prec = vehnt_staked
// Add 12 decimals of precision
.checked_mul(&PreciseNumber::new(1000000000000_u128).unwrap()) // First convert vehnt to 12 decimals
.unwrap()
.checked_div(&PreciseNumber::new(90_u128).unwrap())
.unwrap()
.checked_add(
Expand All @@ -165,21 +168,20 @@ pub fn handler(
.prev_sub_dao_epoch_info
.utility_score
.and_then(PreciseNumber::new)
.unwrap_or(vehnt_staked),
.unwrap_or_else(|| {
vehnt_staked
// Add 12 decimals of precision
.checked_mul(&PreciseNumber::new(1000000000000_u128).unwrap())
.unwrap()
}),
)
.unwrap()
.checked_div(&PreciseNumber::new(90_u128).unwrap())
.unwrap(),
)
.unwrap();
// Convert to u128 with 12 decimals of precision
let utility_score = utility_score_prec
.checked_mul(
&PreciseNumber::new(1000000000000_u128).unwrap(), // u128 with 12 decimal places
)
.unwrap()
.to_imprecise()
.unwrap();

let utility_score = utility_score_prec.to_imprecise().unwrap();

// Store utility scores
epoch_info.utility_score = Some(utility_score);
Expand Down
Loading