Skip to content

Commit

Permalink
Refactor lrtsSellToRepay
Browse files Browse the repository at this point in the history
  • Loading branch information
sablevsky committed Dec 11, 2024
1 parent b1ebf6d commit 85f4b8b
Showing 1 changed file with 6 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ export const createLrtsSellToRepayTokenLoanTxnData: CreateSellToRepayTokenLoanTx
const jupiterQuoteApi = createJupiterApiClient()

const priceQuote = await jupiterQuoteApi.quoteGet({
inputMint: WSOL_ADDRESS,
outputMint: SSOL_MINT.toBase58(),
inputMint: SSOL_MINT.toBase58(),
outputMint: WSOL_ADDRESS,
amount: caclulateBorrowTokenLoanValue(loan).toNumber(),
slippageBps,
computeAutoSlippage: true,
swapMode: 'ExactIn',
swapMode: 'ExactOut',
onlyDirectRoutes: true,
asLegacyTransaction: false,
minimizeSlippage: false,
Expand All @@ -69,31 +69,17 @@ export const createLrtsSellToRepayTokenLoanTxnData: CreateSellToRepayTokenLoanTx
)

const burnInstructions = getBurnLrtsInstructions({
lrtsAmount: new BN(priceQuote.outAmount),
lrtsAmount: new BN(priceQuote.inAmount),
walletPublicKey: walletAndConnection.wallet.publicKey,
undelegateStake: unstakedSolAresteaVaulBalance.lt(new BN(priceQuote.outAmount)),
undelegateStake: unstakedSolAresteaVaulBalance.lt(new BN(priceQuote.inAmount)),
})

instructions.push(...burnInstructions)

const swapQuote = await jupiterQuoteApi.quoteGet({
inputMint: SSOL_MINT.toBase58(),
outputMint: WSOL_ADDRESS,
amount: parseFloat(priceQuote.outAmount),
slippageBps,
computeAutoSlippage: true,
swapMode: 'ExactIn',
onlyDirectRoutes: true,
asLegacyTransaction: false,
maxAccounts: 64,
minimizeSlippage: false,
dexes: ['Whirlpool'],
})

const { instructions: jupSwapInstructions, lookupTables: jupSwapLookupTables } =
await getJupSwapIxns({
jupiterQuoteApi,
quote: swapQuote,
quote: priceQuote,
walletPublicKey: walletAndConnection.wallet.publicKey,
})

Expand Down

0 comments on commit 85f4b8b

Please sign in to comment.