From 3086ee66f402baf074289873a6a514073c02c403 Mon Sep 17 00:00:00 2001 From: bartosz-lipinski <264380+bartosz-lipinski@users.noreply.github.com> Date: Sat, 21 Nov 2020 21:06:54 -0600 Subject: [PATCH] feat: repay instruction --- src/models/lending/repay.ts | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/models/lending/repay.ts b/src/models/lending/repay.ts index a744a12..afdfb9d 100644 --- a/src/models/lending/repay.ts +++ b/src/models/lending/repay.ts @@ -22,11 +22,15 @@ import * as Layout from "./../../utils/layout"; /// 11 `[]` Token program id export const repayInstruction = ( liquidityAmount: number | BN, - from: PublicKey, // Collateral input SPL Token account. $authority can transfer $liquidity_amount - to: PublicKey, // Liquidity output SPL Token account, - reserveAccount: PublicKey, - collateralMint: PublicKey, - reserveSupply: PublicKey, + from: PublicKey, // Liquidity input SPL Token account. $authority can transfer $liquidity_amount + to: PublicKey, // Collateral output SPL Token account, + repayReserveAccount: PublicKey, + repayReserveLiquiditySupply: PublicKey, + withdrawReserve: PublicKey, + withdrawReserveCollateralSupply: PublicKey, + obligation: PublicKey, + obligationMint: PublicKey, + obligationInput: PublicKey, authority: PublicKey ): TransactionInstruction => { const dataLayout = BufferLayout.struct([ @@ -46,9 +50,16 @@ export const repayInstruction = ( const keys = [ { pubkey: from, isSigner: false, isWritable: true }, { pubkey: to, isSigner: false, isWritable: true }, - { pubkey: reserveAccount, isSigner: false, isWritable: true }, - { pubkey: collateralMint, isSigner: false, isWritable: true }, - { pubkey: reserveSupply, isSigner: false, isWritable: true }, + + { pubkey: repayReserveAccount, isSigner: false, isWritable: true }, + { pubkey: repayReserveLiquiditySupply, isSigner: false, isWritable: true }, + + { pubkey: withdrawReserve, isSigner: false, isWritable: false }, + { pubkey: withdrawReserveCollateralSupply, isSigner: false, isWritable: true }, + + { pubkey: obligation, isSigner: false, isWritable: true }, + { pubkey: obligationMint, isSigner: false, isWritable: true }, + { pubkey: obligationInput, isSigner: false, isWritable: true }, { pubkey: authority, isSigner: false, isWritable: false }, { pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false },