Instruction reference
Five entrypoints. Every account is constrained at the program boundary; the SDK and CLI mirror this exact surface area.
Summary
| Instruction | Args | Notes |
|---|---|---|
initialize_pool | fee_bps: u16 | Creates pool + two vault PDAs |
create_bloom | nonce: u64, amount_a: u64, amount_b: u64, duration_slots: u64 | Mints LP shares |
swap | amount_in: u64, min_out: u64, a_to_b: bool | Constant-product, basis-point fee |
settle_bloom | (none) | Permissionless after end_slot |
chirigiwa | (none) | Early exit, fixed 5% penalty |
create_bloom
Opens a time-bounded LP position. The nonce uniquely identifies the bloom for the (pool, owner) pair so the same owner can hold multiple positions in the same pool.
pub fn create_bloom(
ctx: Context<CreateBloom>,
nonce: u64,
amount_a: u64,
amount_b: u64,
duration_slots: u64,
) -> Result<()>;const { signature, bloom } = await client.createBloom({
pool,
amountA: new BN(1_000_000),
amountB: new BN(1_000_000),
durationSlots: new BN(2_400), // ~16 minutes at 400ms slots
});swap
Constant-product swap. The fee portion of amount_in stays in the vault and is tracked separately via cumulative_fee_per_share_* rather than being added to the reserve. This separation is what makes fee isolation possible.
pub fn swap(
ctx: Context<SwapCtx>,
amount_in: u64,
min_out: u64,
a_to_b: bool,
) -> Result<()>;settle_bloom
Permissionless. Anyone can call this after the bloom's end_slot; the position's owner always receives the funds.
pub fn settle_bloom(ctx: Context<SettleBloomCtx>) -> Result<()>;chirigiwa
Owner-only. Pays back the principal minus a fixed 5% penalty plus accrued fees. The penalty stays in the vault and accrues to remaining liquidity.
pub fn chirigiwa(ctx: Context<SettleBloomCtx>) -> Result<()>;Errors
#[error_code]
pub enum HanamiError {
FeeTooHigh, // 6000
InvalidDuration, // 6001
InvalidAmount, // 6002
InsufficientLiquidity,// 6003
NoLiquidity, // 6004
MathOverflow, // 6005
SlippageExceeded, // 6006
BloomNotMatured, // 6007
AlreadyMatured, // 6008
AlreadySettled, // 6009
Unauthorized, // 6010
PoolMismatch, // 6011
InvalidVault, // 6012
InvalidMint, // 6013
}