Theseus Documentation
Theseus Protocol Overview
Theseus also has a dynamic yield-generating protocol that implements an innovative staking mechanism inspired by natural growth patterns. The protocol manages a reward pool of 100 million $THS tokens (10% of total supply) to provide sustainable, predictable returns to stakers while maintaining long-term economic stability.
Dynamic Rates
Adaptive yield based on pool utilization
Sustainable Model
Self-adjusting rewards ensure longevity
Transparent Metrics
Real-time pool health monitoring
Theseus Protocol Architecture
System components
User wallet
Holds $THS tokens
Staking Contract
Manages deposits & withdraws
Reward Pool
100M $THS initial reward pool (Decreases as rewards are distributed)
Flow Description
-
Users stake $THS tokens into the protocol
-
Staking contract tracks deposits and calculates rewards
-
Rewards are distributed from the pool every 6 hours
-
Pool multiplier adjusts based on remaining rewards
Mathematical Foundation
Core Formulas
Base Rate Formula
Effective_Rate = Base_Rate × Pool_Multiplier
where:
Base_Rate = 0.025 (2.50% per 6 hours)
Pool_Multiplier = Current_Pool / 100,000,000
Example: At 75% pool remaining
= 0.025 × (75M/100M)
= 0.025 × 0.75
= 0.01875 (1.875% per period)
Compound Interest Formula
A = P(1 + r)^t
where:
A = Final Amount
P = Principal (Staked Amount)
r = Effective_Rate
t = Number of 6-hour periods
Example: 100,000 $THS Tokens for 24 hours
= 100,000(1 + 0.01875)^4
= 100,000 × 1.0772
= 107,720 $THS
Theseus Pool Dynamics
Pool Depletion Analysis
Pool Levels & Multipliers
Pool Level 100%
Pool Size 100,000,000 $THS
Multiplier 100.0%
Effective Rate 2.500% / 6h
Pool Level 75%
Pool Size 75,000,000 $THS
Multiplier 75.0%
Effective Rate 1.875% / 6h
Impact on Returns
Example stake: 100,000 $THS
At 100% pool: +10,381 $THS/day
At 75% pool : +7,713 $THS/day
At 50% pool: +5,094 $THS/day
At 25% pool: +2,523 $THS/day
At 10% pool: +1,003 $THS/day
Pool Level 50%
Pool Size 50,000,000 $THS
Multiplier 50.0%
Effective Rate 1.250% / 6h
Pool Level 25%
Pool Size 25,000,000 $THS
Multiplier 25.0%
Effective Rate 0.625% / 6h
Pool Level 10%
Pool Size 10,000,000 $THS
Multiplier 10.0%
Effective Rate 0.250% / 6h
Technical Implementation
Implementation Details
Solana Program
// Rust program example
#[program]
pub mod ths_vault {
use super: :*;
pub fn withdraw_ths(ctx: Context<Withdraw>, index: usize, reward_only: bool) -> Result<()> {
// Safely access 'total_deposits' array and validate index
let total_deposits = &ctx.accounts.user_interactions_counter.total_deposits;
let amount = total_deposits.get(index).ok_or(ErrorCode::InvalidIndex)?;
// Safely access 'stake_deposits' array
let stake_deposits = &ctx.accounts.user_interactions_counter.stake_deposits;
let stake_time = stake_deposits.get(index).ok_or(ErrorCode::InvalidIndex)?;
let clock = Clock::get()?;
let unix_timestamp: u64 = clock
.unix_timestamp
.try_into()
.map_err(|_| ErrorCode::Overflow)?;
let time_elapsed = unix_timestamp
.checked_sub(*stake_time)
.ok_or(ErrorCode::Overflow)?
.checked_mul(MILLISECONDS_IN_SECOND)
.ok_or(ErrorCode::Overflow)?;
// Safely update user interaction counters
let counters = &mut ctx.accounts.user_interactions_counter;
if !reward_only {
if let Some(total) = counters.total_deposits.get_mut(index) {
*total = 0;
} else {
return Err(ErrorCode::InvalidIndex.into());
}
if let Some(time) = counters.time_deposits.get_mut(index) {
*time = 0;
} else {
return Err(ErrorCode::InvalidIndex.into());
}
if let Some(stake) = counters.stake_deposits.get_mut(index) {
*stake = 0;
} else {
return Err(ErrorCode::InvalidIndex.into());
}
} else {
if let Some(stake) = counters.stake_deposits.get_mut(index) {
*stake = unix_timestamp;
} else {
return Err(ErrorCode::InvalidIndex.into());
}
}
// Reduce current stakers if applicable
if let Some(first_deposit) = total_deposits.get(0) {
if *first_deposit == 0 && iter_all_eq(total_deposits).is_some() {
ctx.accounts.vault.current_stakers = ctx
.accounts
.vault
.current_stakers
.checked_sub(1)
.ok_or(ErrorCode::Overflow)?;
}
}
// Initialize withdrawal amount
let mut withdraw_amount = *amount;
// Check if sufficient time has elapsed to calculate rewards
let hours_elapsed: u64 = time_elapsed
.checked_div(MILLISECONDS_IN_SECOND)
.and_then(|ms| ms.checked_div(SECONDS_IN_MINUTE))
.and_then(|min| min.checked_div(MINUTES_IN_HOUR))
.ok_or(ErrorCode::Overflow)?;
if hours_elapsed >= ctx.accounts.vault.base_hour.try_into().map_err(|_| ErrorCode::Overflow)?
// Safely access 'vault' fields and ensure no division by zero
let start_pool_f64: f64 = ctx.accounts.vault.start_pool
.try_into()
.map_err(|_| ErrorCode::Overflow)?;
if start_pool_f64 == 0.0 {
return Err(ErrorCode::DivisionByZero.into());
}
let amount_f64: f64 = ctx.accounts.vault.amount
.try_into()
.map_err(|_| ErrorCode::Overflow)?;
let pool_percent = amount_f64 / start_pool_f64;
let base_hour_adjuster: u64 = ctx.accounts
.vault
.base_hour
.try_into()
.map_err(|_| ErrorCode::Overflow)?;
// Safely adjust held hours
let held_hours = hours_elapsed.min(MAX_HELD_HOURS);
let remainder = held_hours % base_hour_adjuster;
let multi: u64 = if remainder == 0 {
held_hours.checked_div(base_hour_adjuster).ok_or(ErrorCode::Overflow)?
} else {
(held_hours.checked_sub(remainder).ok_or(ErrorCode::Overflow)?)
.checked_div(base_hour_adjuster)
.ok_or(ErrorCode::Overflow)?
};
let base_rate_f32: f32 = ctx.accounts.vault.base_rate
.try_into()
.map_err(|_| ErrorCode::Overflow)?;
let final_multi: f32 = (multi.try_into().map_err(|_| ErrorCode::Overflow)? * base_rate_f32)
.checked_mul(pool_percent as f32)
.ok_or(ErrorCode::Overflow)?;
// Safely calculate reward tokens as u64
let reward_tokens: u64 = (amount_f64 * (final_multi / divisor))
.floor()
.try_into()
.map_err(|_| ErrorCode::Overflow)?;
ctx.accounts.vault.amount = ctx
.accounts
.vault
.amount
.checked_sub(reward_tokens)
.ok_or(ErrorCode::Overflow)?;
withdraw_amount = if reward_only {
reward_tokens
} else {
withdraw_amount.checked_add(reward_tokens).ok_or(ErrorCode::Overflow)?
};
}
// Safely update vault staked amount if not reward-only
if !reward_only {
ctx.accounts.vault.amount_staked = ctx
.accounts.vault.amount_staked
.checked_sub(*amount)
.ok_or(ErrorCode::Overflow)?;
} else if withdraw_amount == *amount {
withdraw_amount = 0;
}
// Safely transfer tokens from vault to withdrawer
if withdraw_amount > 0 {
let cpi_accounts = Transfer {
from: ctx.accounts.vault_token_account.to_account_info(),
to: ctx.accounts.withdrawer_token_account.to_account_info(),
authority: ctx.accounts.vault_token_account.to_account_info(),
};
let cpi_program = ctx.accounts.token_program.to_account_info();
transfer(CpiContext::new(cpi_program, cpi_accounts), withdraw_amount)?;
}
Ok(())
}
}