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

[HIP-124] Automatically track sliding scale of voting rewards #726

Merged
merged 17 commits into from
Oct 29, 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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.9.10](https://github.com/helium/helium-program-library/compare/v0.9.8...v0.9.10) (2024-10-28)

**Note:** Version bump only for package helium-program-library





## [0.9.9](https://github.com/helium/helium-program-library/compare/v0.9.2...v0.9.9) (2024-10-28)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"packages/*"
],
"useWorkspaces": true,
"version": "0.9.9"
"version": "0.9.10"
}
8 changes: 8 additions & 0 deletions packages/account-fetch-cache-hooks/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.9.10](https://github.com/helium/helium-program-libary/compare/v0.9.8...v0.9.10) (2024-10-28)

**Note:** Version bump only for package @helium/account-fetch-cache-hooks





## [0.9.9](https://github.com/helium/helium-program-libary/compare/v0.9.2...v0.9.9) (2024-10-28)

**Note:** Version bump only for package @helium/account-fetch-cache-hooks
Expand Down
4 changes: 2 additions & 2 deletions packages/account-fetch-cache-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"registry": "https://registry.npmjs.org/"
},
"license": "Apache-2.0",
"version": "0.9.9",
"version": "0.9.10",
"description": "React hooks and context for account-fetch-cache",
"repository": {
"type": "git",
Expand All @@ -31,7 +31,7 @@
"prebuild": "npm run clean && npm run package"
},
"dependencies": {
"@helium/account-fetch-cache": "^0.9.9",
"@helium/account-fetch-cache": "^0.9.10",
"@solana/web3.js": "^1.78.8",
"react-async-hook": "^4.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/account-fetch-cache-hooks/yarn.deploy.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@helium/account-fetch-cache-hooks@workspace:."
dependencies:
"@helium/account-fetch-cache": ^0.9.9
"@helium/account-fetch-cache": ^0.9.10
"@solana/web3.js": ^1.78.8
git-format-staged: ^2.1.3
react-async-hook: ^4.0.0
Expand All @@ -39,7 +39,7 @@ __metadata:
languageName: unknown
linkType: soft

"@helium/account-fetch-cache@^0.9.9":
"@helium/account-fetch-cache@^0.9.10":
version: 0.0.0-use.local
resolution: "@helium/account-fetch-cache@workspace:packages/account-fetch-cache"
dependencies:
Expand Down
8 changes: 8 additions & 0 deletions packages/account-fetch-cache/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.9.10](https://github.com/helium/helium-program-library/compare/v0.9.8...v0.9.10) (2024-10-28)

**Note:** Version bump only for package @helium/account-fetch-cache





## [0.9.9](https://github.com/helium/helium-program-library/compare/v0.9.2...v0.9.9) (2024-10-28)

**Note:** Version bump only for package @helium/account-fetch-cache
Expand Down
2 changes: 1 addition & 1 deletion packages/account-fetch-cache/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helium/account-fetch-cache",
"version": "0.9.9",
"version": "0.9.10",
"description": "Solana account fetch cache to eliminate reduntant fetching, and batch fetches",
"publishConfig": {
"access": "public",
Expand Down
8 changes: 8 additions & 0 deletions packages/account-postgres-sink-service/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.9.10](https://github.com/helium/helium-program-libary/compare/v0.9.8...v0.9.10) (2024-10-28)

**Note:** Version bump only for package @helium/account-postgres-sink-service





## [0.9.9](https://github.com/helium/helium-program-libary/compare/v0.9.2...v0.9.9) (2024-10-28)

**Note:** Version bump only for package @helium/account-postgres-sink-service
Expand Down
4 changes: 2 additions & 2 deletions packages/account-postgres-sink-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"registry": "https://registry.npmjs.org/"
},
"license": "Apache-2.0",
"version": "0.9.9",
"version": "0.9.10",
"description": "Sync account data to postgres",
"repository": {
"type": "git",
Expand Down Expand Up @@ -37,7 +37,7 @@
"@connectrpc/connect-node": "^1.3.0",
"@coral-xyz/anchor": "^0.28.0",
"@fastify/cors": "^8.1.1",
"@helium/account-fetch-cache": "^0.9.9",
"@helium/account-fetch-cache": "^0.9.10",
"@metaplex-foundation/mpl-token-metadata": "^2.10.0",
"@solana/web3.js": "^1.78.8",
"@substreams/core": "^0.15.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/account-postgres-sink-service/yarn.deploy.lock
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ __metadata:
languageName: node
linkType: hard

"@helium/account-fetch-cache@^0.9.9":
"@helium/account-fetch-cache@^0.9.10":
version: 0.0.0-use.local
resolution: "@helium/account-fetch-cache@workspace:packages/account-fetch-cache"
dependencies:
Expand All @@ -199,7 +199,7 @@ __metadata:
"@connectrpc/connect-node": ^1.3.0
"@coral-xyz/anchor": ^0.28.0
"@fastify/cors": ^8.1.1
"@helium/account-fetch-cache": ^0.9.9
"@helium/account-fetch-cache": ^0.9.10
"@metaplex-foundation/mpl-token-metadata": ^2.10.0
"@solana/web3.js": ^1.78.8
"@substreams/core": ^0.15.1
Expand Down
8 changes: 8 additions & 0 deletions packages/active-device-oracle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.9.10](https://github.com/helium/helium-program-libary/compare/v0.9.8...v0.9.10) (2024-10-28)

**Note:** Version bump only for package @helium/active-device-oracle





## [0.9.9](https://github.com/helium/helium-program-libary/compare/v0.9.2...v0.9.9) (2024-10-28)

**Note:** Version bump only for package @helium/active-device-oracle
Expand Down
2 changes: 1 addition & 1 deletion packages/active-device-oracle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"registry": "https://registry.npmjs.org/"
},
"license": "Apache-2.0",
"version": "0.9.9",
"version": "0.9.10",
"description": "Oracle of helium active devices",
"repository": {
"type": "git",
Expand Down
8 changes: 8 additions & 0 deletions packages/anchor-resolvers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.9.10](https://github.com/helium/helium-program-library/compare/v0.9.8...v0.9.10) (2024-10-28)

**Note:** Version bump only for package @helium/anchor-resolvers





## [0.9.9](https://github.com/helium/helium-program-library/compare/v0.9.2...v0.9.9) (2024-10-28)

**Note:** Version bump only for package @helium/anchor-resolvers
Expand Down
2 changes: 1 addition & 1 deletion packages/anchor-resolvers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helium/anchor-resolvers",
"version": "0.9.9",
"version": "0.9.10",
"description": "Wrappers around anchor custom resolvers to make composition easier",
"publishConfig": {
"access": "public",
Expand Down
8 changes: 8 additions & 0 deletions packages/circuit-breaker-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.9.10](https://github.com/helium/helium-program-libary/compare/v0.9.8...v0.9.10) (2024-10-28)

**Note:** Version bump only for package @helium/circuit-breaker-sdk





## [0.9.9](https://github.com/helium/helium-program-libary/compare/v0.9.2...v0.9.9) (2024-10-28)

**Note:** Version bump only for package @helium/circuit-breaker-sdk
Expand Down
6 changes: 3 additions & 3 deletions packages/circuit-breaker-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"registry": "https://registry.npmjs.org/"
},
"license": "Apache-2.0",
"version": "0.9.9",
"version": "0.9.10",
"description": "Interface to the circuit breaker smart contract",
"repository": {
"type": "git",
Expand All @@ -32,8 +32,8 @@
},
"dependencies": {
"@coral-xyz/anchor": "^0.28.0",
"@helium/anchor-resolvers": "^0.9.9",
"@helium/idls": "^0.9.9",
"@helium/anchor-resolvers": "^0.9.10",
"@helium/idls": "^0.9.10",
"bn.js": "^5.2.0",
"bs58": "^4.0.1"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/circuit-breaker-sdk/yarn.deploy.lock
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ __metadata:
languageName: node
linkType: hard

"@helium/anchor-resolvers@^0.9.9":
"@helium/anchor-resolvers@^0.9.10":
version: 0.0.0-use.local
resolution: "@helium/anchor-resolvers@workspace:packages/anchor-resolvers"
dependencies:
Expand All @@ -86,8 +86,8 @@ __metadata:
resolution: "@helium/circuit-breaker-sdk@workspace:."
dependencies:
"@coral-xyz/anchor": ^0.28.0
"@helium/anchor-resolvers": ^0.9.9
"@helium/idls": ^0.9.9
"@helium/anchor-resolvers": ^0.9.10
"@helium/idls": ^0.9.10
bn.js: ^5.2.0
bs58: ^4.0.1
git-format-staged: ^2.1.3
Expand All @@ -97,7 +97,7 @@ __metadata:
languageName: unknown
linkType: soft

"@helium/idls@^0.9.9":
"@helium/idls@^0.9.10":
version: 0.0.0-use.local
resolution: "@helium/idls@workspace:packages/idls"
dependencies:
Expand Down
8 changes: 8 additions & 0 deletions packages/crons/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.9.10](https://github.com/helium/helium-program-library/compare/v0.9.8...v0.9.10) (2024-10-28)

**Note:** Version bump only for package @helium/crons





## [0.9.9](https://github.com/helium/helium-program-library/compare/v0.9.2...v0.9.9) (2024-10-28)

**Note:** Version bump only for package @helium/crons
Expand Down
32 changes: 16 additions & 16 deletions packages/crons/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helium/crons",
"version": "0.9.9",
"version": "0.9.10",
"description": "scripts to run on a schedule",
"private": true,
"publishConfig": {
Expand Down Expand Up @@ -32,25 +32,25 @@
},
"dependencies": {
"@coral-xyz/anchor": "^0.28.0",
"@helium/account-fetch-cache": "^0.9.9",
"@helium/distributor-oracle": "^0.9.9",
"@helium/fanout-sdk": "^0.9.9",
"@helium/helium-entity-manager-sdk": "^0.9.9",
"@helium/helium-sub-daos-sdk": "^0.9.9",
"@helium/idls": "^0.9.9",
"@helium/lazy-distributor-sdk": "^0.9.9",
"@helium/mobile-entity-manager-sdk": "^0.9.9",
"@helium/account-fetch-cache": "^0.9.10",
"@helium/distributor-oracle": "^0.9.10",
"@helium/fanout-sdk": "^0.9.10",
"@helium/helium-entity-manager-sdk": "^0.9.10",
"@helium/helium-sub-daos-sdk": "^0.9.10",
"@helium/idls": "^0.9.10",
"@helium/lazy-distributor-sdk": "^0.9.10",
"@helium/mobile-entity-manager-sdk": "^0.9.10",
"@helium/nft-proxy-sdk": "^0.0.12",
"@helium/no-emit-sdk": "^0.9.9",
"@helium/no-emit-sdk": "^0.9.10",
"@helium/organization-sdk": "^0.0.12",
"@helium/position-voting-rewards-sdk": "^0.9.9",
"@helium/price-oracle-sdk": "^0.9.9",
"@helium/position-voting-rewards-sdk": "^0.9.10",
"@helium/price-oracle-sdk": "^0.9.10",
"@helium/proposal-sdk": "^0.0.12",
"@helium/rewards-oracle-sdk": "^0.9.9",
"@helium/spl-utils": "^0.9.9",
"@helium/rewards-oracle-sdk": "^0.9.10",
"@helium/spl-utils": "^0.9.10",
"@helium/state-controller-sdk": "^0.0.12",
"@helium/treasury-management-sdk": "^0.9.9",
"@helium/voter-stake-registry-sdk": "^0.9.9",
"@helium/treasury-management-sdk": "^0.9.10",
"@helium/voter-stake-registry-sdk": "^0.9.10",
"@solana/spl-token": "^0.3.8",
"@solana/web3.js": "^1.78.8",
"axios": "^1.3.6",
Expand Down
39 changes: 26 additions & 13 deletions packages/crons/src/end-epoch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,20 @@ async function getSolanaUnixTimestamp(connection: Connection): Promise<bigint> {
},
},
]);
const vetokenTrackers = subDaos.map(subDao => subDao.account.vetokenTracker).filter(tracker => !tracker.equals(PublicKey.default));
const vetokenTrackerAccounts = await Promise.all(vetokenTrackers.map(tracker => pvrProgram.account.veTokenTrackerV0.fetch(tracker)));
const targetTsVetokenTrackers = vetokenTrackerAccounts.reduce(
(acc, tracker) => BN.min(acc, tracker.vetokenLastCalculatedTs),
// Start one day back to ensure we at least close the epoch that the job is running in.
new BN(unixNow - 24 * 60 * 60)
);

let targetTs = subDaos.reduce(
let targetTsSubdao = subDaos.reduce(
(acc, subDao) => BN.min(acc, subDao.account.vehntLastCalculatedTs),
// Start one day back to ensure we at least close the epoch that the job is running in.
new BN(unixNow - 24 * 60 * 60)
);
let targetTs = BN.min(targetTsSubdao, targetTsVetokenTrackers);
const solanaTime = await getSolanaUnixTimestamp(provider.connection)

mainLoop: while (targetTs.toNumber() < unixNow) {
Expand Down Expand Up @@ -147,8 +155,9 @@ async function getSolanaUnixTimestamp(connection: Connection): Promise<bigint> {
}
}

if (!daoEpochInfo?.doneIssuingRewards) {
for (const subDao of subDaos) {

for (const subDao of subDaos) {
if (!daoEpochInfo?.doneIssuingRewards) {
const [subDaoEpoch] = subDaoEpochInfoKey(subDao.publicKey, targetTs);
const subDaoEpochInfo =
await heliumSubDaosProgram.account.subDaoEpochInfoV0.fetchNullable(
Expand All @@ -175,15 +184,20 @@ async function getSolanaUnixTimestamp(connection: Connection): Promise<bigint> {
);
}
}
}

const hasVeTokenTracker = !subDao.account.vetokenTracker.equals(PublicKey.default);
if (hasVeTokenTracker) {
const [vsrEpoch] = vsrEpochInfoKey(subDao.account.vetokenTracker, targetTs);
const vsrEpochInfo =
await pvrProgram.account.vsrEpochInfoV0.fetchNullable(
vsrEpoch
);
if (!vsrEpochInfo || !vsrEpochInfo.rewardsIssuedAt) {
const hasVeTokenTracker = !subDao.account.vetokenTracker.equals(
PublicKey.default
);

if (hasVeTokenTracker) {
const [vsrEpoch] = vsrEpochInfoKey(
subDao.account.vetokenTracker,
targetTs
);
const vsrEpochInfo =
await pvrProgram.account.vsrEpochInfoV0.fetchNullable(vsrEpoch);
if (!vsrEpochInfo || !vsrEpochInfo.rewardsIssuedAt) {
try {
await sendInstructionsWithPriorityFee(
provider,
Expand All @@ -203,8 +217,7 @@ async function getSolanaUnixTimestamp(connection: Connection): Promise<bigint> {
} catch (err: any) {
errors.push(
`Failed to issue voting rewards for ${subDao.account.dntMint.toBase58()}: ${err}`
);
}
);
}
}
}
Expand Down
Loading
Loading