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
andcontract_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
andcontract_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
andfrom_account.mint
with bump).Mutable: No.
Constraints: Must be an
AssetConfig
wheremin_deposit
is less than or equal toamount
.
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. Iflast_deposit_index
is not0
, aprev_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 fromfrom_account
toto_account
with the authoritydepositor
.Creates and stores a
Deposit
wheretransfer
holds the deposit information andprev_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 fromfrom_account
toto_account
, signed bydepositor
.