Skip to main content

tengu_api/
consts.rs

1//! PDA seeds and constants.
2
3use solana_program::pubkey::Pubkey;
4use solana_program::pubkey;
5
6pub const ADMIN_ADDRESS: Pubkey = pubkey!("DEvGq2WVuA3qkSCtwwuMYThY4onkJunEHSAxU5cieph8");
7pub const FEE_COLLECTOR: Pubkey = pubkey!("FEEjHM2DoFu6UifSBmrxTQ6X2KkWQ1dbPXASCtdLUdnx");
8pub const TASK_VERIFIER: Pubkey = pubkey!("tASK7746ambmkkTvqtyCehd3F56X4VJpr9GCPh4bUmu");
9/// $DOJO SPL token mint. Matches ui constants.ts DOJO_MINT.
10pub const DOJO_MINT: Pubkey = pubkey!("sHaRDNEyRgkLRSN22RnmMkmYeQtZRDQjKpQmPTyPkbS");
11
12pub const CONFIG: &[u8] = b"config";
13pub const GAME: &[u8] = b"game";
14pub const DOJO: &[u8] = b"dojo";
15pub const SHOGUN: &[u8] = b"shogun";
16pub const BARRACKS: &[u8] = b"barracks";
17pub const FORGE: &[u8] = b"forge";
18pub const TASKS: &[u8] = b"tasks";
19pub const TREASURY: &[u8] = b"treasury";
20pub const REFERRAL: &[u8] = b"referral";
21
22pub const ED25519_SIGNATURE_OFFSETS_START: usize = 2;
23pub const ED25519_SIGNATURE_OFFSETS_SIZE: usize = 14;
24pub const ED25519_DATA_START: usize = ED25519_SIGNATURE_OFFSETS_START + ED25519_SIGNATURE_OFFSETS_SIZE;
25pub const ED25519_PUBKEY_SIZE: usize = 32;
26pub const ED25519_SIGNATURE_SIZE: usize = 64;
27
28/// Solana: ~0.4s per slot. Ore/chakra/cooldowns use Solana slots.
29pub const SECONDS_PER_SLOT: f64 = 0.4;
30/// Slots in 24h (86400 / 0.4 ≈ 216000).
31pub const ONE_DAY_SLOTS: u64 = 216_000;
32pub const CHAKRA_MAX: u64 = ONE_DAY_SLOTS;
33/// Ore = (spirit_power * slots_elapsed) / ORE_DIVISOR. 200 = 0.5x vs Ninja (Solana 2x faster).
34pub const ORE_DIVISOR: u64 = 200;
35/// Pool-split: raw $DOJO emission per slot (6 decimals). Hyper Ninja: 1000/block × 8640 blocks/day = 8.64M/day; Solana 216k slots/day → 40/slot.
36pub const EMISSION_RAW_PER_SLOT_BASE: u64 = 40_000_000;
37/// Default halving period: matches Hyper Ninja's ~58 days (500k blocks × 10s = 5M sec; 5M/0.4 ≈ 12.5M slots).
38pub const HALVING_PERIOD_SLOTS_DEFAULT: u64 = 12_500_000;
39pub const DOJO_DECIMALS: u8 = 6;
40/// One $DOJO token, denominated in raw units (6 decimals).
41pub const ONE_DOJO: u64 = 10u64.pow(DOJO_DECIMALS as u32);
42
43pub const SLOTS_PER_LEVEL: u64 = 3;
44pub const MAX_BARRACKS_SLOTS: usize = 12;
45
46/// Barracks account sizes for MigrateBarracks. Legacy = SlotCache without dine_count (24 bytes/slot).
47pub const BARRACKS_SIZE_LEGACY: usize = 32 + 8 + 96 + 12 * 24; // dojo + level + slots + slot_cache
48/// Legacy with 8-byte Steel discriminator.
49pub const BARRACKS_SIZE_LEGACY_DISCRIM: usize = 8 + BARRACKS_SIZE_LEGACY;
50/// Migrated = SlotCache with dine_count (32 bytes/slot).
51pub const BARRACKS_SIZE_MIGRATED: usize = 32 + 8 + 96 + 12 * 32;
52/// Migrated with 8-byte discriminator.
53pub const BARRACKS_SIZE_MIGRATED_DISCRIM: usize = 8 + BARRACKS_SIZE_MIGRATED;
54/// Offset of slot_cache in Barracks (dojo 32 + level 8 + slots 96).
55pub const BARRACKS_SLOT_CACHE_OFFSET: usize = 32 + 8 + 96;
56/// With 8-byte discriminator.
57pub const BARRACKS_SLOT_CACHE_OFFSET_DISCRIM: usize = 8 + BARRACKS_SLOT_CACHE_OFFSET;
58/// Lamports to transfer to barracks for rent when migrating (+96 bytes). ~0.001 SOL.
59pub const BARRACKS_MIGRATE_RENT_LAMPORTS: u64 = 1_000_000;
60
61pub const STARTER_TICKET_PRICE: u64 = 1_000_000_000;
62pub const RECRUIT_SOL_PRICE: u64 = 100_000_000;
63
64pub const TICKET_BUNDLE_SOL: u64 = 5_000_000_000;
65pub const TICKET_BUNDLE_TICKETS: u64 = 150;
66
67pub const SHARD_DEAL_TICKETS: u64 = 5;
68pub const SHARD_DEAL_COST: u64 = 300_000_000;
69
70pub const FLASH_SALE_TICKETS: u64 = 50;
71pub const FLASH_SALE_COST: u64 = 5_000_000_000;
72pub const FLASH_SALE_DAILY_LIMIT: u64 = 5;
73
74/// Base cost (first dine for this shogun). 150/300/450 shards.
75pub const DINE_COST_24H: u64 = 150_000_000;
76pub const DINE_COST_48H: u64 = 300_000_000;
77pub const DINE_COST_72H: u64 = 450_000_000;
78
79/// Escalated cost (second+ dine for this shogun). 195/390/585 shards.
80pub const DINE_COST_24H_ESCALATED: u64 = 195_000_000;
81pub const DINE_COST_48H_ESCALATED: u64 = 390_000_000;
82pub const DINE_COST_72H_ESCALATED: u64 = 585_000_000;
83
84pub const BARRACKS_COST_1_2_SHARDS: u64 = 50_000_000;
85pub const BARRACKS_COST_1_2_SOL: u64 = 10_000_000;
86pub const BARRACKS_COST_2_3_SHARDS: u64 = 300_000_000;
87pub const BARRACKS_COST_2_3_SOL: u64 = 100_000_000;
88pub const BARRACKS_COST_3_4: u64 = 8_000_000_000;
89
90/// 1→2: 0.1 SOL.
91pub const FORGE_COST_1_2: u64 = 100_000_000;
92/// 2→3: 1 SOL.
93pub const FORGE_COST_2_3: u64 = 1_000_000_000;
94/// 3→4: 2 SOL.
95pub const FORGE_COST_3_4: u64 = 2_000_000_000;
96/// 4→5: 5 SOL.
97pub const FORGE_COST_4_5: u64 = 5_000_000_000;
98/// 5→6: 12 SOL.
99pub const FORGE_COST_5_6: u64 = 12_000_000_000;
100/// 6→7: 21 SOL (max level).
101pub const FORGE_COST_6_7: u64 = 21_000_000_000;
102
103/// 1→2: no cooldown (unused; we use _2_3 for level 2).
104pub const FORGE_COOLDOWN_1_2: u64 = 0;
105/// 2→3: no cooldown after 1→2; 30 min after 2→3 (level 3 uses _3_4).
106pub const FORGE_COOLDOWN_2_3: u64 = 0;
107/// 3→4: 30 min in slots (1800s / 0.4 = 4500). Cooldown after 2→3.
108pub const FORGE_COOLDOWN_3_4: u64 = 4_500;
109/// 4→5: 90 min in slots (5400s / 0.4 = 13500). Cooldown after 3→4.
110pub const FORGE_COOLDOWN_4_5: u64 = 13_500;
111/// 5→6: 180 min in slots (10800s / 0.4 = 27000). Cooldown after 4→5.
112pub const FORGE_COOLDOWN_5_6: u64 = 27_000;
113/// 6→7: 300 min in slots (18000s / 0.4 = 45000). Cooldown after 5→6 (max level).
114pub const FORGE_COOLDOWN_6_7: u64 = 45_000;
115
116/// Same as ONE_DOJO. Speed-up forge: cost per minute = remaining minutes (Ninja decay).
117pub const SHARDS_RAW_PER_UNIT: u64 = ONE_DOJO;
118
119// Leveling: cost = 200 + 800*(level-1). Capped at 100.
120pub const LEVEL_UP_COST_BASE: u64 = 200_000_000;   // 200 shards raw
121pub const LEVEL_UP_COST_INCREMENT: u64 = 800_000_000; // 800 shards raw per level
122pub const MAX_SHOGUN_LEVEL: u64 = 100;
123
124pub const SP_N: u64 = 10;
125pub const SP_R: u64 = 25;
126pub const SP_SR: u64 = 50;
127pub const SP_SSR: u64 = 100;
128pub const SP_UR: u64 = 160;
129
130pub const DROP_N: u64 = 541;
131pub const DROP_R: u64 = 324;
132pub const DROP_SR: u64 = 108;
133pub const DROP_SSR: u64 = 22;
134pub const DROP_UR: u64 = 5;
135
136pub const RECRUITMENT_TICKET_REWARD_1: u64 = 1;
137pub const RECRUITMENT_TICKET_REWARD_2: u64 = 2;
138pub const RECRUITMENT_TICKET_REWARD_3: u64 = 3;
139pub const RECRUITMENT_TICKET_REWARD_4: u64 = 4;
140pub const RECRUITMENT_TICKET_REWARD_5: u64 = 5;
141pub const RECRUITMENT_TICKET_REWARD_6: u64 = 6;
142pub const RECRUITMENT_TICKET_REWARD_7: u64 = 7;
143pub const RECRUITMENT_TICKET_REWARD_8: u64 = 8;
144pub const RECRUITMENT_TICKET_REWARD_9: u64 = 9;
145pub const RECRUITMENT_TICKET_REWARD_10: u64 = 10;
146pub const RECRUITMENT_TICKET_REWARD_11: u64 = 11;
147pub const RECRUITMENT_TICKET_REWARD_12: u64 = 12;
148pub const RECRUITMENT_TICKET_REWARD_13: u64 = 13;
149pub const RECRUITMENT_TICKET_REWARD_15: u64 = 15;
150
151pub const ELEMENT_RARITY_REWARD_N: u64 = 1;
152pub const ELEMENT_RARITY_REWARD_R: u64 = 1;
153pub const ELEMENT_RARITY_REWARD_SR: u64 = 2;
154pub const ELEMENT_RARITY_REWARD_SSR: u64 = 5;
155pub const ELEMENT_RARITY_REWARD_UR: u64 = 20;
156
157pub const OFF_CHAIN_TASK_START: u64 = 9;
158pub const OFF_CHAIN_TASK_END: u64 = 16;
159pub const OFF_CHAIN_TASK_REWARD: u64 = 1;
160
161pub const DAILY_TASK_START: u64 = 17;
162pub const DAILY_TASK_END: u64 = 24;
163
164pub const CLAIM_TASK_PREFIX: &[u8] = b"dojos:claim_task:";
165pub const ELEMENT_RARITY_SET_SIZE: usize = 3;
166
167// Task ID layout:
168// 0–7: On-chain tasks (recruit, dine, forge Lv.2)
169// 8: Collection rewards (3 ninjas same element+rarity; 25 combos)
170// 9–16: Off-chain tasks (signature required)
171// 17–24: Daily resettable tasks (signature, bits reset daily)
172// 33–35: Forge Lv.3, Lv.4, Lv.5
173pub const TASK_FORGE_3: u64 = 33;
174pub const TASK_FORGE_4: u64 = 34;
175pub const TASK_FORGE_5: u64 = 35;
176pub const FORGE_3_REWARD: u64 = 2;
177pub const FORGE_4_REWARD: u64 = 5;
178pub const FORGE_5_REWARD: u64 = 10;
179pub const FORGE_6_REWARD: u64 = 15;
180pub const FORGE_7_REWARD: u64 = 20;
181
182pub const MAX_SUPPLY: u64 = ONE_DOJO * 1_000_000_000;
183
184// Scene collection
185pub const SCENES: &[u8] = b"scenes";
186pub const SCENE_DEFAULT_ID: u64 = 0;
187pub const SCENE_SECTIONS_PER_SCENE: usize = 12;
188pub const SCENE_COUNT_MAX: usize = 9;
189pub const SCENE_COUNT: u64 = 8;
190/// Scenes in roll pool (1–5). Excludes scene 0 (Green Mountain) and buyable scenes 6–8.
191pub const SCENE_ROLL_COUNT: u64 = 5;
192pub const SCENE_ROLL_AMETHYST_COST: u64 = 100;
193pub const SCENE_ROLL_SHARD_COUNT: u64 = 10;
194pub const SCENE_ROLL_SHARD_COST: u64 = 1_000_000_000;
195pub const SCENE_SALVAGE_REFUND: u64 = 10;
196pub const SCENE_CHEST_SOL_COST: u64 = 1_000_000_000;
197pub const SCENE_CHEST_AMETHYST_AMOUNT: u64 = 5000;
198/// Scenes 6–8 can be bought with Amethyst (unlock entire scene).
199pub const SCENE_BUY_START: u64 = 6;
200pub const SCENE_BUY_AMETHYST_COST: u64 = 5000;
201
202// Scene bonuses for claim_shards (ore = (spirit_power * chakra) / divisor; bonuses apply after sum).
203/// Scene 0 (Green Mountain): no bonus.
204/// Scenes 1, 6, 7, 8: flat +50_000 Spirit Power.
205pub const SCENE_BONUS_FLAT_50K: u64 = 50_000;
206/// Scene 2: flat +100_000 Spirit Power.
207pub const SCENE_BONUS_FLAT_100K: u64 = 100_000;
208/// Scene 3: +2% multiplier (basis points).
209pub const SCENE_BONUS_PCT_2: u64 = 200;
210/// Scene 4: +3% multiplier (basis points).
211pub const SCENE_BONUS_PCT_3: u64 = 300;
212/// Scene 5: +5% multiplier (basis points).
213pub const SCENE_BONUS_PCT_5: u64 = 500;