Skip to content

Commit

Permalink
Merge pull request #239 from TxnLab/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
drichar authored Jul 2, 2024
2 parents 69e5d20 + 4e38bff commit d130fdb
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 277 deletions.
2 changes: 1 addition & 1 deletion contracts/bootstrap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap",
"version": "0.9.4",
"version": "0.9.5",
"description": "",
"main": "index.ts",
"scripts": {
Expand Down
6 changes: 6 additions & 0 deletions contracts/contracts/stakingPool.algo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,16 @@ export class StakingPool extends Contract {

binRoundStart = GlobalStateKey<uint64>({ key: 'binRoundStart' })

// stakeAccumulator is the stake adjusted for a 'per day' bin. It is used to determine a stake added per day (adjusting for
// stake additions as they occur, but adjusted for time in the day). The stakeAccumulator and rewardAccumulator together
// are used to try to calculate a moving average of stake/rewards and APR.
stakeAccumulator = GlobalStateKey<uint128>({ key: 'stakeAccumulator' })

// rewardAccumulator is similar to stakeAccumulator in how it accrues but tracks the rewards as they're determined each
// epoch.
rewardAccumulator = GlobalStateKey<uint64>({ key: 'rewardAccumulator' })

// moving average - calculated based on approximate APR of rewards
weightedMovingAverage = GlobalStateKey<uint128>({ key: 'ewma' })

// ---
Expand Down
Binary file added contracts/diagrams/retiStorage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 104 additions & 0 deletions contracts/diagrams/retiStorage.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# [5] int:expiration time to add to 'now'
@startjson
{
"Validator Contract": {
"{global state}": {
"numV": "number of Validators",
"numStakers": "number of Unique Stakers",
"staked": "total staked"
},
"boxes": {
"v{Validator ID}": {
"ValidatorInfo": {
"config": {
"ValidatorConfig": {
"id": "validator id",
"owner": "{address}",
"manager": "{address}",
"nfdForInfo": "{nfd app id}",
"entryGatingType": "uint8",
"entryGatingAddress": "{address}",
"entryGatingAssets": "uint64[4]",
"gatingAssetMinBalance": "uint64",
"rewardTokenId": "{asset id}",
"rewardPerPayout": "uint64",
"epochRoundLength": "uint32",
"percentToValidator": "uint32",
"validatorCommissionAddress": "{address}",
"minEntryStake": "uint64",
"maxAlgoPerPool": "uint64",
"poolsPerNode": "uint8",
"sunsettingOn": "uint64 - timestamp",
"sunsettingTo": "uint64 - validator id"
}
},
"state": {
"ValidatorCurState": {
"numPools": "uint16",
"totalStakers": "uint64",
"totalAlgoStaked": "uint64",
"rewardTokenHeldBack": "uint64"
}
},
"pools": {
"PoolInfo[24]": {
"poolAppId": "uint64",
"totalStakers": "uint64",
"totalAlgoStaked": "uint64"
}
},
"tokenPayoutRatio": {
"poolTokenPayoutRatio": {
"pooolPctOfWhole": "uint64[24]",
"updatedForPayout": "uint64"
}
},
"nodePoolAssignments": {
"NodePoolAssignmentConfig": {
"NodeConfig[8]": {
"poolAppIds": "uint64[3]"
}
}
}
}
},
"sps{Staker Address}": {
"ValidatorPoolKey[6]": {
"id": "validator id",
"poolId": "1-x [pool index]",
"poolAppId": "pool application id"
}
}
}
},
"Staking Pool Instance": {
"{global state}": {
"creatingValidatorContractAppId": "reti app id",
"validatorId": "uint64 - owning validator id",
"poolId": "uint64",
"numStakers": "uint64",
"totalAlgoStaked": "uint64",
"minEntryStake": "uint64",
"lastPayout": "uint64",
"epochNumber": "uint64",
"algodVer": "string",
"roundsPerDay": "uint64",
"binRoundStart": "uint64",
"stakeAccumulator": "uint128",
"rewardAccumulator": "uint64",
"weightedMovingAverage": "uint128"
},
"boxes": {
"stakers": {
"StakedInfo[200]": {
"account": "Address",
"balance": "uint64",
"totalRewarded": "uint64",
"rewardTokenBalance": "uint64",
"entryRound": "uint64"
}
}
}
}
}
@endjson
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reti-contracts",
"version": "0.9.4",
"version": "0.9.5",
"license": "MIT",
"scripts": {
"generate-client": "algokit generate client contracts/artifacts/ --language typescript --output contracts/clients/{contract_name}Client.ts && ./update_contract_artifacts.sh``",
Expand Down
Loading

0 comments on commit d130fdb

Please sign in to comment.