Expand description
§sendfun-sdk
Rust SDK for the send.fun programs on Solana.
launchpad: token creation, bonding curve trades, migration.dex: AMM trades after migration.nexus: staking and partner fees.transfer_hook: the Token-2022 transfer-hook accounts of a trade. It resolves them from accounts that you fetch, without RPC.
The SDK builds instructions, decodes accounts and events, and calculates quotes
(launchpad::quote, dex::quote). It has no RPC client and does not send
transactions.
Fetch accounts with your own client. Compatible: solana-rpc-client 3.x and
4.1+, blocking and nonblocking. Not compatible: 4.0.x.
Decode an account with the from_account function of its type. from_account
checks the owner, then the discriminator:
use sendfun_sdk::launchpad::accounts::BondingCurve;
let account = rpc.get_account(&address)?;
let curve = BondingCurve::from_account(&account.owner, &account.data)?;get_account fails when the account does not exist. For an account that can
be missing, use get_account_with_commitment. Its value is None for a
missing account. Decode with from_account_maybe. It returns Ok(None) for an
uncreated PDA that holds lamports.
§Install
cargo add sendfun-sdkOptional features:
serde:SerializeandDeserializeon accounts, events and types.anchor:anchor-langinterop for on-chain callers.
§Rules
- For a trade, read
platform_configfrom the bonding curve or the pool. Do not use your own platform key. - A partner other than
DEFAULT_PARTNERmust sign. constants::find_platform_address(slug)returns the key of a platform.- Do not edit the
generatedmodules. They come from the program IDLs.
§Jupiter
jupiter/ holds a separate crate, sendfun-jupiter. It implements the
jupiter-amm-interface Amm trait for the launchpad and the DEX. Its parity
tests run each quote against the deployed program binaries in LiteSVM. The
crate has its own workspace and lockfile. Build and test it on its own:
cd jupiter && cargo testjupiter/README.md describes market discovery, the partner schedule, transfer
hooks and the swap account layout.
§Documentation
§License
MIT, see the LICENSE file.
§Reading accounts
Read an account that can be missing:
use sendfun_sdk::nexus::accounts::PartnerConfig;
let partner = match rpc
.get_account_with_commitment(&pda, rpc.commitment())?
.value
{
Some(account) => {
PartnerConfig::from_account_maybe(&account.owner, &account.data)?
}
None => None,
};Read several accounts in one call. The RPC accepts at most 100 addresses per call:
use sendfun_sdk::launchpad::accounts::BondingCurve;
let curves = rpc
.get_multiple_accounts(&keys)?
.iter()
.map(|account| match account {
Some(account) => {
BondingCurve::from_account_maybe(&account.owner, &account.data)
}
None => Ok(None),
})
.collect::<Result<Vec<_>, _>>()?;Modules§
- constants
- dex
- launchpad
- math
- nexus
- transfer_
fee - Reads the transfer fee of a Token-2022 mint from raw account data, for the
math::ammquotes. Cache aTransferFeeConfigonly while itstransfer_fee_config_authorityisNone. - transfer_
hook - Resolves the Token-2022 transfer-hook accounts of a trade from accounts that
you fetch. A list that reads the transfer amount or needs a signer is
Unresolvable. - utils