Skip to content

Commit

Permalink
new fee structure, reduced unstaking fee to 0.001
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmoi committed May 3, 2022
1 parent 33a8141 commit 289ffaf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions programs/gem_farm/src/instructions/flash_deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::str::FromStr;
use crate::state::*;

const FEE_LAMPORTS: u64 = 2_000_000; // 0.002 SOL per stake/unstake
const FD_FEE_LAMPORTS: u64 = 1_000_000; // half of that for FDs

#[derive(Accounts)]
#[instruction(bump_farmer: u8)]
Expand Down Expand Up @@ -104,9 +105,9 @@ impl<'info> FlashDeposit<'info> {
)
}

fn transfer_fee(&self) -> Result<()> {
fn transfer_fee(&self, fee: u64) -> Result<()> {
invoke(
&system_instruction::transfer(self.identity.key, self.fee_acc.key, FEE_LAMPORTS),
&system_instruction::transfer(self.identity.key, self.fee_acc.key, fee),
&[
self.identity.to_account_info(),
self.fee_acc.clone(),
Expand Down Expand Up @@ -165,7 +166,7 @@ pub fn handler<'a, 'b, 'c, 'info>(
farmer,
)?;
//collect a fee for staking
ctx.accounts.transfer_fee()?;
ctx.accounts.transfer_fee(FEE_LAMPORTS)?;
} else {
let extra_rarity = calc_rarity_points(&ctx.accounts.gem_rarity, amount)?;
farm.stake_extra_gems(
Expand All @@ -176,6 +177,8 @@ pub fn handler<'a, 'b, 'c, 'info>(
extra_rarity,
farmer,
)?;
//collect a fee for staking
ctx.accounts.transfer_fee(FD_FEE_LAMPORTS)?;
}

// msg!("{} extra gems staked for {}", amount, farmer.key());
Expand Down
2 changes: 1 addition & 1 deletion programs/gem_farm/src/instructions/unstake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::str::FromStr;

use crate::state::*;

const FEE_LAMPORTS: u64 = 2_000_000; // 0.002 SOL per stake/unstake
const FEE_LAMPORTS: u64 = 1_000_000; // 0.002 SOL per entire unstake op (charged twice, so 0.001 2x)

#[derive(Accounts)]
#[instruction(bump_auth: u8, bump_treasury: u8, bump_farmer: u8)]
Expand Down

0 comments on commit 289ffaf

Please sign in to comment.