@kamino-finance/klend-sdk 5.0.3 → 5.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/manager.d.ts +38 -4
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +98 -4
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +2 -25
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/vault.d.ts +12 -8
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +94 -66
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +14 -0
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/Reserve.d.ts +3 -3
- package/dist/idl_codegen_kamino_vault/accounts/Reserve.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/Reserve.js +22 -18
- package/dist/idl_codegen_kamino_vault/accounts/Reserve.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +45 -15
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +101 -39
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/index.d.ts +4 -4
- package/dist/idl_codegen_kamino_vault/accounts/index.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/index.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/anchor.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/anchor.js +162 -162
- package/dist/idl_codegen_kamino_vault/errors/anchor.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts +144 -32
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.js +305 -109
- package/dist/idl_codegen_kamino_vault/errors/custom.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/index.d.ts +3 -3
- package/dist/idl_codegen_kamino_vault/errors/index.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/index.js +7 -2
- package/dist/idl_codegen_kamino_vault/errors/index.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts +4 -2
- package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/deposit.js +3 -1
- package/dist/idl_codegen_kamino_vault/instructions/deposit.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts +13 -0
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js +47 -0
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/index.d.ts +18 -10
- package/dist/idl_codegen_kamino_vault/instructions/index.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/index.js +9 -1
- package/dist/idl_codegen_kamino_vault/instructions/index.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts +2 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/invest.d.ts +6 -2
- package/dist/idl_codegen_kamino_vault/instructions/invest.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/invest.js +9 -1
- package/dist/idl_codegen_kamino_vault/instructions/invest.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateAdmin.d.ts +7 -0
- package/dist/idl_codegen_kamino_vault/instructions/updateAdmin.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/updateAdmin.js +16 -0
- package/dist/idl_codegen_kamino_vault/instructions/updateAdmin.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts +2 -2
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts +14 -0
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js +52 -0
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts +4 -2
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.js +8 -2
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts +23 -0
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js +51 -0
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/programId.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/programId.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/programId.js +1 -1
- package/dist/idl_codegen_kamino_vault/programId.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.d.ts +2 -2
- package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.js +4 -1
- package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.js +1 -1
- package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/CurvePoint.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/types/CurvePoint.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/CurvePoint.js +1 -1
- package/dist/idl_codegen_kamino_vault/types/CurvePoint.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/LastUpdate.d.ts +2 -2
- package/dist/idl_codegen_kamino_vault/types/LastUpdate.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/LastUpdate.js +6 -1
- package/dist/idl_codegen_kamino_vault/types/LastUpdate.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.d.ts +2 -2
- package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.js +1 -1
- package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/PythConfiguration.d.ts +2 -2
- package/dist/idl_codegen_kamino_vault/types/PythConfiguration.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/PythConfiguration.js +1 -1
- package/dist/idl_codegen_kamino_vault/types/PythConfiguration.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.d.ts +3 -3
- package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.js +5 -5
- package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts +27 -24
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js +59 -53
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveFees.d.ts +2 -2
- package/dist/idl_codegen_kamino_vault/types/ReserveFees.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveFees.js +5 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveFees.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.d.ts +11 -3
- package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.js +25 -17
- package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.d.ts +2 -2
- package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.js +3 -3
- package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.d.ts +2 -2
- package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.js +1 -1
- package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/TokenInfo.d.ts +3 -3
- package/dist/idl_codegen_kamino_vault/types/TokenInfo.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/TokenInfo.js +11 -11
- package/dist/idl_codegen_kamino_vault/types/TokenInfo.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.d.ts +18 -8
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.js +27 -13
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts +110 -0
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js +242 -0
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/index.d.ts +34 -30
- package/dist/idl_codegen_kamino_vault/types/index.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/index.js +26 -1
- package/dist/idl_codegen_kamino_vault/types/index.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +6 -0
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/leverage/calcs.d.ts +28 -1
- package/dist/leverage/calcs.d.ts.map +1 -1
- package/dist/leverage/calcs.js +204 -8
- package/dist/leverage/calcs.js.map +1 -1
- package/dist/leverage/index.d.ts +1 -0
- package/dist/leverage/index.d.ts.map +1 -1
- package/dist/leverage/index.js +1 -0
- package/dist/leverage/index.js.map +1 -1
- package/dist/leverage/operations.d.ts +14 -241
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +508 -776
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/types.d.ts +173 -0
- package/dist/leverage/types.d.ts.map +1 -0
- package/dist/leverage/types.js +3 -0
- package/dist/leverage/types.js.map +1 -0
- package/dist/leverage/utils.d.ts +5 -5
- package/dist/leverage/utils.d.ts.map +1 -1
- package/dist/leverage/utils.js +68 -33
- package/dist/leverage/utils.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +2 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/fuzz.d.ts +3 -0
- package/dist/utils/fuzz.d.ts.map +1 -0
- package/dist/utils/fuzz.js +11 -0
- package/dist/utils/fuzz.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/rpc.d.ts.map +1 -1
- package/dist/utils/rpc.js +2 -1
- package/dist/utils/rpc.js.map +1 -1
- package/package.json +2 -1
- package/src/classes/manager.ts +122 -4
- package/src/classes/market.ts +1 -1
- package/src/classes/vault.ts +123 -49
- package/src/client_kamino_manager.ts +18 -0
- package/src/idl_codegen_kamino_vault/accounts/Reserve.ts +132 -105
- package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +217 -124
- package/src/idl_codegen_kamino_vault/accounts/index.ts +4 -4
- package/src/idl_codegen_kamino_vault/errors/anchor.ts +335 -326
- package/src/idl_codegen_kamino_vault/errors/custom.ts +353 -157
- package/src/idl_codegen_kamino_vault/errors/index.ts +35 -22
- package/src/idl_codegen_kamino_vault/instructions/deposit.ts +33 -25
- package/src/idl_codegen_kamino_vault/instructions/giveUpPendingFees.ts +40 -0
- package/src/idl_codegen_kamino_vault/instructions/index.ts +27 -10
- package/src/idl_codegen_kamino_vault/instructions/initVault.ts +25 -20
- package/src/idl_codegen_kamino_vault/instructions/invest.ts +40 -25
- package/src/idl_codegen_kamino_vault/instructions/updateAdmin.ts +24 -0
- package/src/idl_codegen_kamino_vault/instructions/updateReserveAllocation.ts +24 -24
- package/src/idl_codegen_kamino_vault/instructions/updateVaultConfig.ts +49 -0
- package/src/idl_codegen_kamino_vault/instructions/withdraw.ts +45 -33
- package/src/idl_codegen_kamino_vault/instructions/withdrawPendingFees.ts +75 -0
- package/src/idl_codegen_kamino_vault/programId.ts +5 -3
- package/src/idl_codegen_kamino_vault/types/BigFractionBytes.ts +24 -18
- package/src/idl_codegen_kamino_vault/types/BorrowRateCurve.ts +21 -16
- package/src/idl_codegen_kamino_vault/types/CurvePoint.ts +21 -18
- package/src/idl_codegen_kamino_vault/types/LastUpdate.ts +32 -27
- package/src/idl_codegen_kamino_vault/types/PriceHeuristic.ts +25 -22
- package/src/idl_codegen_kamino_vault/types/PythConfiguration.ts +14 -14
- package/src/idl_codegen_kamino_vault/types/ReserveCollateral.ts +35 -35
- package/src/idl_codegen_kamino_vault/types/ReserveConfig.ts +232 -191
- package/src/idl_codegen_kamino_vault/types/ReserveFees.ts +27 -23
- package/src/idl_codegen_kamino_vault/types/ReserveLiquidity.ts +116 -98
- package/src/idl_codegen_kamino_vault/types/ScopeConfiguration.ts +25 -25
- package/src/idl_codegen_kamino_vault/types/SwitchboardConfiguration.ts +21 -18
- package/src/idl_codegen_kamino_vault/types/TokenInfo.ts +92 -74
- package/src/idl_codegen_kamino_vault/types/VaultAllocation.ts +67 -49
- package/src/idl_codegen_kamino_vault/types/VaultConfigField.ts +270 -0
- package/src/idl_codegen_kamino_vault/types/index.ts +77 -30
- package/src/lending_operations/repay_with_collateral_operations.ts +2 -0
- package/src/leverage/calcs.ts +315 -8
- package/src/leverage/index.ts +1 -0
- package/src/leverage/operations.ts +1079 -1331
- package/src/leverage/types.ts +211 -0
- package/src/leverage/utils.ts +103 -64
- package/src/utils/constants.ts +2 -0
- package/src/utils/fuzz.ts +5 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/rpc.ts +2 -1
|
@@ -1,49 +1,62 @@
|
|
|
1
|
-
import { PublicKey } from
|
|
2
|
-
import { PROGRAM_ID } from
|
|
3
|
-
import * as anchor from
|
|
4
|
-
import * as custom from
|
|
5
|
-
|
|
6
|
-
export function fromCode(
|
|
7
|
-
|
|
1
|
+
import { PublicKey } from "@solana/web3.js"
|
|
2
|
+
import { PROGRAM_ID } from "../programId"
|
|
3
|
+
import * as anchor from "./anchor"
|
|
4
|
+
import * as custom from "./custom"
|
|
5
|
+
|
|
6
|
+
export function fromCode(
|
|
7
|
+
code: number,
|
|
8
|
+
logs?: string[]
|
|
9
|
+
): custom.CustomError | anchor.AnchorError | null {
|
|
10
|
+
return code >= 6000
|
|
11
|
+
? custom.fromCode(code, logs)
|
|
12
|
+
: anchor.fromCode(code, logs)
|
|
8
13
|
}
|
|
9
14
|
|
|
10
|
-
function hasOwnProperty<X extends object, Y extends PropertyKey>(
|
|
11
|
-
|
|
15
|
+
function hasOwnProperty<X extends object, Y extends PropertyKey>(
|
|
16
|
+
obj: X,
|
|
17
|
+
prop: Y
|
|
18
|
+
): obj is X & Record<Y, unknown> {
|
|
19
|
+
return Object.hasOwnProperty.call(obj, prop)
|
|
12
20
|
}
|
|
13
21
|
|
|
14
|
-
const errorRe = /Program (\w+) failed: custom program error: (\w+)
|
|
22
|
+
const errorRe = /Program (\w+) failed: custom program error: (\w+)/
|
|
15
23
|
|
|
16
24
|
export function fromTxError(
|
|
17
25
|
err: unknown,
|
|
18
26
|
programId: PublicKey = PROGRAM_ID
|
|
19
27
|
): custom.CustomError | anchor.AnchorError | null {
|
|
20
|
-
if (
|
|
21
|
-
|
|
28
|
+
if (
|
|
29
|
+
typeof err !== "object" ||
|
|
30
|
+
err === null ||
|
|
31
|
+
!hasOwnProperty(err, "logs") ||
|
|
32
|
+
!Array.isArray(err.logs)
|
|
33
|
+
) {
|
|
34
|
+
return null
|
|
22
35
|
}
|
|
23
36
|
|
|
24
|
-
let firstMatch: RegExpExecArray | null = null
|
|
37
|
+
let firstMatch: RegExpExecArray | null = null
|
|
25
38
|
for (const logLine of err.logs) {
|
|
26
|
-
firstMatch = errorRe.exec(logLine)
|
|
39
|
+
firstMatch = errorRe.exec(logLine)
|
|
27
40
|
if (firstMatch !== null) {
|
|
28
|
-
break
|
|
41
|
+
break
|
|
29
42
|
}
|
|
30
43
|
}
|
|
31
44
|
|
|
32
45
|
if (firstMatch === null) {
|
|
33
|
-
return null
|
|
46
|
+
return null
|
|
34
47
|
}
|
|
35
48
|
|
|
36
|
-
const [programIdRaw, codeRaw] = firstMatch.slice(1)
|
|
49
|
+
const [programIdRaw, codeRaw] = firstMatch.slice(1)
|
|
37
50
|
if (programIdRaw !== programId.toString()) {
|
|
38
|
-
return null
|
|
51
|
+
return null
|
|
39
52
|
}
|
|
40
53
|
|
|
41
|
-
let errorCode: number
|
|
54
|
+
let errorCode: number
|
|
42
55
|
try {
|
|
43
|
-
errorCode = parseInt(codeRaw, 16)
|
|
56
|
+
errorCode = parseInt(codeRaw, 16)
|
|
44
57
|
} catch (parseErr) {
|
|
45
|
-
return null
|
|
58
|
+
return null
|
|
46
59
|
}
|
|
47
60
|
|
|
48
|
-
return fromCode(errorCode, err.logs)
|
|
61
|
+
return fromCode(errorCode, err.logs)
|
|
49
62
|
}
|
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
import { TransactionInstruction, PublicKey, AccountMeta } from
|
|
2
|
-
import BN from
|
|
3
|
-
import * as borsh from
|
|
4
|
-
import * as types from
|
|
5
|
-
import { PROGRAM_ID } from
|
|
1
|
+
import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from "../programId"
|
|
6
6
|
|
|
7
7
|
export interface DepositArgs {
|
|
8
|
-
maxAmount: BN
|
|
8
|
+
maxAmount: BN
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface DepositAccounts {
|
|
12
|
-
user: PublicKey
|
|
13
|
-
vaultState: PublicKey
|
|
14
|
-
tokenVault: PublicKey
|
|
15
|
-
tokenMint: PublicKey
|
|
16
|
-
baseVaultAuthority: PublicKey
|
|
17
|
-
sharesMint: PublicKey
|
|
18
|
-
tokenAta: PublicKey
|
|
19
|
-
userSharesAta: PublicKey
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
user: PublicKey
|
|
13
|
+
vaultState: PublicKey
|
|
14
|
+
tokenVault: PublicKey
|
|
15
|
+
tokenMint: PublicKey
|
|
16
|
+
baseVaultAuthority: PublicKey
|
|
17
|
+
sharesMint: PublicKey
|
|
18
|
+
tokenAta: PublicKey
|
|
19
|
+
userSharesAta: PublicKey
|
|
20
|
+
klendProgram: PublicKey
|
|
21
|
+
tokenProgram: PublicKey
|
|
22
|
+
sharesTokenProgram: PublicKey
|
|
23
|
+
instructionSysvarAccount: PublicKey
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
export const layout = borsh.struct([borsh.u64(
|
|
26
|
+
export const layout = borsh.struct([borsh.u64("maxAmount")])
|
|
25
27
|
|
|
26
|
-
export function deposit(
|
|
28
|
+
export function deposit(
|
|
29
|
+
args: DepositArgs,
|
|
30
|
+
accounts: DepositAccounts,
|
|
31
|
+
programId: PublicKey = PROGRAM_ID
|
|
32
|
+
) {
|
|
27
33
|
const keys: Array<AccountMeta> = [
|
|
28
34
|
{ pubkey: accounts.user, isSigner: true, isWritable: true },
|
|
29
35
|
{ pubkey: accounts.vaultState, isSigner: false, isWritable: true },
|
|
@@ -33,22 +39,24 @@ export function deposit(args: DepositArgs, accounts: DepositAccounts, programId:
|
|
|
33
39
|
{ pubkey: accounts.sharesMint, isSigner: false, isWritable: true },
|
|
34
40
|
{ pubkey: accounts.tokenAta, isSigner: false, isWritable: true },
|
|
35
41
|
{ pubkey: accounts.userSharesAta, isSigner: false, isWritable: true },
|
|
42
|
+
{ pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
|
|
36
43
|
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
44
|
+
{ pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
|
|
37
45
|
{
|
|
38
46
|
pubkey: accounts.instructionSysvarAccount,
|
|
39
47
|
isSigner: false,
|
|
40
48
|
isWritable: false,
|
|
41
49
|
},
|
|
42
|
-
]
|
|
43
|
-
const identifier = Buffer.from([242, 35, 198, 137, 82, 225, 242, 182])
|
|
44
|
-
const buffer = Buffer.alloc(1000)
|
|
50
|
+
]
|
|
51
|
+
const identifier = Buffer.from([242, 35, 198, 137, 82, 225, 242, 182])
|
|
52
|
+
const buffer = Buffer.alloc(1000)
|
|
45
53
|
const len = layout.encode(
|
|
46
54
|
{
|
|
47
55
|
maxAmount: args.maxAmount,
|
|
48
56
|
},
|
|
49
57
|
buffer
|
|
50
|
-
)
|
|
51
|
-
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
|
|
52
|
-
const ix = new TransactionInstruction({ keys, programId, data })
|
|
53
|
-
return ix
|
|
58
|
+
)
|
|
59
|
+
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
|
|
60
|
+
const ix = new TransactionInstruction({ keys, programId, data })
|
|
61
|
+
return ix
|
|
54
62
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from "../programId"
|
|
6
|
+
|
|
7
|
+
export interface GiveUpPendingFeesArgs {
|
|
8
|
+
maxAmountToGiveUp: BN
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface GiveUpPendingFeesAccounts {
|
|
12
|
+
adminAuthority: PublicKey
|
|
13
|
+
vaultState: PublicKey
|
|
14
|
+
klendProgram: PublicKey
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const layout = borsh.struct([borsh.u64("maxAmountToGiveUp")])
|
|
18
|
+
|
|
19
|
+
export function giveUpPendingFees(
|
|
20
|
+
args: GiveUpPendingFeesArgs,
|
|
21
|
+
accounts: GiveUpPendingFeesAccounts,
|
|
22
|
+
programId: PublicKey = PROGRAM_ID
|
|
23
|
+
) {
|
|
24
|
+
const keys: Array<AccountMeta> = [
|
|
25
|
+
{ pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
|
|
26
|
+
{ pubkey: accounts.vaultState, isSigner: false, isWritable: true },
|
|
27
|
+
{ pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
|
|
28
|
+
]
|
|
29
|
+
const identifier = Buffer.from([177, 200, 120, 134, 110, 217, 147, 81])
|
|
30
|
+
const buffer = Buffer.alloc(1000)
|
|
31
|
+
const len = layout.encode(
|
|
32
|
+
{
|
|
33
|
+
maxAmountToGiveUp: args.maxAmountToGiveUp,
|
|
34
|
+
},
|
|
35
|
+
buffer
|
|
36
|
+
)
|
|
37
|
+
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
|
|
38
|
+
const ix = new TransactionInstruction({ keys, programId, data })
|
|
39
|
+
return ix
|
|
40
|
+
}
|
|
@@ -1,10 +1,27 @@
|
|
|
1
|
-
export { initVault } from
|
|
2
|
-
export type { InitVaultAccounts } from
|
|
3
|
-
export { updateReserveAllocation } from
|
|
4
|
-
export type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
export {
|
|
10
|
-
export
|
|
1
|
+
export { initVault } from "./initVault"
|
|
2
|
+
export type { InitVaultAccounts } from "./initVault"
|
|
3
|
+
export { updateReserveAllocation } from "./updateReserveAllocation"
|
|
4
|
+
export type {
|
|
5
|
+
UpdateReserveAllocationArgs,
|
|
6
|
+
UpdateReserveAllocationAccounts,
|
|
7
|
+
} from "./updateReserveAllocation"
|
|
8
|
+
export { deposit } from "./deposit"
|
|
9
|
+
export type { DepositArgs, DepositAccounts } from "./deposit"
|
|
10
|
+
export { withdraw } from "./withdraw"
|
|
11
|
+
export type { WithdrawArgs, WithdrawAccounts } from "./withdraw"
|
|
12
|
+
export { invest } from "./invest"
|
|
13
|
+
export type { InvestAccounts } from "./invest"
|
|
14
|
+
export { updateVaultConfig } from "./updateVaultConfig"
|
|
15
|
+
export type {
|
|
16
|
+
UpdateVaultConfigArgs,
|
|
17
|
+
UpdateVaultConfigAccounts,
|
|
18
|
+
} from "./updateVaultConfig"
|
|
19
|
+
export { withdrawPendingFees } from "./withdrawPendingFees"
|
|
20
|
+
export type { WithdrawPendingFeesAccounts } from "./withdrawPendingFees"
|
|
21
|
+
export { updateAdmin } from "./updateAdmin"
|
|
22
|
+
export type { UpdateAdminAccounts } from "./updateAdmin"
|
|
23
|
+
export { giveUpPendingFees } from "./giveUpPendingFees"
|
|
24
|
+
export type {
|
|
25
|
+
GiveUpPendingFeesArgs,
|
|
26
|
+
GiveUpPendingFeesAccounts,
|
|
27
|
+
} from "./giveUpPendingFees"
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import { TransactionInstruction, PublicKey, AccountMeta } from
|
|
2
|
-
import BN from
|
|
3
|
-
import * as borsh from
|
|
4
|
-
import * as types from
|
|
5
|
-
import { PROGRAM_ID } from
|
|
1
|
+
import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from "../programId"
|
|
6
6
|
|
|
7
7
|
export interface InitVaultAccounts {
|
|
8
|
-
adminAuthority: PublicKey
|
|
9
|
-
vaultState: PublicKey
|
|
10
|
-
tokenMint: PublicKey
|
|
11
|
-
tokenVault: PublicKey
|
|
12
|
-
baseVaultAuthority: PublicKey
|
|
13
|
-
sharesMint: PublicKey
|
|
14
|
-
systemProgram: PublicKey
|
|
15
|
-
rent: PublicKey
|
|
16
|
-
tokenProgram: PublicKey
|
|
8
|
+
adminAuthority: PublicKey
|
|
9
|
+
vaultState: PublicKey
|
|
10
|
+
tokenMint: PublicKey
|
|
11
|
+
tokenVault: PublicKey
|
|
12
|
+
baseVaultAuthority: PublicKey
|
|
13
|
+
sharesMint: PublicKey
|
|
14
|
+
systemProgram: PublicKey
|
|
15
|
+
rent: PublicKey
|
|
16
|
+
tokenProgram: PublicKey
|
|
17
|
+
sharesTokenProgram: PublicKey
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
export function initVault(
|
|
20
|
+
export function initVault(
|
|
21
|
+
accounts: InitVaultAccounts,
|
|
22
|
+
programId: PublicKey = PROGRAM_ID
|
|
23
|
+
) {
|
|
20
24
|
const keys: Array<AccountMeta> = [
|
|
21
25
|
{ pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
|
|
22
26
|
{ pubkey: accounts.vaultState, isSigner: false, isWritable: true },
|
|
@@ -27,9 +31,10 @@ export function initVault(accounts: InitVaultAccounts, programId: PublicKey = PR
|
|
|
27
31
|
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
28
32
|
{ pubkey: accounts.rent, isSigner: false, isWritable: false },
|
|
29
33
|
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
34
|
+
{ pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
|
|
35
|
+
]
|
|
36
|
+
const identifier = Buffer.from([77, 79, 85, 150, 33, 217, 52, 106])
|
|
37
|
+
const data = identifier
|
|
38
|
+
const ix = new TransactionInstruction({ keys, programId, data })
|
|
39
|
+
return ix
|
|
35
40
|
}
|
|
@@ -1,31 +1,40 @@
|
|
|
1
|
-
import { TransactionInstruction, PublicKey, AccountMeta } from
|
|
2
|
-
import BN from
|
|
3
|
-
import * as borsh from
|
|
4
|
-
import * as types from
|
|
5
|
-
import { PROGRAM_ID } from
|
|
1
|
+
import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from "../programId"
|
|
6
6
|
|
|
7
7
|
export interface InvestAccounts {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
payer: PublicKey
|
|
9
|
+
payerTokenAccount: PublicKey
|
|
10
|
+
vaultState: PublicKey
|
|
11
|
+
tokenVault: PublicKey
|
|
12
|
+
tokenMint: PublicKey
|
|
13
|
+
baseVaultAuthority: PublicKey
|
|
14
|
+
ctokenVault: PublicKey
|
|
15
|
+
reserve: PublicKey
|
|
14
16
|
/** CPI accounts */
|
|
15
|
-
lendingMarket: PublicKey
|
|
16
|
-
lendingMarketAuthority: PublicKey
|
|
17
|
-
reserveLiquiditySupply: PublicKey
|
|
18
|
-
reserveCollateralMint: PublicKey
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
lendingMarket: PublicKey
|
|
18
|
+
lendingMarketAuthority: PublicKey
|
|
19
|
+
reserveLiquiditySupply: PublicKey
|
|
20
|
+
reserveCollateralMint: PublicKey
|
|
21
|
+
reserveCollateralTokenProgram: PublicKey
|
|
22
|
+
klendProgram: PublicKey
|
|
23
|
+
instructionSysvarAccount: PublicKey
|
|
24
|
+
tokenProgram: PublicKey
|
|
25
|
+
sharesTokenProgram: PublicKey
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
export function invest(
|
|
28
|
+
export function invest(
|
|
29
|
+
accounts: InvestAccounts,
|
|
30
|
+
programId: PublicKey = PROGRAM_ID
|
|
31
|
+
) {
|
|
25
32
|
const keys: Array<AccountMeta> = [
|
|
26
|
-
{ pubkey: accounts.
|
|
33
|
+
{ pubkey: accounts.payer, isSigner: true, isWritable: true },
|
|
34
|
+
{ pubkey: accounts.payerTokenAccount, isSigner: false, isWritable: true },
|
|
27
35
|
{ pubkey: accounts.vaultState, isSigner: false, isWritable: true },
|
|
28
36
|
{ pubkey: accounts.tokenVault, isSigner: false, isWritable: true },
|
|
37
|
+
{ pubkey: accounts.tokenMint, isSigner: false, isWritable: true },
|
|
29
38
|
{ pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: true },
|
|
30
39
|
{ pubkey: accounts.ctokenVault, isSigner: false, isWritable: true },
|
|
31
40
|
{ pubkey: accounts.reserve, isSigner: false, isWritable: true },
|
|
@@ -45,6 +54,11 @@ export function invest(accounts: InvestAccounts, programId: PublicKey = PROGRAM_
|
|
|
45
54
|
isSigner: false,
|
|
46
55
|
isWritable: true,
|
|
47
56
|
},
|
|
57
|
+
{
|
|
58
|
+
pubkey: accounts.reserveCollateralTokenProgram,
|
|
59
|
+
isSigner: false,
|
|
60
|
+
isWritable: false,
|
|
61
|
+
},
|
|
48
62
|
{ pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
|
|
49
63
|
{
|
|
50
64
|
pubkey: accounts.instructionSysvarAccount,
|
|
@@ -52,9 +66,10 @@ export function invest(accounts: InvestAccounts, programId: PublicKey = PROGRAM_
|
|
|
52
66
|
isWritable: false,
|
|
53
67
|
},
|
|
54
68
|
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
|
|
69
|
+
{ pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
|
|
70
|
+
]
|
|
71
|
+
const identifier = Buffer.from([13, 245, 180, 103, 254, 182, 121, 4])
|
|
72
|
+
const data = identifier
|
|
73
|
+
const ix = new TransactionInstruction({ keys, programId, data })
|
|
74
|
+
return ix
|
|
60
75
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from "../programId"
|
|
6
|
+
|
|
7
|
+
export interface UpdateAdminAccounts {
|
|
8
|
+
pendingAdmin: PublicKey
|
|
9
|
+
vaultState: PublicKey
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function updateAdmin(
|
|
13
|
+
accounts: UpdateAdminAccounts,
|
|
14
|
+
programId: PublicKey = PROGRAM_ID
|
|
15
|
+
) {
|
|
16
|
+
const keys: Array<AccountMeta> = [
|
|
17
|
+
{ pubkey: accounts.pendingAdmin, isSigner: true, isWritable: true },
|
|
18
|
+
{ pubkey: accounts.vaultState, isSigner: false, isWritable: true },
|
|
19
|
+
]
|
|
20
|
+
const identifier = Buffer.from([161, 176, 40, 213, 60, 184, 179, 228])
|
|
21
|
+
const data = identifier
|
|
22
|
+
const ix = new TransactionInstruction({ keys, programId, data })
|
|
23
|
+
return ix
|
|
24
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { TransactionInstruction, PublicKey, AccountMeta } from
|
|
2
|
-
import BN from
|
|
3
|
-
import * as borsh from
|
|
4
|
-
import * as types from
|
|
5
|
-
import { PROGRAM_ID } from
|
|
1
|
+
import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from "../programId"
|
|
6
6
|
|
|
7
7
|
export interface UpdateReserveAllocationArgs {
|
|
8
|
-
weight: BN
|
|
9
|
-
cap: BN
|
|
8
|
+
weight: BN
|
|
9
|
+
cap: BN
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export interface UpdateReserveAllocationAccounts {
|
|
13
|
-
adminAuthority: PublicKey
|
|
14
|
-
vaultState: PublicKey
|
|
15
|
-
baseVaultAuthority: PublicKey
|
|
16
|
-
reserveCollateralMint: PublicKey
|
|
17
|
-
reserve: PublicKey
|
|
18
|
-
ctokenVault: PublicKey
|
|
19
|
-
systemProgram: PublicKey
|
|
20
|
-
rent: PublicKey
|
|
21
|
-
tokenProgram: PublicKey
|
|
13
|
+
adminAuthority: PublicKey
|
|
14
|
+
vaultState: PublicKey
|
|
15
|
+
baseVaultAuthority: PublicKey
|
|
16
|
+
reserveCollateralMint: PublicKey
|
|
17
|
+
reserve: PublicKey
|
|
18
|
+
ctokenVault: PublicKey
|
|
19
|
+
systemProgram: PublicKey
|
|
20
|
+
rent: PublicKey
|
|
21
|
+
tokenProgram: PublicKey
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export const layout = borsh.struct([borsh.u64(
|
|
24
|
+
export const layout = borsh.struct([borsh.u64("weight"), borsh.u64("cap")])
|
|
25
25
|
|
|
26
26
|
export function updateReserveAllocation(
|
|
27
27
|
args: UpdateReserveAllocationArgs,
|
|
@@ -42,17 +42,17 @@ export function updateReserveAllocation(
|
|
|
42
42
|
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
|
43
43
|
{ pubkey: accounts.rent, isSigner: false, isWritable: false },
|
|
44
44
|
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
45
|
-
]
|
|
46
|
-
const identifier = Buffer.from([5, 54, 213, 112, 75, 232, 117, 37])
|
|
47
|
-
const buffer = Buffer.alloc(1000)
|
|
45
|
+
]
|
|
46
|
+
const identifier = Buffer.from([5, 54, 213, 112, 75, 232, 117, 37])
|
|
47
|
+
const buffer = Buffer.alloc(1000)
|
|
48
48
|
const len = layout.encode(
|
|
49
49
|
{
|
|
50
50
|
weight: args.weight,
|
|
51
51
|
cap: args.cap,
|
|
52
52
|
},
|
|
53
53
|
buffer
|
|
54
|
-
)
|
|
55
|
-
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
|
|
56
|
-
const ix = new TransactionInstruction({ keys, programId, data })
|
|
57
|
-
return ix
|
|
54
|
+
)
|
|
55
|
+
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
|
|
56
|
+
const ix = new TransactionInstruction({ keys, programId, data })
|
|
57
|
+
return ix
|
|
58
58
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from "../programId"
|
|
6
|
+
|
|
7
|
+
export interface UpdateVaultConfigArgs {
|
|
8
|
+
entry: types.VaultConfigFieldKind
|
|
9
|
+
data: Uint8Array
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface UpdateVaultConfigAccounts {
|
|
13
|
+
adminAuthority: PublicKey
|
|
14
|
+
vaultState: PublicKey
|
|
15
|
+
klendProgram: PublicKey
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const layout = borsh.struct([
|
|
19
|
+
types.VaultConfigField.layout("entry"),
|
|
20
|
+
borsh.vecU8("data"),
|
|
21
|
+
])
|
|
22
|
+
|
|
23
|
+
export function updateVaultConfig(
|
|
24
|
+
args: UpdateVaultConfigArgs,
|
|
25
|
+
accounts: UpdateVaultConfigAccounts,
|
|
26
|
+
programId: PublicKey = PROGRAM_ID
|
|
27
|
+
) {
|
|
28
|
+
const keys: Array<AccountMeta> = [
|
|
29
|
+
{ pubkey: accounts.adminAuthority, isSigner: true, isWritable: true },
|
|
30
|
+
{ pubkey: accounts.vaultState, isSigner: false, isWritable: true },
|
|
31
|
+
{ pubkey: accounts.klendProgram, isSigner: false, isWritable: false },
|
|
32
|
+
]
|
|
33
|
+
const identifier = Buffer.from([122, 3, 21, 222, 158, 255, 238, 157])
|
|
34
|
+
const buffer = Buffer.alloc(1000)
|
|
35
|
+
const len = layout.encode(
|
|
36
|
+
{
|
|
37
|
+
entry: args.entry.toEncodable(),
|
|
38
|
+
data: Buffer.from(
|
|
39
|
+
args.data.buffer,
|
|
40
|
+
args.data.byteOffset,
|
|
41
|
+
args.data.length
|
|
42
|
+
),
|
|
43
|
+
},
|
|
44
|
+
buffer
|
|
45
|
+
)
|
|
46
|
+
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
|
|
47
|
+
const ix = new TransactionInstruction({ keys, programId, data })
|
|
48
|
+
return ix
|
|
49
|
+
}
|
|
@@ -1,37 +1,43 @@
|
|
|
1
|
-
import { TransactionInstruction, PublicKey, AccountMeta } from
|
|
2
|
-
import BN from
|
|
3
|
-
import * as borsh from
|
|
4
|
-
import * as types from
|
|
5
|
-
import { PROGRAM_ID } from
|
|
1
|
+
import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
import { PROGRAM_ID } from "../programId"
|
|
6
6
|
|
|
7
7
|
export interface WithdrawArgs {
|
|
8
|
-
sharesAmount: BN
|
|
8
|
+
sharesAmount: BN
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface WithdrawAccounts {
|
|
12
|
-
user: PublicKey
|
|
13
|
-
vaultState: PublicKey
|
|
14
|
-
reserve: PublicKey
|
|
15
|
-
tokenVault: PublicKey
|
|
16
|
-
ctokenVault: PublicKey
|
|
17
|
-
baseVaultAuthority: PublicKey
|
|
18
|
-
tokenAta: PublicKey
|
|
19
|
-
tokenMint: PublicKey
|
|
20
|
-
userSharesAta: PublicKey
|
|
21
|
-
sharesMint: PublicKey
|
|
22
|
-
tokenProgram: PublicKey
|
|
12
|
+
user: PublicKey
|
|
13
|
+
vaultState: PublicKey
|
|
14
|
+
reserve: PublicKey
|
|
15
|
+
tokenVault: PublicKey
|
|
16
|
+
ctokenVault: PublicKey
|
|
17
|
+
baseVaultAuthority: PublicKey
|
|
18
|
+
tokenAta: PublicKey
|
|
19
|
+
tokenMint: PublicKey
|
|
20
|
+
userSharesAta: PublicKey
|
|
21
|
+
sharesMint: PublicKey
|
|
22
|
+
tokenProgram: PublicKey
|
|
23
23
|
/** CPI accounts */
|
|
24
|
-
lendingMarket: PublicKey
|
|
25
|
-
lendingMarketAuthority: PublicKey
|
|
26
|
-
reserveLiquiditySupply: PublicKey
|
|
27
|
-
reserveCollateralMint: PublicKey
|
|
28
|
-
klendProgram: PublicKey
|
|
29
|
-
instructionSysvarAccount: PublicKey
|
|
24
|
+
lendingMarket: PublicKey
|
|
25
|
+
lendingMarketAuthority: PublicKey
|
|
26
|
+
reserveLiquiditySupply: PublicKey
|
|
27
|
+
reserveCollateralMint: PublicKey
|
|
28
|
+
klendProgram: PublicKey
|
|
29
|
+
instructionSysvarAccount: PublicKey
|
|
30
|
+
reserveCollateralTokenProgram: PublicKey
|
|
31
|
+
sharesTokenProgram: PublicKey
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
export const layout = borsh.struct([borsh.u64(
|
|
34
|
+
export const layout = borsh.struct([borsh.u64("sharesAmount")])
|
|
33
35
|
|
|
34
|
-
export function withdraw(
|
|
36
|
+
export function withdraw(
|
|
37
|
+
args: WithdrawArgs,
|
|
38
|
+
accounts: WithdrawAccounts,
|
|
39
|
+
programId: PublicKey = PROGRAM_ID
|
|
40
|
+
) {
|
|
35
41
|
const keys: Array<AccountMeta> = [
|
|
36
42
|
{ pubkey: accounts.user, isSigner: true, isWritable: true },
|
|
37
43
|
{ pubkey: accounts.vaultState, isSigner: false, isWritable: true },
|
|
@@ -40,7 +46,7 @@ export function withdraw(args: WithdrawArgs, accounts: WithdrawAccounts, program
|
|
|
40
46
|
{ pubkey: accounts.ctokenVault, isSigner: false, isWritable: true },
|
|
41
47
|
{ pubkey: accounts.baseVaultAuthority, isSigner: false, isWritable: true },
|
|
42
48
|
{ pubkey: accounts.tokenAta, isSigner: false, isWritable: true },
|
|
43
|
-
{ pubkey: accounts.tokenMint, isSigner: false, isWritable:
|
|
49
|
+
{ pubkey: accounts.tokenMint, isSigner: false, isWritable: true },
|
|
44
50
|
{ pubkey: accounts.userSharesAta, isSigner: false, isWritable: true },
|
|
45
51
|
{ pubkey: accounts.sharesMint, isSigner: false, isWritable: true },
|
|
46
52
|
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
|
@@ -66,16 +72,22 @@ export function withdraw(args: WithdrawArgs, accounts: WithdrawAccounts, program
|
|
|
66
72
|
isSigner: false,
|
|
67
73
|
isWritable: false,
|
|
68
74
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
{
|
|
76
|
+
pubkey: accounts.reserveCollateralTokenProgram,
|
|
77
|
+
isSigner: false,
|
|
78
|
+
isWritable: false,
|
|
79
|
+
},
|
|
80
|
+
{ pubkey: accounts.sharesTokenProgram, isSigner: false, isWritable: false },
|
|
81
|
+
]
|
|
82
|
+
const identifier = Buffer.from([183, 18, 70, 156, 148, 109, 161, 34])
|
|
83
|
+
const buffer = Buffer.alloc(1000)
|
|
72
84
|
const len = layout.encode(
|
|
73
85
|
{
|
|
74
86
|
sharesAmount: args.sharesAmount,
|
|
75
87
|
},
|
|
76
88
|
buffer
|
|
77
|
-
)
|
|
78
|
-
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
|
|
79
|
-
const ix = new TransactionInstruction({ keys, programId, data })
|
|
80
|
-
return ix
|
|
89
|
+
)
|
|
90
|
+
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
|
|
91
|
+
const ix = new TransactionInstruction({ keys, programId, data })
|
|
92
|
+
return ix
|
|
81
93
|
}
|