Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions programs/v07_launchpad/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub struct LaunchInitializedEvent {
pub additional_tokens_amount: u64,
pub additional_tokens_recipient: Option<Pubkey>,
pub accumulator_activation_delay_seconds: u32,
pub has_bid_wall: bool,
}

#[event]
Expand Down
23 changes: 15 additions & 8 deletions programs/v07_launchpad/src/instructions/complete_launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,21 @@ impl CompleteLaunch<'_> {
let usdc_to_lp = launch_total_approved_amount.saturating_div(5);
let usdc_to_dao = launch_total_approved_amount.saturating_sub(usdc_to_lp);

// We then determine how much USDC to allocate to the DAO treasury, and how much to the DAO's bid wall
// In scenarios where the total approved amount is less than 1.25x the minimum raise amount:
// - we allocate the entire amount after LP allocation to the DAO treasury
// - we don't initialize the bid wall
// In all other scenarios, a bid wall is initialized with the remaining USDC after LP and DAO treasury allocation
// This is emergent behavior from the design of the launch, as 20% of the total approved amount is allocated to Futarchy AMM liquidity
let usdc_to_dao_treasury = usdc_to_dao.min(ctx.accounts.launch.minimum_raise_amount);
let usdc_to_bid_wall = usdc_to_dao.saturating_sub(usdc_to_dao_treasury);
// We only activate the bid wall if the launch has one configured.
// Otherwise, we allocate the entire amount after LP allocation to the DAO treasury.
let (usdc_to_dao_treasury, usdc_to_bid_wall) = if ctx.accounts.launch.has_bid_wall {
// We determine how much USDC to allocate to the DAO treasury, and how much to the DAO's bid wall
// In scenarios where the total approved amount is less than 1.25x the minimum raise amount:
// - we allocate the entire amount after LP allocation to the DAO treasury
// - we don't initialize the bid wall
// In all other scenarios, a bid wall is initialized with the remaining USDC after LP and DAO treasury allocation
// This is emergent behavior from the design of the launch, as 20% of the total approved amount is allocated to Futarchy AMM liquidity
let usdc_to_dao_treasury = usdc_to_dao.min(ctx.accounts.launch.minimum_raise_amount);
let usdc_to_bid_wall = usdc_to_dao.saturating_sub(usdc_to_dao_treasury);
(usdc_to_dao_treasury, usdc_to_bid_wall)
} else {
(usdc_to_dao, 0)
};

ctx.accounts.initialize_dao(launch_signer, price_1e12)?;

Expand Down
3 changes: 3 additions & 0 deletions programs/v07_launchpad/src/instructions/initialize_launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub struct InitializeLaunchArgs {
pub team_address: Pubkey,
pub additional_tokens_amount: u64,
pub accumulator_activation_delay_seconds: u32,
pub has_bid_wall: bool,
}

#[event_cpi]
Expand Down Expand Up @@ -247,6 +248,7 @@ impl InitializeLaunch<'_> {
unix_timestamp_completed: None,
is_performance_package_initialized: false,
accumulator_activation_delay_seconds: args.accumulator_activation_delay_seconds,
has_bid_wall: args.has_bid_wall,
});

let clock = Clock::get()?;
Expand Down Expand Up @@ -275,6 +277,7 @@ impl InitializeLaunch<'_> {
.as_ref()
.map(|a| a.key()),
accumulator_activation_delay_seconds: args.accumulator_activation_delay_seconds,
has_bid_wall: args.has_bid_wall,
});

let launch_key = ctx.accounts.launch.key();
Expand Down
3 changes: 2 additions & 1 deletion programs/v07_launchpad/src/instructions/resize_launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ impl ResizeLaunch<'_> {
additional_tokens_claimed: old_data.additional_tokens_claimed,
unix_timestamp_completed: old_data.unix_timestamp_completed,
is_performance_package_initialized: old_data.is_performance_package_initialized,
accumulator_activation_delay_seconds: 0,
accumulator_activation_delay_seconds: old_data.accumulator_activation_delay_seconds,
has_bid_wall: false,
};

launch.realloc(AFTER_REALLOC_SIZE, true)?;
Expand Down
6 changes: 5 additions & 1 deletion programs/v07_launchpad/src/state/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ pub struct Launch {
/// Number of seconds after launch start before the funding accumulator
/// begins tracking.
pub accumulator_activation_delay_seconds: u32,
/// Whether the launch has a bid wall.
pub has_bid_wall: bool,
}

