Depositing Funds

EVM-Compatible Networks

Native Coin Deposit

function deposit(address ephemeralL2Address, TradeInput calldata input, TradeDetail calldata data) external payable;

🔐 Permissionless Execution

  • Callable by any user initiating a native coin trade.

  • Requires msg.value to match the expected deposit amount.

🔎 Trade Validation

  • Ensures the caller matches the expected sender in TradeInput.

  • Checks whether the tradeId derived from the input has already been used.

  • Prevents replay attacks or duplicate trade submissions.

🔁 Trade State Transition

  • Records the hash of TradeDetail for future verification and process continuity.

📢 Event Emission

  • Emits a Deposited event with metadata required for off-chain monitoring and processing.

ERC-20 Token Deposit

function deposit(address ephemeralL2Address, TradeInput calldata input, TradeDetail calldata data) external;

🔐 Permissionless Execution

  • Callable by any user initiating an ERC-20 token trade.

🔎 Trade Validation

  • Ensures the deposited token matches the configured LOCKING_TOKEN.

  • Ensures the caller matches the expected sender in TradeInput.

  • Checks whether the tradeId derived from the input has already been used.

  • Prevents replay or re-submission of the same trade.

💸 Token Transfer

  • Uses safeTransferFrom to securely transfer tokens into the Vault contract.

  • The caller must approve the Vault to spend tokens prior to calling.

🔁 Trade State Transition

  • Records the hash of TradeDetail for future verification and process continuity.

📢 Event Emission

  • Emits a Deposited event with metadata required for off-chain monitoring and processing.

Unlike EVM and Solana networks which use smart contracts, Bitcoin utilizes the Native Bitcoin Vault—a non-custodial escrow built with Bitcoin's native scripting.

Users deposit BTC into a P2TR (Pay-to-Taproot) address controlled by a 2-of-2 multisig between the user and the Settlement Committee. Trades are settled when both parties sign, or users can reclaim funds after timelock expiry using only their own key.

For technical details on vault construction, spending paths, and security model, see Native Bitcoin Vault.

Solana Network

Native SOL and SPL-token deposit

Unlike EVM networks, we use a single function for depositing both native SOL and SPL tokens. The distinction between them is made using arguments and the list of accounts.

pub struct TradeInput {
    /// The sessionId, unique identifier for the trade.
    pub session_id: [u8; 32],  
    /// The solver address, the address of the solver.
    pub solver: [u8; 20],      
    /// The trade information, contains the information about the origin and destination of the trade.
    pub trade_info: TradeInfo, 
}

pub struct TradeDetailInput {
    pub timeout: i64,
    pub mpc_pubkey: Pubkey,
    pub refund_pubkey: Pubkey,
}
pub struct DepositArgs {
    /// Input trade information.
    pub input: TradeInput,
    /// Detailed trade data.
    pub data: TradeDetailInput,
    /// The tradeId, unique identifier for the trade.
    pub trade_id: [u8; 32],
}
pub fn handler_deposit<'c: 'info, 'info>(
    ctx: Context<'_, '_, 'c, 'info, DepositAccounts<'info>>,
    deposit_args: DepositArgs,
) -> Result<()>

🔐 Permissionless Execution

  • Callable by any user initiating a trade.

🔎 Trade Validation

  • Ensures that the ephemeral_account is not associated with any active trades.

  • Ensures signer matches the expected spender in TradeInput .

  • Ensures the asset matches the expected value in the TradeInput. For native SOL, the asset is marked as native; otherwise, it is the public key of the SPL token.

  • Ensures the deposited amount is at least equal to the whitelisted minimum set by the operators.

  • Checks whether the tradeId derived from the input has already been used.

  • Check whether the asset was whitelisted by the operators beforehand.

  • Prevents replay attacks or duplicate trade submissions.

  • Ensures the deposited vault address matches the expected vault PDA uniquely derived for the trade.

💸 Token Transfer

  • Use spl_token::transfer_checked instruction to securely transfer SPL-token with the correct accounts.

  • Use system_program::transfer instruction to transfer native SOL with the correct accounts.

🔁 Trade State Transition

  • Creates a TradeDetail PDA account to store trade information for future verification and process continuity, state of the TradeDetail will be Deposited

Last updated