API reference

Every instruction of the PLEDGE program, with its arguments and accounts in order. Writable accounts are marked (w), signers (s). The IDL is engine/target/idl/pledge.json; the app builds every instruction from it.

create_campaign

Opens a campaign and moves the whole bonus deposit into its vault.

ArgumentTypeMeaning
idu64creator's own campaign number; part of the campaign's seeds
goalu64base units of the mint that must be pledged by the deadline
deadlinei64unix time; 1 to 90 days after now
bonus_bpsu16100 to 5,000 (1% to 50%)
bonus_depositu64base units locked now; deposit x 10,000 / bonus_bps <= goal
uristringup to 200 bytes, the campaign's description link

Accounts: creator (w, s), mint, campaign (w), vault (w), creator_token (w), fee_vault (w), burn_authority, token_program, system_program.

Emits CampaignCreated { campaign, creator, mint, goal, bonus_deposit, bonus_bps, early_cap, early_end, deadline }.

pledge

Escrows amount until the deadline.

ArgumentTypeMeaning
amountu64base units to pledge, more than zero
min_eligibleu64revert if less than this much of the pledge would earn the bonus

Accounts: backer (w, s), campaign (w), pledge (w), mint, vault (w), backer_token (w), token_program, system_program.

Emits Pledged { campaign, backer, amount, eligible, bonus_if_failed, total_pledged }.

lock_waiver

Locks config.waiver_amount PLEDGE in the campaign until it settles; the raise becomes fee-free. Once per campaign, before the deadline.

Accounts: creator (w, s), campaign (w), config, pledge_mint, creator_pledge_token (w), waiver_vault (w), pledge_token_program, system_program.

settle

Anyone, at or after the deadline. total_pledged >= goal is success; anything less is failure. Takes the 2% fee on success unless a waiver is locked.

Accounts: campaign (w), mint, vault (w), fee_vault (w), token_program.

Emits Settled { campaign, succeeded, total_pledged, fee, bonus_owed }.

claim_backer

Anyone, after settle. Failure: pays amount + floor(eligible x bonus_bps / 10,000) to the backer's own token account. Success: pays nothing and closes the pledge record. Rent goes back to the backer.

Accounts: campaign (w), pledge (w), backer (w), mint, vault (w), backer_token (w), token_program.

claim_creator

Anyone, after settle, once. Success: total_pledged - fee_paid + bonus_deposit. Failure: bonus_deposit - bonus_owed. Only to the creator's own token account.

Accounts: campaign (w), mint, vault (w), creator_token (w), token_program.

release_waiver

Anyone, after settle: the locked PLEDGE goes back to the creator.

Accounts: campaign (w), creator (w), config, pledge_mint, creator_pledge_token (w), waiver_vault (w), pledge_token_program.

close_campaign

Anyone, when every backer, the creator and the waiver are paid. Sends any stray tokens in the vault to the creator, closes the vault and the campaign, rent to the creator.

Accounts: campaign (w), creator (w), mint, vault (w), creator_token (w), token_program.

crank_burn

Anyone. Spends up to amount of one mint's fees buying PLEDGE in the pool pinned in Config and burns everything bought. At most 0.1% of the pool's reserve per call, at least 98% of the pool's 30-minute time-weighted price.

ArgumentTypeMeaning
amountu64fee units to spend in this call

Accounts: caller (s), config (w), fee_mint, fee_vault (w), burn_authority, bought (w), pledge_mint (w), pool (w), amm_config, pool_fee_vault (w), pool_pledge_vault (w), observation (w), cpmm_authority, cpmm_program, token_program, pledge_token_program.

init_config

Upgrade authority only, once at launch. Names PLEDGE, its CP-Swap pools (USDC required, wrapped SOL optional) and the waiver size.

ArgumentTypeMeaning
waiver_amountu64PLEDGE base units a creator locks for a fee-free raise

Accounts: authority (w, s), config (w), pledge_mint, burn_authority, bought (w), usdc_pool, wsol_pool, program, program_data, pledge_token_program, system_program.