Smart Contract

BagDistributionRatio

A.c649103ebbc38926.BagDistributionRatio

Valid From

129,521,167

Deployed

1w ago
Feb 20, 2026, 09:25:18 AM UTC

Dependents

1 imports
1import FlowIDTableStaking from 0x8624b52f9ddcd04a
2import FlowStakingCollection from 0x8d0e87b65159ae63
3
4access(all) contract BagDistributionRatio {
5    
6    access(all) var targetAPY: UFix64
7    access(all) var totalWeek: UFix64
8
9    access(all) resource Admin {
10        access(all) fun calculateWeeklyDistribution(nodeID: String, delegatorID: UInt32): UFix64 {
11            let tokenStaked = self.getTokenStaked(nodeID: nodeID, delegatorID: delegatorID)
12            let targetWeekly = (tokenStaked * BagDistributionRatio.targetAPY) / BagDistributionRatio.totalWeek
13            return targetWeekly
14        }
15
16        access(all) fun getTokenStaked(nodeID: String, delegatorID: UInt32): UFix64 {
17            let delInfo = FlowIDTableStaking.DelegatorInfo(nodeID: nodeID, delegatorID: delegatorID)
18            return delInfo.tokensStaked
19        }      
20
21        access(all) fun updateTargetAPY(newAPY:UFix64){
22            BagDistributionRatio.targetAPY = newAPY
23        }
24
25        access(all) fun updateTotalWeek(newTotalWeek: UFix64) {
26            BagDistributionRatio.totalWeek = newTotalWeek
27        }
28    }
29
30    access(all) view fun getTargetAPY(): UFix64 {
31        return self.targetAPY
32    }
33
34    access(all) view fun getTotalWeek(): UFix64 {
35        return self.totalWeek
36    }
37
38    init(targetAPY:UFix64, totalWeek:UFix64) {
39        self.targetAPY = targetAPY
40        self.totalWeek = totalWeek
41
42        let admin <- create Admin()
43        self.account.storage.save(<- admin, to: /storage/BagDistributionRatioAdmin)
44    }
45}