universalsettle-api 0.1.6

X402-inspired settlement program for any token on Solana
Documentation
mod authority_transfer;
mod config;
mod split_vault;

pub use authority_transfer::*;
pub use config::*;
pub use split_vault::*;

use steel::*;

use crate::consts::*;

#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
pub enum SettlementAccount {
    Config = 0,
    SplitVault = 1,
    AuthorityTransfer = 2,
}

/// Derive the PDA of the config account.
pub fn config_pda() -> (Pubkey, u8) {
    Pubkey::find_program_address(&[CONFIG], &crate::id())
}

/// Derive the PDA of the SplitVault account
pub fn split_vault_pda(seller: &Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(&[VAULT, seller.as_ref()], &crate::id())
}

/// Derive the PDA of the SOL storage account for a SplitVault.
pub fn vault_sol_storage_pda(vault_pda: Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(&[SOL_STORAGE, vault_pda.as_ref()], &crate::id())
}

/// Derive the PDA of an authority transfer proposal.
pub fn authority_transfer_pda(config: Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(&[AUTHORITY_TRANSFER, config.as_ref()], &crate::id())
}