diff --git a/cross-chain/solana/programs/tbtc/src/event.rs b/cross-chain/solana/programs/tbtc/src/event.rs index 6a385a50a..341f6156e 100644 --- a/cross-chain/solana/programs/tbtc/src/event.rs +++ b/cross-chain/solana/programs/tbtc/src/event.rs @@ -18,4 +18,4 @@ pub struct GuardianAdded { #[event] pub struct GuardianRemoved { pub guardian: Pubkey, -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs index 81453a5dc..d36c49a9c 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs @@ -14,7 +14,7 @@ pub struct Initialize<'info> { seeds = [SEED_PREFIX_TBTC_MINT], bump, payer = authority, - mint::decimals = 9, + mint::decimals = 8, mint::authority = config, )] mint: Account<'info, token::Mint>, diff --git a/cross-chain/solana/programs/wormhole-gateway/src/error.rs b/cross-chain/solana/programs/wormhole-gateway/src/error.rs index f1ced8941..a607e79b8 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/error.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/error.rs @@ -17,9 +17,6 @@ pub enum WormholeGatewayError { #[msg("Amount must not be 0.")] ZeroAmount = 0x50, - #[msg("Amount too low to bridge.")] - TruncatedZeroAmount = 0x60, - #[msg("Token Bridge transfer already redeemed.")] TransferAlreadyRedeemed = 0x70, diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/gateway.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/gateway.rs index acbd4346c..13fac606f 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/gateway.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/gateway.rs @@ -124,9 +124,11 @@ pub fn send_tbtc_gateway(ctx: Context, args: SendTbtcGatewayArg let token_bridge_transfer_authority = &ctx.accounts.token_bridge_transfer_authority; let token_program = &ctx.accounts.token_program; + let gateway = ctx.accounts.gateway_info.address; + // Prepare for wrapped tBTC transfer (this method also truncates the amount to prevent having to // handle dust since tBTC has >8 decimals). - let amount = super::burn_and_prepare_transfer( + super::burn_and_prepare_transfer( super::PrepareTransfer { custodian: &mut ctx.accounts.custodian, tbtc_mint: &ctx.accounts.tbtc_mint, @@ -137,18 +139,12 @@ pub fn send_tbtc_gateway(ctx: Context, args: SendTbtcGatewayArg token_program, }, amount, - )?; - - let gateway = ctx.accounts.gateway_info.address; - - emit!(crate::event::WormholeTbtcSent { - amount, recipient_chain, - gateway, + Some(gateway), recipient, - arbiter_fee: Default::default(), - nonce - }); + None, // arbiter_fee + nonce, + )?; let custodian = &ctx.accounts.custodian; diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/mod.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/mod.rs index 5996e879b..f7bfc1e3f 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/mod.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/mod.rs @@ -37,7 +37,15 @@ pub struct PrepareTransfer<'ctx, 'info> { token_program: &'ctx Program<'info, token::Token>, } -pub fn burn_and_prepare_transfer(prepare_transfer: PrepareTransfer, amount: u64) -> Result { +pub fn burn_and_prepare_transfer( + prepare_transfer: PrepareTransfer, + amount: u64, + recipient_chain: u16, + gateway: Option<[u8; 32]>, + recipient: [u8; 32], + arbiter_fee: Option, + nonce: u32, +) -> Result<()> { let PrepareTransfer { custodian, tbtc_mint, @@ -48,13 +56,10 @@ pub fn burn_and_prepare_transfer(prepare_transfer: PrepareTransfer, amount: u64) token_program, } = prepare_transfer; - let truncated = 10 * (amount / 10); - require_gt!(truncated, 0, WormholeGatewayError::TruncatedZeroAmount); - // Account for burning tBTC. custodian .minted_amount - .checked_sub(truncated) + .checked_sub(amount) .ok_or(WormholeGatewayError::MintedAmountUnderflow)?; // Burn TBTC mint. @@ -70,6 +75,15 @@ pub fn burn_and_prepare_transfer(prepare_transfer: PrepareTransfer, amount: u64) amount, )?; + emit!(crate::event::WormholeTbtcSent { + amount, + recipient_chain, + gateway: gateway.unwrap_or_default(), + recipient, + arbiter_fee: arbiter_fee.unwrap_or_default(), + nonce + }); + // Delegate authority to Token Bridge's transfer authority. token::approve( CpiContext::new_with_signer( @@ -81,8 +95,6 @@ pub fn burn_and_prepare_transfer(prepare_transfer: PrepareTransfer, amount: u64) }, &[&[Custodian::SEED_PREFIX, &[custodian.bump]]], ), - truncated, - )?; - - Ok(truncated) + amount, + ) } diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/wrapped.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/wrapped.rs index 0be9a0207..71bacbf57 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/wrapped.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/wrapped.rs @@ -116,7 +116,7 @@ pub fn send_tbtc_wrapped(ctx: Context, args: SendTbtcWrappedArg let token_program = &ctx.accounts.token_program; // Prepare for wrapped tBTC transfer. - let amount = super::burn_and_prepare_transfer( + super::burn_and_prepare_transfer( super::PrepareTransfer { custodian: &mut ctx.accounts.custodian, tbtc_mint: &ctx.accounts.tbtc_mint, @@ -127,16 +127,12 @@ pub fn send_tbtc_wrapped(ctx: Context, args: SendTbtcWrappedArg token_program, }, amount, - )?; - - emit!(crate::event::WormholeTbtcSent { - amount, recipient_chain, - gateway: Default::default(), + None, // gateway recipient, - arbiter_fee, - nonce - }); + Some(arbiter_fee), + nonce, + )?; let custodian = &ctx.accounts.custodian;