Skip to content

Commit

Permalink
Make it 1,000 tokens per USDC instead of 10,000
Browse files Browse the repository at this point in the history
  • Loading branch information
metaproph3t committed Feb 14, 2025
1 parent 047e187 commit d0f89ea
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion programs/launchpad/src/instructions/complete_launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use anchor_lang::{prelude::*, system_program};
use anchor_spl::associated_token::AssociatedToken;
use anchor_spl::token::{self, Mint, MintTo, Token, TokenAccount, Transfer};

use crate::TOKENS_PER_USDC;
use crate::error::LaunchpadError;
use crate::state::{Launch, LaunchState};
use raydium_cpmm_cpi::{
Expand Down Expand Up @@ -163,7 +164,7 @@ impl CompleteLaunch<'_> {
if launch_usdc_balance >= launch.minimum_raise_amount {
let usdc_to_lp = launch_usdc_balance.saturating_div(10);
let usdc_to_dao = launch_usdc_balance.saturating_sub(usdc_to_lp);
let token_to_lp = usdc_to_lp.saturating_mul(10_000);
let token_to_lp = usdc_to_lp.saturating_mul(TOKENS_PER_USDC);

let dao_key = launch.dao;

Expand Down
3 changes: 2 additions & 1 deletion programs/launchpad/src/instructions/fund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use anchor_spl::token::{self, Mint, Token, TokenAccount, Transfer, MintTo};

use crate::state::{Launch, LaunchState};
use crate::error::LaunchpadError;
use crate::TOKENS_PER_USDC;

#[derive(Accounts)]
pub struct Fund<'info> {
Expand Down Expand Up @@ -58,7 +59,7 @@ impl Fund<'_> {
// Transfer tokens from vault to funder (10,000 * USDC amount)
// We don't need to worry about decimals because both USDC and token
// have 6 decimals
let token_amount = amount * 10_000;
let token_amount = amount * TOKENS_PER_USDC;

let dao_key = ctx.accounts.launch.dao;

Expand Down
3 changes: 2 additions & 1 deletion programs/launchpad/src/instructions/refund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use anchor_spl::token::{self, Token, TokenAccount, Transfer, Burn, Mint};

use crate::state::{Launch, LaunchState};
use crate::error::LaunchpadError;
use crate::TOKENS_PER_USDC;

#[derive(Accounts)]
pub struct Refund<'info> {
Expand Down Expand Up @@ -68,7 +69,7 @@ impl Refund<'_> {
},
signer,
),
user_token_balance / 10_000,
user_token_balance.saturating_div(TOKENS_PER_USDC),
)?;

// Burn tokens
Expand Down
4 changes: 2 additions & 2 deletions programs/launchpad/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ use instructions::*;

declare_id!("AfJJJ5UqxhBKoE3grkKAZZsoXDE9kncbMKvqSHGsCNrE");

pub const TOKENS_PER_USDC: u64 = 1_000;

/// TODO:
/// - Add a `refund` instruction that allows funders to get their USDC back if the launch fails
/// - Add a `start_launch` instruction that allows the creator to start the launch
/// - Make it 1,000 tokens per USDC rather than 10,000
/// - Test on devnet
#[program]
Expand Down
2 changes: 0 additions & 2 deletions sdk/src/v0.4/types/launchpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export type Launchpad = {
name: "launchpad";
docs: [
"TODO:",
"- Add a `refund` instruction that allows funders to get their USDC back if the launch fails",
"- Add a `start_launch` instruction that allows the creator to start the launch",
"- Make it 1,000 tokens per USDC rather than 10,000",
"- Test on devnet"
Expand Down Expand Up @@ -538,7 +537,6 @@ export const IDL: Launchpad = {
name: "launchpad",
docs: [
"TODO:",
"- Add a `refund` instruction that allows funders to get their USDC back if the launch fails",
"- Add a `start_launch` instruction that allows the creator to start the launch",
"- Make it 1,000 tokens per USDC rather than 10,000",
"- Test on devnet",
Expand Down
2 changes: 1 addition & 1 deletion tests/launchpad/unit/fund.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ export default function suite() {
assert.equal(usdcVaultAccount.amount.toString(), fundAmount.toString());

const storedFunderTokenAccount = await getAccount(this.banksClient, funderTokenAccount);
assert.equal(storedFunderTokenAccount.amount.toString(), fundAmount.muln(10_000).toString());
assert.equal(storedFunderTokenAccount.amount.toString(), fundAmount.muln(1_000).toString());
});
}

0 comments on commit d0f89ea

Please sign in to comment.