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_SEEDandcontract_storage.last_deposit_index + 1with bump).Mutable: Yes.
Constraints: Must be a new account initialized with space
8 + 104(discriminator +Depositsize).
prev_deposit: The previous deposit data.Signer: No.
Init: No.
PDA: Yes (derived from
DEPOSIT_SEEDandcontract_storage.last_deposit_indexwith 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_SEEDandfrom_account.mintwith bump).Mutable: No.
Constraints: Must be an
AssetConfigwheremin_depositis less than or equal toamount.
contract_storage: The global contract storage.Signer: No.
Init: No.
PDA: Yes (derived from
CONTRACT_STORAGE_SEEDwith bump).Mutable: Yes.
Constraints: Must be a
ContractStorageaccount. Iflast_deposit_indexis not0, aprev_depositmust 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
amountof the SPL token fromfrom_accounttoto_accountwith the authoritydepositor.Creates and stores a
Depositwheretransferholds the deposit information andprev_deposit_rootis the hash of the previous deposit, if supplied.Increments
contract_storage.last_deposit_index.Logs a
Depositevent.
CPI
transfer: Transfers the specified tokens fromfrom_accounttoto_account, signed bydepositor.