@@ -671,7 +671,9 @@ export namespace TokenTransfer {
671
671
) ,
672
672
) ;
673
673
674
- // The expected destination gas can be pulled from the destination token bridge
674
+ // TODO: consider moving these solana specific checks to its protocol implementation
675
+ const solanaMinBalanceForRentExemptAccount = 890880n ;
676
+
675
677
let destinationNativeGas = 0n ;
676
678
if ( transfer . nativeGas ) {
677
679
const dtb = await dstChain . getAutomaticTokenBridge ( ) ;
@@ -692,12 +694,34 @@ export namespace TokenTransfer {
692
694
) } >${ amount . fmt ( maxNativeAmountIn , dstDecimals ) } `,
693
695
) ;
694
696
697
+ // when native gas is requested on solana, the amount must be at least the rent-exempt amount
698
+ // or the transaction could fail if the account does not have enough lamports
699
+ if ( dstChain . chain === "Solana" && _destinationNativeGas < solanaMinBalanceForRentExemptAccount ) {
700
+ throw new Error (
701
+ `Native gas amount must be at least ${ solanaMinBalanceForRentExemptAccount } lamports` ,
702
+ ) ;
703
+ }
704
+
695
705
destinationNativeGas = _destinationNativeGas ;
696
706
}
697
707
698
708
const destAmountLessFee =
699
709
amount . units ( dstAmountReceivable ) - dstNativeGasAmountRequested - amount . units ( feeAmountDest ) ;
700
710
711
+ // when sending wsol to solana, the amount must be at least the rent-exempt amount
712
+ // or the transaction could fail if the account does not have enough lamports
713
+ if ( dstToken . chain === "Solana" ) {
714
+ const nativeWrappedTokenId = await dstChain . getNativeWrappedTokenId ( ) ;
715
+ if (
716
+ dstToken . address === nativeWrappedTokenId . address &&
717
+ destAmountLessFee < solanaMinBalanceForRentExemptAccount
718
+ ) {
719
+ throw new Error (
720
+ `Destination amount must be at least ${ solanaMinBalanceForRentExemptAccount } lamports` ,
721
+ ) ;
722
+ }
723
+ }
724
+
701
725
return {
702
726
sourceToken : {
703
727
token : srcToken ,
0 commit comments