Skip to content

Commit

Permalink
Document token router
Browse files Browse the repository at this point in the history
  • Loading branch information
deekerno committed Mar 20, 2024
1 parent 6ffef08 commit f95aa7b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
14 changes: 14 additions & 0 deletions solana/programs/token-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,42 @@ const PREPARED_CUSTODY_TOKEN_SEED_PREFIX: &[u8] = b"prepared-custody";
pub mod token_router {
use super::*;

/// Prepare market order for the transfer of funds.
///
/// This instruction will validate arguments before transferring the desired
/// amount to the custody token account.
pub fn prepare_market_order(
ctx: Context<PrepareMarketOrder>,
args: PrepareMarketOrderArgs,
) -> Result<()> {
processor::prepare_market_order(ctx, args)
}

/// Close prepared order.
///
/// This instruction transfers the funds in the prepared custody token account to
/// the refund token account. It then closes the prepared custody token account.
pub fn close_prepared_order(ctx: Context<ClosePreparedOrder>) -> Result<()> {
processor::close_prepared_order(ctx)
}

/// Place market order through CCTP.
pub fn place_market_order_cctp(ctx: Context<PlaceMarketOrderCctp>) -> Result<()> {
processor::place_market_order_cctp(ctx)
}

/// Redeem fill by reconciling CCTP messages to mint tokens for the [`mint_recipient`] token account.
pub fn redeem_cctp_fill(ctx: Context<RedeemCctpFill>, args: CctpMessageArgs) -> Result<()> {
processor::redeem_cctp_fill(ctx, args)
}

/// Redeem fast fill by transferring funds from the payer to the prepared fill token account.
pub fn redeem_fast_fill(ctx: Context<RedeemFastFill>) -> Result<()> {
processor::redeem_fast_fill(ctx)
}

/// Consume prepared fill by transferring funds from the prepared custody token
/// account to the destination token account.
pub fn consume_prepared_fill(ctx: Context<ConsumePreparedFill>) -> Result<()> {
processor::consume_prepared_fill(ctx)
}
Expand Down Expand Up @@ -211,6 +224,7 @@ pub mod token_router {
// processor::complete_wrapped_transfer_with_relay(ctx, _vaa_hash)
// }

/// Authorize upgrade of token router program.
pub fn authorize_upgrade(ctx: Context<AuthorizeUpgrade>) -> Result<()> {
processor::authorize_upgrade(ctx)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ pub struct ClosePreparedOrder<'info> {
token_program: Program<'info, token::Token>,
}

/// TODO: add docstring
/// Close prepared order.
///
/// This instruction transfers the funds in the prepared custody token account to
/// the refund token account. It then closes the prepared custody token account.
pub fn close_prepared_order(ctx: Context<ClosePreparedOrder>) -> Result<()> {
token::transfer(
CpiContext::new_with_signer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ pub struct ConsumePreparedFill<'info> {
token_program: Program<'info, token::Token>,
}

/// TODO: add docstring
/// Consume prepared fill by transferring funds from the prepared custody token
/// account to the destination token account.
pub fn consume_prepared_fill(ctx: Context<ConsumePreparedFill>) -> Result<()> {
token::transfer(
CpiContext::new_with_signer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub struct PrepareMarketOrderArgs {
pub redeemer_message: Vec<u8>,
}

/// TODO: add docstring
/// Prepare a market order for the transfer of funds.
pub fn prepare_market_order(
ctx: Context<PrepareMarketOrder>,
args: PrepareMarketOrderArgs,
Expand Down

0 comments on commit f95aa7b

Please sign in to comment.