File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -6321,7 +6321,6 @@ export class DriftClient {
63216321 const inMarket = this . getSpotMarketAccount ( inMarketIndex ) ;
63226322
63236323 const isExactOut = swapMode === 'ExactOut' ;
6324- const exactOutBufferedAmountIn = amount . muln ( 1001 ) . divn ( 1000 ) ; // Add 10bp buffer
63256324
63266325 const preInstructions : TransactionInstruction [ ] = [ ] ;
63276326
@@ -6377,11 +6376,24 @@ export class DriftClient {
63776376 }
63786377 }
63796378
6379+ let amountInForBeginSwap : BN ;
6380+ if ( isExactOut ) {
6381+ if ( quote || v6 ?. quote ) {
6382+ amountInForBeginSwap = v6 ?. quote
6383+ ? new BN ( v6 . quote . inAmount )
6384+ : new BN ( quote ! . inAmount ) ;
6385+ } else {
6386+ amountInForBeginSwap = amount . muln ( 1001 ) . divn ( 1000 ) ;
6387+ }
6388+ } else {
6389+ amountInForBeginSwap = amount ;
6390+ }
6391+
63806392 // Get drift swap instructions for begin and end
63816393 const { beginSwapIx, endSwapIx } = await this . getSwapIx ( {
63826394 outMarketIndex,
63836395 inMarketIndex,
6384- amountIn : isExactOut ? exactOutBufferedAmountIn : amount ,
6396+ amountIn : amountInForBeginSwap ,
63856397 inTokenAccount : finalInAssociatedTokenAccount ,
63866398 outTokenAccount : finalOutAssociatedTokenAccount ,
63876399 reduceOnly,
You can’t perform that action at this time.
0 commit comments