forked from theblockcade/stellarcade
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_docs.sh
More file actions
executable file
·66 lines (55 loc) · 2.07 KB
/
Copy pathupdate_docs.sh
File metadata and controls
executable file
·66 lines (55 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
CONTRACTS=("payout-checkpoints" "arena-reserves" "badge-claims-v2" "ladder-payouts")
STRUCTS=("PayoutCheckpoints" "ArenaReserves" "BadgeClaimsV2" "LadderPayouts")
for i in "${!CONTRACTS[@]}"; do
C="${CONTRACTS[$i]}"
S="${STRUCTS[$i]}"
cat << LIB > contracts/$C/src/lib.rs
#![no_std]
pub mod types;
pub mod storage;
#[cfg(test)]
mod test;
use soroban_sdk::{contract, contractimpl, Address, Env};
use crate::types::{Config, PendingClaimSnapshot, RolloverPressure};
use crate::storage::{get_config, get_pending_claim, get_rollover_pressure as get_rp};
#[contract]
pub struct $S;
#[contractimpl]
impl $S {
/// Returns a structured snapshot of a user's pending claims.
///
/// # Fallback and Zero-State Behavior
/// If the contract is not initialized or the user has no claims, returns `pending_amount = 0`.
/// `is_paused` defaults to `true` when uninitialized to prevent accidental state progression.
///
/// # Rounding Conventions
/// Amounts are returned in their base integer units (i128) with no implicit decimal rounding.
pub fn get_pending_claim_snapshot(env: Env, user: Address) -> PendingClaimSnapshot {
let is_paused = get_config(&env).map(|c| c.is_paused).unwrap_or(true);
let pending_amount = get_pending_claim(&env, &user);
PendingClaimSnapshot {
user,
pending_amount,
is_paused,
timestamp: env.ledger().timestamp(),
}
}
/// Returns the current rollover pressure for the system.
///
/// # Fallback and Zero-State Behavior
/// If no rollover pressure has been recorded, returns `total_pressure = 0` and `active_users = 0`.
///
/// # Rounding Conventions
/// All pressure calculations are performed and returned in base units without truncation.
pub fn get_rollover_pressure(env: Env) -> RolloverPressure {
let total_pressure = get_rp(&env);
RolloverPressure {
total_pressure,
active_users: 0,
timestamp: env.ledger().timestamp(),
}
}
}
LIB
done