API
Version: 0.1.0 Format Version: 46Module relay_depository
Modules
Module program
Module representing the program.
Types
Struct RelayDepository
Type representing the program.
Module relay_depository
Functions
Function initialize
Initialize the relay depository program with owner and allocator
Creates and initializes the relay depository account with the specified
owner and allocator.
Parameters
ctx- The context containing the accounts
Returns
Ok(())on success
Function set_allocator
Update the allocator public key
Allows the owner to change the authorized allocator that can sign transfer requests.
Parameters
ctx- The context containing the accountsnew_allocator- The public key of the new allocator
Returns
Ok(())on successErr(error)if not authorized
Function set_owner
Update the owner public key
Allows the current owner to transfer ownership to a new address.
Parameters
ctx- The context containing the accountsnew_owner- The public key of the new owner
Returns
Ok(())on successErr(error)if not authorized
Function deposit_native
Deposit native SOL tokens into the vault
Transfers SOL from the sender to the vault and emits a deposit event.
Parameters
ctx- The context containing the accountsamount- The amount of SOL to depositid- A unique identifier for the deposit
Returns
Ok(())on success
Function deposit_token
Deposit SPL tokens into the vault
Creates the vault’s token account if needed, transfers tokens from the sender,
and emits a deposit event.
Parameters
ctx- The context containing the accountsamount- The amount of tokens to depositid- A unique identifier for the deposit
Returns
Ok(())on success
Function execute_transfer
Execute a transfer with allocator signature
Verifies the allocator’s signature, transfers tokens to the recipient,
and marks the request as used.
Parameters
ctx- The context containing the accountsrequest- The transfer request details and signature
Returns
Ok(())on successErr(error)if signature is invalid or request can’t be processed
Module instruction
An Anchor generated module containing the program’s set of
instructions, where each method handler in the #[program] mod is
associated with a struct defining the input arguments to the
method. These should be used directly, when one wants to serialize
Anchor instruction data, for example, when specifying
instructions on a client.
Types
Struct Initialize
Instruction.
Struct SetAllocator
Instruction.
Fields
Struct SetOwner
Instruction.
Fields
Struct DepositNative
Instruction.
Fields
Struct DepositToken
Instruction.
Fields
Struct ExecuteTransfer
Instruction.
Fields
Module cpi
Attributes:
#[<cfg>(feature = "cpi")]
Modules
Module accounts
An Anchor generated module, providing a set of structs
mirroring the structs deriving Accounts, where each field is
an AccountInfo. This is useful for CPI.
Re-exports
Re-export crate::__cpi_client_accounts_set_allocator::*
Re-export crate::__cpi_client_accounts_set_owner::*
Re-export crate::__cpi_client_accounts_initialize::*
Re-export crate::__cpi_client_accounts_deposit_token::*
Re-export crate::__cpi_client_accounts_execute_transfer::*
Re-export crate::__cpi_client_accounts_deposit_native::*
Types
Struct Return
Fields
Functions
Function initialize
Function set_allocator
Function set_owner
Function deposit_native
Function deposit_token
Function execute_transfer
Module accounts
An Anchor generated module, providing a set of structs
mirroring the structs deriving Accounts, where each field is
a Pubkey. This is useful for specifying accounts for a client.
Re-exports
Re-export crate::__client_accounts_execute_transfer::*
Re-export crate::__client_accounts_deposit_token::*
Re-export crate::__client_accounts_initialize::*
Re-export crate::__client_accounts_set_owner::*
Re-export crate::__client_accounts_set_allocator::*
Re-export crate::__client_accounts_deposit_native::*
Types
Struct RelayDepository
Relay depository account that stores configuration and state
This account is a PDA derived from the RELAY_DEPOSITORY_SEED and
contains the ownership and allocation information.
Fields
Struct UsedRequest
Account that tracks whether a transfer request has been used
This account is created for each transfer request to prevent replay attacks.
Fields
Struct Initialize
Accounts required for initializing the relay depository
Fields
Struct InitializeBumps
Fields
Struct SetAllocator
Accounts required for updating the allocator
Fields
Struct SetAllocatorBumps
Fields
Struct SetOwner
Accounts required for updating the owner
Fields
Struct SetOwnerBumps
Fields
Struct DepositNative
Accounts required for depositing native currency
Fields
Struct DepositNativeBumps
Fields
Struct DepositToken
Accounts required for depositing tokens
Fields
Struct DepositTokenBumps
Fields
Struct ExecuteTransfer
Attributes:
#[instruction(request: TransferRequest)]
Fields
Struct ExecuteTransferBumps
Fields
Struct TransferRequest
Structure representing a transfer request signed by the allocator
Fields
Implementations
Methods
-
Computes a hash of the serialized request for signature verification
Struct TransferExecutedEvent
Event emitted when a transfer is executed
Fields
Struct DepositEvent
Event emitted when a deposit is made
Fields
Enum CustomError
Attributes:
#[repr(u32)]
Variants
TransferRequestAlreadyUsed
Thrown when trying to execute a transfer request that has already been used
InvalidMint
Thrown when the provided mint does not match the expected mint
Unauthorized
Thrown when an account attempts an operation it is not authorized for
AllocatorSignerMismatch
Thrown when the signature’s signer doesn’t match the expected allocator
MessageMismatch
Thrown when the signed message doesn’t match the expected request
MalformedEd25519Data
Thrown when the Ed25519 signature data is malformed
MissingSignature
Thrown when a required signature is missing
SignatureExpired
Thrown when the signature has expired
InvalidRecipient
Thrown when the recipient doesn’t match the expected recipient
InvalidVaultTokenAccount
Thrown when the vault token account doesn’t match the expected address
InsufficientVaultBalance
Thrown when a transfer would leave the vault with insufficient balance for rent
Implementations
Methods
-
Gets the name of this [#enum_name].
Functions
Function check_id
Confirms that a given pubkey is equivalent to the program ID
Function id
Returns the program ID
Function id_const
Const version of ID
Function entry
The Anchor codegen exposes a programming model where a user defines
a set of methods inside of a #[program] module in a way similar
to writing RPC request handlers. The macro then generates a bunch of
code wrapping these user defined methods into something that can be
executed on Solana.
These methods fall into one category for now.
Global methods - regular methods inside of the #[program].
Care must be taken by the codegen to prevent collisions between
methods in these different namespaces. For this reason, Anchor uses
a variant of sighash to perform method dispatch, rather than
something like a simple enum variant discriminator.
The execution flow of the generated code can be roughly outlined:
- Start program via the entrypoint.
- Strip method identifier off the first 8 bytes of the instruction
data and invoke the identified method. The method identifier
is a variant of sighash. See docs.rs for
anchor_langfor details. - If the method identifier is an IDL identifier, execute the IDL instructions, which are a special set of hardcoded instructions baked into every Anchor program. Then exit.
- Otherwise, the method identifier is for a user defined
instruction, i.e., one of the methods in the user defined
#[program]module. Perform method dispatch, i.e., execute the big match statement mapping method identifier to method handler wrapper. - Run the method handler wrapper. This wraps the code the user actually wrote, deserializing the accounts, constructing the context, invoking the user’s code, and finally running the exit routine, which typically persists account changes.
entry function here, defines the standard entry to a Solana
program, where execution begins.
Function get_transfer_fee
Calculates the transfer fee for a token
Determines the fee amount for the given mint and transfer amount,
taking into account the token extension for transfer fees if present.
Parameters
mint_account- The mint account of the tokenpre_fee_amount- The amount to transfer before fees
Returns
- The calculated fee amount
Constants and Statics
Static ID
The static program ID
Constant ID_CONST
Const version of ID