Assessment reports>N1 Bridge>Threat Model>Instruction: deposit_spl

Instruction: deposit_spl

This instruction allows the depositor to deposit SPL tokens to the bridge.

Input parameters

  • amount: u64: The amount of SPL tokens to deposit.

Accounts

  • depositor: The depositor account that is the authority for the deposited tokens — pays for the new initialized accounts.

    • Signer: Yes.

    • Init: No.

    • PDA: No.

    • Mutable: Yes.

    • Constraints: Must have sufficient lamports to cover the account-creation cost.

  • deposit: The account to hold the new deposit data.

    • Signer: No.

    • Init: Yes.

    • PDA: Yes (derived from DEPOSIT_SEED and contract_storage.last_deposit_index + 1 with bump).

    • Mutable: Yes.

    • Constraints: Must be a new account initialized with space 8 + 104 (discriminator + Deposit size).

  • prev_deposit: The previous deposit data.

    • Signer: No.

    • Init: No.

    • PDA: Yes (derived from DEPOSIT_SEED and contract_storage.last_deposit_index with bump).

    • Mutable: No.

    • Optional: Yes.

    • Constraints: Must be of type Deposit.

  • asset_config: The configuration data for this asset.

    • Signer: No.

    • Init: No.

    • PDA: Yes (derived from ASSET_CONFIG_SEED and from_account.mint with bump).

    • Mutable: No.

    • Constraints: Must be an AssetConfig where min_deposit is less than or equal to amount.

  • contract_storage: The global contract storage.

    • Signer: No.

    • Init: No.

    • PDA: Yes (derived from CONTRACT_STORAGE_SEED with bump).

    • Mutable: Yes.

    • Constraints: Must be a ContractStorage account. If last_deposit_index is not 0, a prev_deposit must be provided.

  • from_account: The SPL token account where tokens are taken from.

    • Signer: No.

    • Init: No.

    • PDA: No.

    • Mutable: Yes.

    • Constraints: Must be a valid SPL token account.

  • to_account: The ATA where tokens will be sent.

    • Signer: No.

    • Init: No.

    • PDA: No.

    • Mutable: Yes.

    • Constraints: Must be an ATA for the authority account, with the same mint as from_account.

Additional checks and behavior

  • Transfers amount of the SPL token from from_account to to_account with the authority depositor.

  • Creates and stores a Deposit where transfer holds the deposit information and prev_deposit_root is the hash of the previous deposit, if supplied.

  • Increments contract_storage.last_deposit_index.

  • Logs a Deposit event.

CPI

  • transfer: Transfers the specified tokens from from_account to to_account, signed by depositor.

Zellic © 2025Back to top ↑