Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

tier.gno

0.97 Kb · 40 lines
 1package kourtv3
 2func tierBpsFor(cs *claimState) int64 {
 3	if cs.tierRef <= 0 {
 4		return tierParBps
 5	}
 6	v := mulDiv128(cs.xBarFrozen, tierParBps, cs.tierRef)
 7	if v < tierFloorBps {
 8		return tierFloorBps
 9	}
10	if v > tierCeilBps {
11		return tierCeilBps
12	}
13	return v
14}
15func tierRefAt(c *Court) int64 {
16	ref := c.xBarAcc / tierEMAN
17	if floor := supplyFloor(c, tierRefFloorBps, tierRefDustCC); ref < floor {
18		ref = floor
19	}
20	return ref
21}
22func observeClaimSize(c *Court, xbar int64) {
23	c.xBarAcc = mustAdd(c.xBarAcc, xbar-c.xBarAcc/tierEMAN)
24}
25func ClaimTierBps(courtSlug string, claimID uint64) int64 {
26	return tierBpsFor(mustClaim(mustCourt(courtSlug), claimID))
27}
28func ClaimTierRef(courtSlug string, claimID uint64) int64 {
29	return mustClaim(mustCourt(courtSlug), claimID).tierRef
30}
31func spamNetBps(cs *claimState) int64 {
32	if cs.spamTotalW <= 0 {
33		return tierParBps
34	}
35	net := cs.spamTotalW - mustMul(2, cs.spamW)
36	if net <= 0 {
37		return 0
38	}
39	return mulDiv128(net, tierParBps, cs.spamTotalW)
40}