sla-escrow-api 0.2.5

SLA-Escrow: Service Level Agreement Enforcer for AI Agents
Documentation
use const_crypto::ed25519;
use solana_program::{pubkey, pubkey::Pubkey};

// Test initializer (mac::id.json)
// pub const INITIALIZER_ADDRESS: Pubkey = pubkey!("Ac2ev4ofDx61tuSJCgq9ToSBfVwHD2a1FVJf6p7TAqiB");
// Test initializer (mac&hp::test-id.json)
pub const INITIALIZER_ADDRESS: Pubkey = pubkey!("4ALL9EAVHpv7ioJF95ktDLtrHUEJezPuFxTFFMy3fpSy");

// The authority allowed to initialize the program.
// pub const INITIALIZER_ADDRESS: Pubkey = pubkey!("staryJacbXodPh4WfwVtgA5jkJhvsMHERtkdttnLEHc");

/// Basis points denominator for percentage calculations (1 basis point = 0.01%).
pub const BASIS_POINTS_DENOMINATOR: u128 = 10_000;

pub const DEFAULT_FEE_BPS: u16 = 100; // 1%

/// Closure delay constants (in seconds)
pub const CLOSURE_DELAY_RELEASE_REFUND: i64 = 7 * 24 * 60 * 60; // 7 days
pub const CLOSURE_DELAY_CANCEL: i64 = 3 * 24 * 60 * 60; // 3 days

/// TTL (Time To Live) constants (in seconds)
pub const MIN_TTL_SECONDS: i64 = 60; // 1 minute minimum
pub const DEFAULT_TTL_SECONDS: i64 = 3600; // 1 hour default
pub const MAX_TTL_SECONDS: i64 = 30 * 24 * 60 * 60; // 30 days maximum

/// Payment state constants
pub const PAYMENT_STATE_FUNDED: u8 = 0; // Account created and funded atomically
pub const PAYMENT_STATE_RELEASED: u8 = 1; // Released to seller (normal flow)
pub const PAYMENT_STATE_REFUNDED: u8 = 2; // Refunded to buyer (normal flow)

/// The seed of the bank account PDA.
pub const BANK: &[u8] = b"bank";

/// The seed of the config account PDA.
pub const CONFIG: &[u8] = b"config";

/// The seed for escrow account PDAs.
pub const ESCROW: &[u8] = b"escrow";

pub const SOL_STORAGE: &[u8] = b"sol_storage";

/// The seed for payment account PDAs.
pub const PAYMENT: &[u8] = b"payment";

