Skip to content

Commit

Permalink
✨ chore: seeds the staking pool meme balance
Browse files Browse the repository at this point in the history
  • Loading branch information
josemvcerqueira committed May 8, 2024
1 parent 0122ce3 commit 8f3737c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions memechan/sources/live_phase/go_live.move
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module memechan::go_live {
struct AddLiquidityHook has drop {}

const SCALE: u256 = 1_000_000_000_000_000_000; // 1e18
const TWENTY_PERCENT: u256 = 200_000_000_000_000_000; // 0.2e18

const A: u256 = 400_000;
const GAMMA: u256 = 145_000_000_000_000;
Expand Down Expand Up @@ -174,6 +175,10 @@ module memechan::go_live {

let price = (amount_sui * SCALE) / amount_meme;

// Calculate the 80% value for the staking pool
let total_amount = amount_meme * SCALE / TWENTY_PERCENT;
let staking_pool_amount = total_amount * (SCALE - TWENTY_PERCENT) / SCALE;

let (amm_pool, admin, lp_tokens) = volatile_hooks::new_2_pool_with_hooks(
clock,
&decimals,
Expand All @@ -189,10 +194,13 @@ module memechan::go_live {
);

let pool_id = object::id(&amm_pool);

let staking_pool_meme_balance = coin::mint_balance(&mut meme_cap, (staking_pool_amount as u64));

// 4. Create staking pool
let staking_pool = staking_pool::new<S, Meme, LP>(
pool_id,
staking_pool_meme_balance,
(seed_pool::gamma_m(&params) as u64),
coin::into_balance(lp_tokens),
vesting_config,
Expand Down
8 changes: 6 additions & 2 deletions memechan/sources/live_phase/staking_pool.move
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module memechan::staking_pool {

public(friend) fun new<S, Meme, LP>(
amm_pool: ID,
balance_meme: Balance<Meme>,
stake_total: u64,
balance_lp: Balance<LP>,
vesting_config: VestingConfig,
Expand All @@ -48,7 +49,7 @@ module memechan::staking_pool {
let staking_pool = StakingPool {
id: object::new(ctx),
amm_pool,
balance_meme: balance::zero(),
balance_meme,
balance_lp,
meme_cap,
policy_cap,
Expand Down Expand Up @@ -99,7 +100,10 @@ module memechan::staking_pool {
token_ir::to_coin(policy, coin_x, ctx),
);

balance::join(&mut balance_meme, balance::split(&mut staking_pool.balance_meme, release_amount));
let remaining_balance = balance::value(&staking_pool.balance_meme);
let safe_value = if (remaining_balance > release_amount) release_amount else remaining_balance;

balance::join(&mut balance_meme, balance::split(&mut staking_pool.balance_meme, safe_value));

(
coin::from_balance(balance_meme, ctx),
Expand Down

0 comments on commit 8f3737c

Please sign in to comment.