-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMilestone-Based Payouts Solana Program.rust
More file actions
71 lines (61 loc) · 2.17 KB
/
Milestone-Based Payouts Solana Program.rust
File metadata and controls
71 lines (61 loc) · 2.17 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
67
68
69
70
71
~~~
Milestone-Based Payouts Solana Program
Program Architecture
1. Account Layout
```rust
// Anchor program structure
use anchor_lang::prelude::*;
use anchor_spl::token::{self, Token, TokenAccount, Transfer};
use solana_program::sysvar::clock::Clock;
// Constants
const PLATFORM_FEE_BASIS_POINTS: u16 = 200; // 2%
const TREASURY_FEE_BASIS_POINTS: u16 = 100; // 1%
const BASIS_POINTS_DIVISOR: u16 = 10000;
// Main configuration account
#[account]
#[derive(Default, InitSpace)]
pub struct PayoutConfig {
pub authority: Pubkey, // Admin/owner who creates payouts
pub treasury: Pubkey, // Treasury wallet
pub platform_owner: Pubkey, // Platform fee recipient
pub mint: Pubkey, // Token mint for payments
pub total_funded: u64, // Total funds deposited
pub total_paid_out: u64, // Total paid out
pub bump: u8, // PDA bump
pub kyc_authority: Pubkey, // KYC service signer
pub is_active: bool,
}
// Individual milestone account
#[account]
#[derive(Default, InitSpace)]
pub struct Milestone {
pub payout_config: Pubkey, // Parent config
pub contributor: Pubkey, // Contributor wallet
pub verifier: Pubkey, // Verifier who signs attestations
pub amount: u64, // Total milestone amount
pub amount_paid: u64, // Amount already paid
pub milestone_number: u8, // Which milestone (1, 2, 3...)
pub total_milestones: u8, // Total milestones in project
pub attestation_count: u32, // Number of attestations (for nonce)
pub is_completed: bool,
pub bump: u8,
}
// KYC attestation account
#[account]
#[derive(Default, InitSpace)]
pub struct KycAttestation {
pub contributor: Pubkey,
pub kyc_authority: Pubkey,
pub level: u8, // KYC level (1=basic, 2=enhanced, etc.)
pub expiry: i64, // Unix timestamp
pub is_valid: bool,
pub bump: u8,
}
// Nonce account for replay protection
#[account]
#[derive(Default, InitSpace)]
pub struct AttestationNonce {
pub milestone: Pubkey,
pub nonce: u32, // Increments with each attestation
pub bump: u8,
}