pub const MARS_MINT_ADDRESS: Pubkey = pubkey!("7RAV5UPRTzxn46kLeA8MiJsdNy9VKc5fip8FWEgTpTHh");
pub const USDC_MINT_ADDRESS: Pubkey = pubkey!("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
pub const USDT_MINT_ADDRESS: Pubkey = pubkey!("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB");
pub const WSOL_MINT_ADDRESS: Pubkey = pubkey!("So11111111111111111111111111111111111111112");
pub const MIRACLE_MINT_ADDRESS: Pubkey = pubkey!("Mirab4SFVff6sCuK48PPnSUj7PNpDDrBWY6FkJmuifG");
pub const TESTCOIN_MINT_ADDRESS: Pubkey = pubkey!("2gNCDGj8Xi9Zs7LNQTPWf4pfZvAM7UHusY4xhKNYg6W6");

/// SPL Token-2022 Program ID
pub const TOKEN_2022_PROGRAM_ID: Pubkey = pubkey!("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");

/// Program id for const pda derivations
const PROGRAM_ID: [u8; 32] = unsafe { *(&crate::id() as *const Pubkey as *const [u8; 32]) };

/// The address of the bank account.
pub const BANK_ADDRESS: Pubkey =
    Pubkey::new_from_array(ed25519::derive_program_address(&[BANK], &PROGRAM_ID).0);

/// The bump of the bank account.
pub const BANK_BUMP: u8 = ed25519::derive_program_address(&[BANK], &PROGRAM_ID).1;

/// The address of the config account.
pub const CONFIG_ADDRESS: Pubkey =
    Pubkey::new_from_array(ed25519::derive_program_address(&[CONFIG], &PROGRAM_ID).0);

pub const MARS_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
    ed25519::derive_program_address(
        &[
            ESCROW,
            unsafe { &*(&MARS_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
        ],
        &PROGRAM_ID,
    )
    .0,
);
pub const MARS_ESCROW_BUMP: u8 = ed25519::derive_program_address(
    &[
        ESCROW,
        unsafe { &*(&MARS_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
    ],
    &PROGRAM_ID,
)
.1;
pub const MARS_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
    ed25519::derive_program_address(
        &[
            unsafe { &*(&MARS_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&MARS_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
        ],
        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
    )
    .0,
);

pub const MIRACLE_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
    ed25519::derive_program_address(
        &[
            ESCROW,
            unsafe { &*(&MIRACLE_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
        ],
        &PROGRAM_ID,
    )
    .0,
);
pub const MIRACLE_ESCROW_BUMP: u8 = ed25519::derive_program_address(
    &[
        ESCROW,
        unsafe { &*(&MIRACLE_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
    ],
    &PROGRAM_ID,
)
.1;
pub const MIRACLE_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
    ed25519::derive_program_address(
        &[
            unsafe { &*(&MIRACLE_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&MIRACLE_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
        ],
        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
    )
    .0,
);

pub const USDC_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
    ed25519::derive_program_address(
        &[
            ESCROW,
            unsafe { &*(&USDC_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
        ],
        &PROGRAM_ID,
    )
    .0,
);
pub const USDC_ESCROW_BUMP: u8 = ed25519::derive_program_address(
    &[
        ESCROW,
        unsafe { &*(&USDC_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
    ],
    &PROGRAM_ID,
)
.1;
pub const USDC_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
    ed25519::derive_program_address(
        &[
            unsafe { &*(&USDC_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&USDC_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
        ],
        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
    )
    .0,
);

pub const USDT_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
    ed25519::derive_program_address(
        &[
            ESCROW,
            unsafe { &*(&USDT_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
        ],
        &PROGRAM_ID,
    )
    .0,
);
pub const USDT_ESCROW_BUMP: u8 = ed25519::derive_program_address(
    &[
        ESCROW,
        unsafe { &*(&USDT_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
    ],
    &PROGRAM_ID,
)
.1;
pub const USDT_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
    ed25519::derive_program_address(
        &[
            unsafe { &*(&USDT_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&USDT_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
        ],
        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
    )
    .0,
);

pub const WSOL_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
    ed25519::derive_program_address(
        &[
            ESCROW,
            unsafe { &*(&WSOL_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
        ],
        &PROGRAM_ID,
    )
    .0,
);
pub const WSOL_ESCROW_BUMP: u8 = ed25519::derive_program_address(
    &[
        ESCROW,
        unsafe { &*(&WSOL_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
    ],
    &PROGRAM_ID,
)
.1;
pub const WSOL_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
    ed25519::derive_program_address(
        &[
            unsafe { &*(&WSOL_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&WSOL_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
        ],
        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
    )
    .0,
);
pub const TESTCOIN_ESCROW_ADDRESS: Pubkey = Pubkey::new_from_array(
    ed25519::derive_program_address(
        &[
            ESCROW,
            unsafe { &*(&TESTCOIN_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
        ],
        &PROGRAM_ID,
    )
    .0,
);
pub const TESTCOIN_ESCROW_BUMP: u8 = ed25519::derive_program_address(
    &[
        ESCROW,
        unsafe { &*(&TESTCOIN_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
        unsafe { &*(&BANK_ADDRESS as *const Pubkey as *const [u8; 32]) },
    ],
    &PROGRAM_ID,
)
.1;
pub const TESTCOIN_ESCROW_TOKENS_ADDRESS: Pubkey = Pubkey::new_from_array(
    ed25519::derive_program_address(
        &[
            unsafe { &*(&TESTCOIN_ESCROW_ADDRESS as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&spl_token::id() as *const Pubkey as *const [u8; 32]) },
            unsafe { &*(&TESTCOIN_MINT_ADDRESS as *const Pubkey as *const [u8; 32]) },
        ],
        unsafe { &*(&spl_associated_token_account::id() as *const Pubkey as *const [u8; 32]) },
    )
    .0,
);