@@ -101,14 +101,27 @@ func (s *transactionServer) CanWithdrawToAccount(ctx context.Context, req *trans
101101 return nil , status .Error (codes .Internal , "" )
102102 }
103103
104- if ! isOnCurve && ! isVmDepositPda {
104+ var isVmSwapPda bool
105+ if ! isVmDepositPda {
106+ timelockRecord , err = s .data .GetTimelockBySwapPda (ctx , accountToCheck .PublicKey ().ToBase58 ())
107+ switch err {
108+ case nil :
109+ isVmSwapPda = true
110+ case timelock .ErrTimelockNotFound :
111+ default :
112+ log .WithError (err ).Warn ("failure checking timelock db as a swap pda account" )
113+ return nil , status .Error (codes .Internal , "" )
114+ }
115+ }
116+
117+ if ! isOnCurve && ! isVmDepositPda && ! isVmSwapPda {
105118 return & transactionpb.CanWithdrawToAccountResponse {
106119 IsValidPaymentDestination : false ,
107120 AccountType : transactionpb .CanWithdrawToAccountResponse_Unknown ,
108121 }, nil
109122 }
110123
111- if isVmDepositPda {
124+ if isVmDepositPda || isVmSwapPda {
112125 accountInfoRecord , err := s .data .GetAccountInfoByTokenAddress (ctx , timelockRecord .VaultAddress )
113126 if err != nil {
114127 log .WithError (err ).Warn ("failure checking account info db" )
@@ -137,16 +150,20 @@ func (s *transactionServer) CanWithdrawToAccount(ctx context.Context, req *trans
137150 AccountType : transactionpb .CanWithdrawToAccountResponse_OwnerAccount ,
138151 }, nil
139152 case token .ErrAccountNotFound , solana .ErrNoAccountInfo :
140- // ATA doesn't exist, and we won't be subsidizing it. Let the client know
141- // they require a fee.
153+ // ATA doesn't exist, and we won't be subsidizing it unless it's a VM Swap PDA.
154+ // Let the client know they require a fee.
155+ var feeAmount * transactionpb.ExchangeDataWithoutRate
156+ if ! isVmSwapPda {
157+ feeAmount = & transactionpb.ExchangeDataWithoutRate {
158+ Currency : string (currency_lib .USD ),
159+ NativeAmount : s .conf .createOnSendWithdrawalUsdFee .Get (ctx ),
160+ }
161+ }
142162 return & transactionpb.CanWithdrawToAccountResponse {
143163 IsValidPaymentDestination : true ,
144164 AccountType : transactionpb .CanWithdrawToAccountResponse_OwnerAccount ,
145165 RequiresInitialization : true ,
146- FeeAmount : & transactionpb.ExchangeDataWithoutRate {
147- Currency : string (currency_lib .USD ),
148- NativeAmount : s .conf .createOnSendWithdrawalUsdFee .Get (ctx ),
149- },
166+ FeeAmount : feeAmount ,
150167 }, nil
151168 case token .ErrInvalidTokenAccount :
152169 return & transactionpb.CanWithdrawToAccountResponse {
0 commit comments