Non-Token Based Gameplay
What is Non-Token Based Gameplay?
The Non-Token Based Gameplay is the core mechanic that drives Shrimp Farm after the Pre-Market window closes.
Instead of traditional token exchanges, players interact with a bonding curve system using SOL and virtual assets.
The game revolves around three primary actions: buying shrimp, hatching eggs, and selling eggs.
Players accumulate shrimp that produce eggs over time. These eggs can either be hatched for more shrimp (compounding growth) or sold for SOL (taking profits). The entire economy is balanced through mathematical formulas that create sustainable gameplay without requiring traditional tokens.
Core Game Mechanics
Below is a detailed walkthrough of each gameplay action. Feel free to expand the code blocks for the exact Rust implementation.
1 Buying Shrimp (buy_shrimp.rs)
- Players deposit SOL (minimum 0.01 SOL) after the Pre-Market ends.
- The contract calculates eggs purchased using the bonding curve formula.
- Eggs are immediately converted to shrimp at a fixed ratio (86,400 eggs = 1 shrimp).
- 4% goes to developers, 6% to Pre-Market participants, 90% stays in the game balance.
Show the Rust
pub fn buy_shrimp(
ctx: Context<BuyAccounts>,
amount: u64,
) -> Result<()> {
// Minimum buy check
require!(
amount >= MIN_BUY,
CustomErrors::BuyAmountTooLow
);
// Ensure game is active (post-premarket, not over)
let now: u64 = clock::Clock::get().unwrap().unix_timestamp.try_into().unwrap();
require!(
now > game_state.premarket_end,
CustomErrors::PreMarketInProgress
);
// Calculate eggs using bonding curve
let eggs_bought: u128 = calculate_egg_buy(amount as u128, game_balance as u128, game_state.market_eggs);
// Convert eggs to shrimp (86,400 eggs = 1 shrimp)
let shrimp_to_add = eggs_bought.checked_div(EGGS_TO_HATCH_1SHRIMP).unwrap_or_default();
player_state.shrimp = player_state.shrimp.checked_add(shrimp_to_add).unwrap_or(player_state.shrimp);
Ok(())
}
2 Hatching Eggs (hatch_eggs.rs)
- Players can hatch accumulated eggs to get more shrimp (compounding strategy).
- Eggs accumulate automatically over time based on shrimp count (1 shrimp = 1 egg per second).
- NFT holders get 10% bonus eggs, testnet players get 1% bonus.
- Cooldown period prevents spam (configurable, typically 3 hours).
Show the Rust
pub fn hatch_eggs(ctx: Context<SellAndHatchAccounts>) -> Result<()> {
// Ensure cooldown period has passed
require!(
now >= player_state.last_hatch + game_state.cooldown,
CustomErrors::HatchCooldownNotReached
);
// Calculate total eggs available
let mut eggs = get_my_eggs(player_state, game_state);
// Apply bonuses (NFT: 10%, Testnet: 1%)
let mut bonus_percent: u128 = 0;
if is_nft_holder(&ctx.accounts.nft_asset, ctx.accounts.player.key(), game_state.collection_key)? {
bonus_percent += NFT_BONUS; // 10%
}
if player_state.testnet_player {
bonus_percent += TESTNET_BONUS; // 1%
}
if bonus_percent > 0 {
eggs = eggs.checked_mul(100 + bonus_percent).unwrap().checked_div(100).unwrap();
}
// Convert eggs to shrimp
let shrimp_to_add = eggs.checked_div(EGGS_TO_HATCH_1SHRIMP).unwrap_or_default();
player_state.shrimp = player_state.shrimp.checked_add(shrimp_to_add).unwrap_or(player_state.shrimp);
Ok(())
}
3 Selling Eggs (sell_eggs.rs)
- Players can sell accumulated eggs for SOL (exit strategy).
- Same egg calculation and bonus system as hatching.
- SOL received is calculated using the bonding curve in reverse.
- 4% goes to developers, 6% to Pre-Market participants, 90% goes to the player.
- Selling increases market eggs, making future purchases more expensive.
Show the Rust
pub fn sell_eggs(ctx: Context<SellAndHatchAccounts>) -> Result<()> {
// Calculate eggs with bonuses (same as hatch)
let mut eggs = get_my_eggs(player_state, game_state);
// Apply NFT and testnet bonuses
if bonus_percent > 0 {
eggs = eggs.checked_mul(100 + bonus_percent).unwrap().checked_div(100).unwrap();
}
// Check if this sell triggers game end
let new_market_eggs = game_state.market_eggs.checked_add(eggs).unwrap_or(ENDGAME_LIMIT + 1);
if new_market_eggs > ENDGAME_LIMIT {
game_state.game_over = true;
return Ok(());
}
// Calculate SOL payout using bonding curve
let egg_sell = calculate_egg_sell(eggs, game_state.market_eggs, game_balance as u128) as u64;
// Apply fees (dev: 4%, premarket: 6%, player: 90%)
let final_payout = egg_sell.checked_sub(dev_amount).unwrap().checked_sub(premarket_amount).unwrap();
// Update market eggs (makes future buys more expensive)
game_state.market_eggs = game_state.market_eggs.checked_add(eggs).unwrap();
Ok(())
}
The Bonding Curve Formula
The entire economy is governed by mathematical formulas that create a balanced trading environment.
Core Trading Formula
The foundation of all buy/sell calculations uses this formula:
Show the Rust
pub fn calculate_trade(rt: u128, rs: u128, bs: u128) -> u128 {
let psn_bs = PSN.checked_mul(bs).unwrap(); // PSN * balance_supply
let psnh_rt = PSNH.checked_mul(rt).unwrap(); // PSNH * resource_tokens
let psn_rs = PSN.checked_mul(rs).unwrap(); // PSN * resource_supply
let add_psn_rs_psnh_rt = psn_rs.checked_add(psnh_rt).unwrap();
let div_add_rt = add_psn_rs_psnh_rt.checked_div(rt).unwrap();
let add_psnd_psndh_rt = PSNH.checked_add(div_add_rt).unwrap();
return psn_bs.checked_div(add_psnd_psndh_rt).unwrap();
}
// PSN = 10,000 and PSNH = 5,000 are carefully chosen constants
// that create the desired bonding curve behavior
Buy Calculation
When players buy shrimp with SOL:
Show the Rust
pub fn calculate_egg_buy(amount: u128, contract_balance: u128, market_eggs: u128) -> u128 {
// Get base eggs from bonding curve
let eggs: u128 = calculate_trade(amount, contract_balance, market_eggs);
// Apply 10% total fee (4% dev + 6% premarket)
let fee: u128 = (eggs.checked_mul(FEE.try_into().unwrap()).unwrap()).checked_div(100).unwrap();
return eggs.checked_sub(fee).unwrap();
}
Sell Calculation
When players sell eggs for SOL:
Show the Rust
pub fn calculate_egg_sell(eggs: u128, market_eggs: u128, contract_balance: u128) -> u128 {
// Direct bonding curve calculation (no fee applied here - handled in sell_eggs)
let received: u128 = calculate_trade(eggs, market_eggs, contract_balance);
return received;
}
Egg Production System
Eggs are the core resource that drives the entire game economy.
Automatic Egg Generation
Show the Rust
pub fn get_eggs_since_last_hatch(player_state: &PlayerState, game_state: &GameState) -> u128 {
let now = Clock::get().unwrap().unix_timestamp as u128;
let last_interaction = if player_state.last_interaction == 0 {
game_state.premarket_end // Start counting from premarket end
} else {
player_state.last_interaction
};
let seconds_passed = now - last_interaction as u128;
// Each shrimp produces 1 egg per second
return seconds_passed
.checked_mul(get_my_shrimp(player_state, game_state))
.unwrap();
}
Total Egg Calculation
Show the Rust
pub fn get_my_eggs(player_state: &PlayerState, game_state: &GameState) -> u128 {
// Extra eggs from previous interactions + newly generated eggs
return player_state.extra_eggs + get_eggs_since_last_hatch(player_state, game_state);
}
Shrimp Count (Including Pre-Market)
Show the Rust
pub fn get_my_shrimp(player_state: &PlayerState, game_state: &GameState) -> u128 {
// Calculate Pre-Market shrimp share
let player_share = if game_state.premarket_spent > 0 {
player_state.premarket_spent
.checked_mul(100000).unwrap()
.checked_div(game_state.premarket_spent).unwrap()
} else { 0 };
let premarket_shrimp = if player_share > 0 {
let shrimp_for_premarket_spent = calculate_egg_buy(game_state.premarket_spent as u128, 0, MARKET_START);
shrimp_for_premarket_spent
.checked_mul(player_share as u128).unwrap()
.checked_div(100000).unwrap()
.checked_div(EGGS_TO_HATCH_1SHRIMP).unwrap()
} else { 0 };
// Total shrimp = market-bought shrimp + premarket share
player_state.shrimp.checked_add(premarket_shrimp).unwrap()
}
Game Balance and Endgame
The game is designed to eventually end, creating urgency and excitement.
Game End Condition
The game ends when total market eggs exceed ENDGAME_LIMIT (10^34). This happens naturally as more players sell eggs, inflating the market egg count.
Balance Distribution
When the game ends, remaining SOL is distributed proportionally to Pre-Market participants based on their original deposits.
This non-token system creates engaging gameplay where players must strategically balance between:
- Buying: Increasing their shrimp army
- Hatching: Compounding their egg production
- Selling: Taking profits but inflating the market
The mathematical formulas ensure the game remains balanced and fair for all participants.