From d0f89eab4c304a2fe927fe1fbd00272872a2462c Mon Sep 17 00:00:00 2001 From: metaproph3t Date: Fri, 14 Feb 2025 00:00:00 -0700 Subject: [PATCH] Make it 1,000 tokens per USDC instead of 10,000 --- programs/launchpad/src/instructions/complete_launch.rs | 3 ++- programs/launchpad/src/instructions/fund.rs | 3 ++- programs/launchpad/src/instructions/refund.rs | 3 ++- programs/launchpad/src/lib.rs | 4 ++-- sdk/src/v0.4/types/launchpad.ts | 2 -- tests/launchpad/unit/fund.test.ts | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/programs/launchpad/src/instructions/complete_launch.rs b/programs/launchpad/src/instructions/complete_launch.rs index 3a3637cf..4803d0bd 100644 --- a/programs/launchpad/src/instructions/complete_launch.rs +++ b/programs/launchpad/src/instructions/complete_launch.rs @@ -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::{ @@ -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; diff --git a/programs/launchpad/src/instructions/fund.rs b/programs/launchpad/src/instructions/fund.rs index 199a164d..92ea4e36 100644 --- a/programs/launchpad/src/instructions/fund.rs +++ b/programs/launchpad/src/instructions/fund.rs @@ -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> { @@ -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; diff --git a/programs/launchpad/src/instructions/refund.rs b/programs/launchpad/src/instructions/refund.rs index ee06c308..e49e7a21 100644 --- a/programs/launchpad/src/instructions/refund.rs +++ b/programs/launchpad/src/instructions/refund.rs @@ -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> { @@ -68,7 +69,7 @@ impl Refund<'_> { }, signer, ), - user_token_balance / 10_000, + user_token_balance.saturating_div(TOKENS_PER_USDC), )?; // Burn tokens diff --git a/programs/launchpad/src/lib.rs b/programs/launchpad/src/lib.rs index 0022bd96..d0f8b30d 100644 --- a/programs/launchpad/src/lib.rs +++ b/programs/launchpad/src/lib.rs @@ -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] diff --git a/sdk/src/v0.4/types/launchpad.ts b/sdk/src/v0.4/types/launchpad.ts index 79932ab8..734e4dee 100644 --- a/sdk/src/v0.4/types/launchpad.ts +++ b/sdk/src/v0.4/types/launchpad.ts @@ -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" @@ -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", diff --git a/tests/launchpad/unit/fund.test.ts b/tests/launchpad/unit/fund.test.ts index 889b4f83..df4e3806 100644 --- a/tests/launchpad/unit/fund.test.ts +++ b/tests/launchpad/unit/fund.test.ts @@ -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()); }); } \ No newline at end of file