Skip to content

Commit

Permalink
More bugfixes for HIP-138 (#758)
Browse files Browse the repository at this point in the history
* Bugfixes for 138

* More bugfixes for HIP-138
  • Loading branch information
ChewingGlass authored Dec 16, 2024
1 parent b5526d6 commit 27076bf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
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

0 comments on commit 27076bf

Please sign in to comment.