#[account]
Expand Down Expand Up @@ -152,6 +154,8 @@ pub struct OldLaunch {
pub additional_tokens_claimed: bool,
/// The unix timestamp when the launch was completed.
pub unix_timestamp_completed: Option<i64>,
/// Whether the performance package has been initialized.
pub is_performance_package_initialized: bool,
/// Number of seconds after launch start before the funding accumulator
/// begins tracking.
pub accumulator_activation_delay_seconds: u32,
}
2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metadaoproject/futarchy",
"version": "0.7.1-alpha.5",
"version": "0.7.2-alpha.0",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
Expand Down
3 changes: 3 additions & 0 deletions sdk/src/v0.7/LaunchpadClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export class LaunchpadClient {
additionalTokensRecipient,
additionalTokensAmount,
accumulatorActivationDelaySeconds = 0,
hasBidWall = false,
}: {
tokenName: string;
tokenSymbol: string;
Expand All @@ -172,6 +173,7 @@ export class LaunchpadClient {
additionalTokensRecipient?: PublicKey;
additionalTokensAmount?: BN;
accumulatorActivationDelaySeconds?: number;
hasBidWall: boolean;
}) {
const [launch] = getLaunchAddr(this.launchpad.programId, baseMint);
const [launchSigner] = getLaunchSignerAddr(
Expand Down Expand Up @@ -206,6 +208,7 @@ export class LaunchpadClient {
teamAddress,
additionalTokensAmount: additionalTokensAmount ?? new BN(0),
accumulatorActivationDelaySeconds,
hasBidWall,
})
.accounts({
launch,
Expand Down
46 changes: 44 additions & 2 deletions sdk/src/v0.7/types/launchpad_v7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,11 @@ export type LaunchpadV7 = {
];
type: "u32";
},
{
name: "hasBidWall";
docs: ["Whether the launch has a bid wall."];
type: "bool";
},
];
};
},
Expand Down Expand Up @@ -1332,9 +1337,16 @@ export type LaunchpadV7 = {
},
{
name: "isPerformancePackageInitialized";
docs: ["Whether the performance package has been initialized."];
type: "bool";
},
{
name: "accumulatorActivationDelaySeconds";
docs: [
"Number of seconds after launch start before the funding accumulator",
"begins tracking.",
];
type: "u32";
},
];
};
},
Expand Down Expand Up @@ -1419,6 +1431,10 @@ export type LaunchpadV7 = {
name: "accumulatorActivationDelaySeconds";
type: "u32";
},
{
name: "hasBidWall";
type: "bool";
},
];
};
},
Expand Down Expand Up @@ -1556,6 +1572,11 @@ export type LaunchpadV7 = {
type: "u32";
index: false;
},
{
name: "hasBidWall";
type: "bool";
index: false;
},
];
},
{
Expand Down Expand Up @@ -3162,6 +3183,11 @@ export const IDL: LaunchpadV7 = {
],
type: "u32",
},
{
name: "hasBidWall",
docs: ["Whether the launch has a bid wall."],
type: "bool",
},
],
},
},
Expand Down Expand Up @@ -3360,9 +3386,16 @@ export const IDL: LaunchpadV7 = {
},
{
name: "isPerformancePackageInitialized",
docs: ["Whether the performance package has been initialized."],
type: "bool",
},
{
name: "accumulatorActivationDelaySeconds",
docs: [
"Number of seconds after launch start before the funding accumulator",
"begins tracking.",
],
type: "u32",
},
],
},
},
Expand Down Expand Up @@ -3447,6 +3480,10 @@ export const IDL: LaunchpadV7 = {
name: "accumulatorActivationDelaySeconds",
type: "u32",
},
{
name: "hasBidWall",
type: "bool",
},
],
},
},
Expand Down Expand Up @@ -3584,6 +3621,11 @@ export const IDL: LaunchpadV7 = {
type: "u32",
index: false,
},
{
name: "hasBidWall",
type: "bool",
index: false,
},
],
},
{
Expand Down
1 change: 1 addition & 0 deletions tests/launchpad_v7/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default function suite() {
monthsUntilInsidersCanUnlock: 24, // 2 years
teamAddress: PublicKey.default,
launchAuthority: launchAuthority,
hasBidWall: false,
})
.rpc();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default function suite() {
launchAuthority: launchAuthority.publicKey,
additionalTokensAmount: additionalTokensAmount,
additionalTokensRecipient: additionalTokensRecipient,
hasBidWall: false,
})
.rpc();

Expand Down Expand Up @@ -200,6 +201,7 @@ export default function suite() {
monthsUntilInsidersCanUnlock: 18,
teamAddress: PublicKey.default,
launchAuthority: launchAuthority.publicKey,
hasBidWall: false,
})
.rpc();

Expand Down
1 change: 1 addition & 0 deletions tests/launchpad_v7/unit/closeLaunch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export default function suite() {
monthsUntilInsidersCanUnlock: 18,
teamAddress: PublicKey.default,
launchAuthority: launchAuthority.publicKey,
hasBidWall: false,
})
.rpc();

Expand Down
Loading
Loading