@kamino-finance/klend-sdk 5.10.12 → 5.10.14
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/README.md +32 -0
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +8 -6
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.d.ts +20 -17
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +28 -35
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/obligation.d.ts +1 -0
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +23 -1
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.js +10 -10
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/types_utils.d.ts +5 -2
- package/dist/classes/types_utils.d.ts.map +1 -1
- package/dist/classes/types_utils.js +31 -2
- package/dist/classes/types_utils.js.map +1 -1
- package/dist/classes/utils.d.ts +8 -0
- package/dist/classes/utils.d.ts.map +1 -1
- package/dist/classes/utils.js +48 -0
- package/dist/classes/utils.js.map +1 -1
- package/dist/classes/vault.d.ts +24 -19
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +80 -47
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.js +4 -4
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl.json +1137 -132
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +6 -6
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.js +7 -7
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +15 -7
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen/errors/custom.js +28 -14
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.d.ts +29 -0
- package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js +125 -0
- package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js.map +1 -0
- package/dist/idl_codegen/instructions/depositObligationCollateralV2.d.ts +26 -0
- package/dist/idl_codegen/instructions/depositObligationCollateralV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/depositObligationCollateralV2.js +110 -0
- package/dist/idl_codegen/instructions/depositObligationCollateralV2.js.map +1 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.d.ts +31 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js +135 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js.map +1 -0
- package/dist/idl_codegen/instructions/index.d.ts +18 -0
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/index.js +19 -1
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.d.ts +43 -0
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js +181 -0
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js.map +1 -0
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.d.ts +8 -6
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js +23 -7
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeemV2.d.ts +49 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeemV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeemV2.js +205 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeemV2.js.map +1 -0
- package/dist/idl_codegen/instructions/repayObligationLiquidityV2.d.ts +27 -0
- package/dist/idl_codegen/instructions/repayObligationLiquidityV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js +111 -0
- package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js.map +1 -0
- package/dist/idl_codegen/instructions/socializeLossV2.d.ts +23 -0
- package/dist/idl_codegen/instructions/socializeLossV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/socializeLossV2.js +95 -0
- package/dist/idl_codegen/instructions/socializeLossV2.js.map +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.d.ts +31 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js +135 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js.map +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralV2.d.ts +26 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralV2.js +110 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralV2.js.map +1 -0
- package/dist/idl_codegen/types/ReserveConfig.d.ts +8 -5
- package/dist/idl_codegen/types/ReserveConfig.d.ts.map +1 -1
- package/dist/idl_codegen/types/ReserveConfig.js +9 -8
- package/dist/idl_codegen/types/ReserveConfig.js.map +1 -1
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts +7 -7
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateConfigMode.js +12 -12
- package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +7 -7
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +12 -12
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +4 -4
- package/dist/idl_codegen/types/index.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/programId.d.ts +2 -1
- package/dist/idl_codegen_kamino_vault/programId.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/programId.js +5 -1
- package/dist/idl_codegen_kamino_vault/programId.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/pyth/accounts/index.d.ts +1 -1
- package/dist/pyth/accounts/index.d.ts.map +1 -1
- package/dist/utils/ObligationType.d.ts +10 -4
- package/dist/utils/ObligationType.d.ts.map +1 -1
- package/dist/utils/ObligationType.js +36 -11
- package/dist/utils/ObligationType.js.map +1 -1
- package/dist/utils/accountListing.d.ts +3 -1
- package/dist/utils/accountListing.d.ts.map +1 -1
- package/dist/utils/accountListing.js +40 -0
- package/dist/utils/accountListing.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/managerTypes.js +1 -1
- package/dist/utils/managerTypes.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/action.ts +8 -6
- package/src/classes/manager.ts +34 -38
- package/src/classes/obligation.ts +43 -3
- package/src/classes/reserve.ts +12 -12
- package/src/classes/types_utils.ts +33 -3
- package/src/classes/utils.ts +50 -1
- package/src/classes/vault.ts +104 -57
- package/src/client.ts +22 -0
- package/src/client_kamino_manager.ts +4 -4
- package/src/idl.json +1137 -132
- package/src/idl_codegen/accounts/LendingMarket.ts +11 -11
- package/src/idl_codegen/errors/custom.ts +26 -12
- package/src/idl_codegen/instructions/borrowObligationLiquidityV2.ts +124 -0
- package/src/idl_codegen/instructions/depositObligationCollateralV2.ts +106 -0
- package/src/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.ts +136 -0
- package/src/idl_codegen/instructions/index.ts +45 -0
- package/src/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.ts +195 -0
- package/src/idl_codegen/instructions/refreshObligationFarmsForReserve.ts +31 -13
- package/src/idl_codegen/instructions/repayAndWithdrawAndRedeemV2.ts +239 -0
- package/src/idl_codegen/instructions/repayObligationLiquidityV2.ts +108 -0
- package/src/idl_codegen/instructions/socializeLossV2.ts +88 -0
- package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts +136 -0
- package/src/idl_codegen/instructions/withdrawObligationCollateralV2.ts +106 -0
- package/src/idl_codegen/types/ReserveConfig.ts +17 -14
- package/src/idl_codegen/types/UpdateConfigMode.ts +13 -13
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +13 -13
- package/src/idl_codegen/types/index.ts +4 -4
- package/src/idl_codegen_kamino_vault/programId.ts +5 -1
- package/src/lending_operations/swap_collateral_operations.ts +1 -1
- package/src/pyth/accounts/index.ts +1 -1
- package/src/utils/ObligationType.ts +41 -12
- package/src/utils/accountListing.ts +43 -1
- package/src/utils/constants.ts +2 -0
- package/src/utils/managerTypes.ts +1 -1
package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
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 WithdrawObligationCollateralAndRedeemReserveCollateralV2Args {
|
|
8
|
+
collateralAmount: BN
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface WithdrawObligationCollateralAndRedeemReserveCollateralV2Accounts {
|
|
12
|
+
withdrawAccounts: {
|
|
13
|
+
owner: PublicKey
|
|
14
|
+
obligation: PublicKey
|
|
15
|
+
lendingMarket: PublicKey
|
|
16
|
+
lendingMarketAuthority: PublicKey
|
|
17
|
+
withdrawReserve: PublicKey
|
|
18
|
+
reserveLiquidityMint: PublicKey
|
|
19
|
+
reserveSourceCollateral: PublicKey
|
|
20
|
+
reserveCollateralMint: PublicKey
|
|
21
|
+
reserveLiquiditySupply: PublicKey
|
|
22
|
+
userDestinationLiquidity: PublicKey
|
|
23
|
+
placeholderUserDestinationCollateral: PublicKey
|
|
24
|
+
collateralTokenProgram: PublicKey
|
|
25
|
+
liquidityTokenProgram: PublicKey
|
|
26
|
+
instructionSysvarAccount: PublicKey
|
|
27
|
+
}
|
|
28
|
+
farmsAccounts: {
|
|
29
|
+
obligationFarmUserState: PublicKey
|
|
30
|
+
reserveFarmState: PublicKey
|
|
31
|
+
}
|
|
32
|
+
farmsProgram: PublicKey
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const layout = borsh.struct([borsh.u64("collateralAmount")])
|
|
36
|
+
|
|
37
|
+
export function withdrawObligationCollateralAndRedeemReserveCollateralV2(
|
|
38
|
+
args: WithdrawObligationCollateralAndRedeemReserveCollateralV2Args,
|
|
39
|
+
accounts: WithdrawObligationCollateralAndRedeemReserveCollateralV2Accounts,
|
|
40
|
+
programId: PublicKey = PROGRAM_ID
|
|
41
|
+
) {
|
|
42
|
+
const keys: Array<AccountMeta> = [
|
|
43
|
+
{
|
|
44
|
+
pubkey: accounts.withdrawAccounts.owner,
|
|
45
|
+
isSigner: true,
|
|
46
|
+
isWritable: false,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
pubkey: accounts.withdrawAccounts.obligation,
|
|
50
|
+
isSigner: false,
|
|
51
|
+
isWritable: true,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
pubkey: accounts.withdrawAccounts.lendingMarket,
|
|
55
|
+
isSigner: false,
|
|
56
|
+
isWritable: false,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
pubkey: accounts.withdrawAccounts.lendingMarketAuthority,
|
|
60
|
+
isSigner: false,
|
|
61
|
+
isWritable: false,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
pubkey: accounts.withdrawAccounts.withdrawReserve,
|
|
65
|
+
isSigner: false,
|
|
66
|
+
isWritable: true,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
pubkey: accounts.withdrawAccounts.reserveLiquidityMint,
|
|
70
|
+
isSigner: false,
|
|
71
|
+
isWritable: true,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
pubkey: accounts.withdrawAccounts.reserveSourceCollateral,
|
|
75
|
+
isSigner: false,
|
|
76
|
+
isWritable: true,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
pubkey: accounts.withdrawAccounts.reserveCollateralMint,
|
|
80
|
+
isSigner: false,
|
|
81
|
+
isWritable: true,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
pubkey: accounts.withdrawAccounts.reserveLiquiditySupply,
|
|
85
|
+
isSigner: false,
|
|
86
|
+
isWritable: true,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
pubkey: accounts.withdrawAccounts.userDestinationLiquidity,
|
|
90
|
+
isSigner: false,
|
|
91
|
+
isWritable: true,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
pubkey: accounts.withdrawAccounts.placeholderUserDestinationCollateral,
|
|
95
|
+
isSigner: false,
|
|
96
|
+
isWritable: false,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
pubkey: accounts.withdrawAccounts.collateralTokenProgram,
|
|
100
|
+
isSigner: false,
|
|
101
|
+
isWritable: false,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
pubkey: accounts.withdrawAccounts.liquidityTokenProgram,
|
|
105
|
+
isSigner: false,
|
|
106
|
+
isWritable: false,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
pubkey: accounts.withdrawAccounts.instructionSysvarAccount,
|
|
110
|
+
isSigner: false,
|
|
111
|
+
isWritable: false,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
pubkey: accounts.farmsAccounts.obligationFarmUserState,
|
|
115
|
+
isSigner: false,
|
|
116
|
+
isWritable: true,
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
pubkey: accounts.farmsAccounts.reserveFarmState,
|
|
120
|
+
isSigner: false,
|
|
121
|
+
isWritable: true,
|
|
122
|
+
},
|
|
123
|
+
{ pubkey: accounts.farmsProgram, isSigner: false, isWritable: false },
|
|
124
|
+
]
|
|
125
|
+
const identifier = Buffer.from([235, 52, 119, 152, 149, 197, 20, 7])
|
|
126
|
+
const buffer = Buffer.alloc(1000)
|
|
127
|
+
const len = layout.encode(
|
|
128
|
+
{
|
|
129
|
+
collateralAmount: args.collateralAmount,
|
|
130
|
+
},
|
|
131
|
+
buffer
|
|
132
|
+
)
|
|
133
|
+
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
|
|
134
|
+
const ix = new TransactionInstruction({ keys, programId, data })
|
|
135
|
+
return ix
|
|
136
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
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 WithdrawObligationCollateralV2Args {
|
|
8
|
+
collateralAmount: BN
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface WithdrawObligationCollateralV2Accounts {
|
|
12
|
+
withdrawAccounts: {
|
|
13
|
+
owner: PublicKey
|
|
14
|
+
obligation: PublicKey
|
|
15
|
+
lendingMarket: PublicKey
|
|
16
|
+
lendingMarketAuthority: PublicKey
|
|
17
|
+
withdrawReserve: PublicKey
|
|
18
|
+
reserveSourceCollateral: PublicKey
|
|
19
|
+
userDestinationCollateral: PublicKey
|
|
20
|
+
tokenProgram: PublicKey
|
|
21
|
+
instructionSysvarAccount: PublicKey
|
|
22
|
+
}
|
|
23
|
+
farmsAccounts: {
|
|
24
|
+
obligationFarmUserState: PublicKey
|
|
25
|
+
reserveFarmState: PublicKey
|
|
26
|
+
}
|
|
27
|
+
farmsProgram: PublicKey
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const layout = borsh.struct([borsh.u64("collateralAmount")])
|
|
31
|
+
|
|
32
|
+
export function withdrawObligationCollateralV2(
|
|
33
|
+
args: WithdrawObligationCollateralV2Args,
|
|
34
|
+
accounts: WithdrawObligationCollateralV2Accounts,
|
|
35
|
+
programId: PublicKey = PROGRAM_ID
|
|
36
|
+
) {
|
|
37
|
+
const keys: Array<AccountMeta> = [
|
|
38
|
+
{
|
|
39
|
+
pubkey: accounts.withdrawAccounts.owner,
|
|
40
|
+
isSigner: true,
|
|
41
|
+
isWritable: false,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
pubkey: accounts.withdrawAccounts.obligation,
|
|
45
|
+
isSigner: false,
|
|
46
|
+
isWritable: true,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
pubkey: accounts.withdrawAccounts.lendingMarket,
|
|
50
|
+
isSigner: false,
|
|
51
|
+
isWritable: false,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
pubkey: accounts.withdrawAccounts.lendingMarketAuthority,
|
|
55
|
+
isSigner: false,
|
|
56
|
+
isWritable: false,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
pubkey: accounts.withdrawAccounts.withdrawReserve,
|
|
60
|
+
isSigner: false,
|
|
61
|
+
isWritable: true,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
pubkey: accounts.withdrawAccounts.reserveSourceCollateral,
|
|
65
|
+
isSigner: false,
|
|
66
|
+
isWritable: true,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
pubkey: accounts.withdrawAccounts.userDestinationCollateral,
|
|
70
|
+
isSigner: false,
|
|
71
|
+
isWritable: true,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
pubkey: accounts.withdrawAccounts.tokenProgram,
|
|
75
|
+
isSigner: false,
|
|
76
|
+
isWritable: false,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
pubkey: accounts.withdrawAccounts.instructionSysvarAccount,
|
|
80
|
+
isSigner: false,
|
|
81
|
+
isWritable: false,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
pubkey: accounts.farmsAccounts.obligationFarmUserState,
|
|
85
|
+
isSigner: false,
|
|
86
|
+
isWritable: true,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
pubkey: accounts.farmsAccounts.reserveFarmState,
|
|
90
|
+
isSigner: false,
|
|
91
|
+
isWritable: true,
|
|
92
|
+
},
|
|
93
|
+
{ pubkey: accounts.farmsProgram, isSigner: false, isWritable: false },
|
|
94
|
+
]
|
|
95
|
+
const identifier = Buffer.from([202, 249, 117, 114, 231, 192, 47, 138])
|
|
96
|
+
const buffer = Buffer.alloc(1000)
|
|
97
|
+
const len = layout.encode(
|
|
98
|
+
{
|
|
99
|
+
collateralAmount: args.collateralAmount,
|
|
100
|
+
},
|
|
101
|
+
buffer
|
|
102
|
+
)
|
|
103
|
+
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len)
|
|
104
|
+
const ix = new TransactionInstruction({ keys, programId, data })
|
|
105
|
+
return ix
|
|
106
|
+
}
|
|
@@ -60,7 +60,8 @@ export interface ReserveConfigFields {
|
|
|
60
60
|
debtWithdrawalCap: types.WithdrawalCapsFields
|
|
61
61
|
elevationGroups: Array<number>
|
|
62
62
|
disableUsageAsCollOutsideEmode: number
|
|
63
|
-
|
|
63
|
+
/** Utilization (in percentage) above which borrowing is blocked. 0 to disable. */
|
|
64
|
+
utilizationLimitBlockBorrowingAbovePct: number
|
|
64
65
|
/**
|
|
65
66
|
* Whether this reserve should be subject to auto-deleveraging after deposit or borrow limit is
|
|
66
67
|
* crossed.
|
|
@@ -147,7 +148,8 @@ export interface ReserveConfigJSON {
|
|
|
147
148
|
debtWithdrawalCap: types.WithdrawalCapsJSON
|
|
148
149
|
elevationGroups: Array<number>
|
|
149
150
|
disableUsageAsCollOutsideEmode: number
|
|
150
|
-
|
|
151
|
+
/** Utilization (in percentage) above which borrowing is blocked. 0 to disable. */
|
|
152
|
+
utilizationLimitBlockBorrowingAbovePct: number
|
|
151
153
|
/**
|
|
152
154
|
* Whether this reserve should be subject to auto-deleveraging after deposit or borrow limit is
|
|
153
155
|
* crossed.
|
|
@@ -235,7 +237,8 @@ export class ReserveConfig {
|
|
|
235
237
|
readonly debtWithdrawalCap: types.WithdrawalCaps
|
|
236
238
|
readonly elevationGroups: Array<number>
|
|
237
239
|
readonly disableUsageAsCollOutsideEmode: number
|
|
238
|
-
|
|
240
|
+
/** Utilization (in percentage) above which borrowing is blocked. 0 to disable. */
|
|
241
|
+
readonly utilizationLimitBlockBorrowingAbovePct: number
|
|
239
242
|
/**
|
|
240
243
|
* Whether this reserve should be subject to auto-deleveraging after deposit or borrow limit is
|
|
241
244
|
* crossed.
|
|
@@ -297,8 +300,8 @@ export class ReserveConfig {
|
|
|
297
300
|
})
|
|
298
301
|
this.elevationGroups = fields.elevationGroups
|
|
299
302
|
this.disableUsageAsCollOutsideEmode = fields.disableUsageAsCollOutsideEmode
|
|
300
|
-
this.
|
|
301
|
-
fields.
|
|
303
|
+
this.utilizationLimitBlockBorrowingAbovePct =
|
|
304
|
+
fields.utilizationLimitBlockBorrowingAbovePct
|
|
302
305
|
this.autodeleverageEnabled = fields.autodeleverageEnabled
|
|
303
306
|
this.reserved1 = fields.reserved1
|
|
304
307
|
this.borrowLimitOutsideElevationGroup =
|
|
@@ -336,7 +339,7 @@ export class ReserveConfig {
|
|
|
336
339
|
types.WithdrawalCaps.layout("debtWithdrawalCap"),
|
|
337
340
|
borsh.array(borsh.u8(), 20, "elevationGroups"),
|
|
338
341
|
borsh.u8("disableUsageAsCollOutsideEmode"),
|
|
339
|
-
borsh.u8("
|
|
342
|
+
borsh.u8("utilizationLimitBlockBorrowingAbovePct"),
|
|
340
343
|
borsh.u8("autodeleverageEnabled"),
|
|
341
344
|
borsh.array(borsh.u8(), 1, "reserved1"),
|
|
342
345
|
borsh.u64("borrowLimitOutsideElevationGroup"),
|
|
@@ -383,8 +386,8 @@ export class ReserveConfig {
|
|
|
383
386
|
),
|
|
384
387
|
elevationGroups: obj.elevationGroups,
|
|
385
388
|
disableUsageAsCollOutsideEmode: obj.disableUsageAsCollOutsideEmode,
|
|
386
|
-
|
|
387
|
-
obj.
|
|
389
|
+
utilizationLimitBlockBorrowingAbovePct:
|
|
390
|
+
obj.utilizationLimitBlockBorrowingAbovePct,
|
|
388
391
|
autodeleverageEnabled: obj.autodeleverageEnabled,
|
|
389
392
|
reserved1: obj.reserved1,
|
|
390
393
|
borrowLimitOutsideElevationGroup: obj.borrowLimitOutsideElevationGroup,
|
|
@@ -428,8 +431,8 @@ export class ReserveConfig {
|
|
|
428
431
|
),
|
|
429
432
|
elevationGroups: fields.elevationGroups,
|
|
430
433
|
disableUsageAsCollOutsideEmode: fields.disableUsageAsCollOutsideEmode,
|
|
431
|
-
|
|
432
|
-
fields.
|
|
434
|
+
utilizationLimitBlockBorrowingAbovePct:
|
|
435
|
+
fields.utilizationLimitBlockBorrowingAbovePct,
|
|
433
436
|
autodeleverageEnabled: fields.autodeleverageEnabled,
|
|
434
437
|
reserved1: fields.reserved1,
|
|
435
438
|
borrowLimitOutsideElevationGroup: fields.borrowLimitOutsideElevationGroup,
|
|
@@ -468,8 +471,8 @@ export class ReserveConfig {
|
|
|
468
471
|
debtWithdrawalCap: this.debtWithdrawalCap.toJSON(),
|
|
469
472
|
elevationGroups: this.elevationGroups,
|
|
470
473
|
disableUsageAsCollOutsideEmode: this.disableUsageAsCollOutsideEmode,
|
|
471
|
-
|
|
472
|
-
this.
|
|
474
|
+
utilizationLimitBlockBorrowingAbovePct:
|
|
475
|
+
this.utilizationLimitBlockBorrowingAbovePct,
|
|
473
476
|
autodeleverageEnabled: this.autodeleverageEnabled,
|
|
474
477
|
reserved1: this.reserved1,
|
|
475
478
|
borrowLimitOutsideElevationGroup:
|
|
@@ -515,8 +518,8 @@ export class ReserveConfig {
|
|
|
515
518
|
debtWithdrawalCap: types.WithdrawalCaps.fromJSON(obj.debtWithdrawalCap),
|
|
516
519
|
elevationGroups: obj.elevationGroups,
|
|
517
520
|
disableUsageAsCollOutsideEmode: obj.disableUsageAsCollOutsideEmode,
|
|
518
|
-
|
|
519
|
-
obj.
|
|
521
|
+
utilizationLimitBlockBorrowingAbovePct:
|
|
522
|
+
obj.utilizationLimitBlockBorrowingAbovePct,
|
|
520
523
|
autodeleverageEnabled: obj.autodeleverageEnabled,
|
|
521
524
|
reserved1: obj.reserved1,
|
|
522
525
|
borrowLimitOutsideElevationGroup: new BN(
|
|
@@ -969,25 +969,25 @@ export class UpdateDisableUsageAsCollateralOutsideEmode {
|
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
971
|
|
|
972
|
-
export interface
|
|
973
|
-
kind: "
|
|
972
|
+
export interface UpdateBlockBorrowingAboveUtilizationPctJSON {
|
|
973
|
+
kind: "UpdateBlockBorrowingAboveUtilizationPct"
|
|
974
974
|
}
|
|
975
975
|
|
|
976
|
-
export class
|
|
976
|
+
export class UpdateBlockBorrowingAboveUtilizationPct {
|
|
977
977
|
static readonly discriminator = 42
|
|
978
|
-
static readonly kind = "
|
|
978
|
+
static readonly kind = "UpdateBlockBorrowingAboveUtilizationPct"
|
|
979
979
|
readonly discriminator = 42
|
|
980
|
-
readonly kind = "
|
|
980
|
+
readonly kind = "UpdateBlockBorrowingAboveUtilizationPct"
|
|
981
981
|
|
|
982
|
-
toJSON():
|
|
982
|
+
toJSON(): UpdateBlockBorrowingAboveUtilizationPctJSON {
|
|
983
983
|
return {
|
|
984
|
-
kind: "
|
|
984
|
+
kind: "UpdateBlockBorrowingAboveUtilizationPct",
|
|
985
985
|
}
|
|
986
986
|
}
|
|
987
987
|
|
|
988
988
|
toEncodable() {
|
|
989
989
|
return {
|
|
990
|
-
|
|
990
|
+
UpdateBlockBorrowingAboveUtilizationPct: {},
|
|
991
991
|
}
|
|
992
992
|
}
|
|
993
993
|
}
|
|
@@ -1262,8 +1262,8 @@ export function fromDecoded(obj: any): types.UpdateConfigModeKind {
|
|
|
1262
1262
|
if ("UpdateDisableUsageAsCollateralOutsideEmode" in obj) {
|
|
1263
1263
|
return new UpdateDisableUsageAsCollateralOutsideEmode()
|
|
1264
1264
|
}
|
|
1265
|
-
if ("
|
|
1266
|
-
return new
|
|
1265
|
+
if ("UpdateBlockBorrowingAboveUtilizationPct" in obj) {
|
|
1266
|
+
return new UpdateBlockBorrowingAboveUtilizationPct()
|
|
1267
1267
|
}
|
|
1268
1268
|
if ("UpdateBlockPriceUsage" in obj) {
|
|
1269
1269
|
return new UpdateBlockPriceUsage()
|
|
@@ -1417,8 +1417,8 @@ export function fromJSON(
|
|
|
1417
1417
|
case "UpdateDisableUsageAsCollateralOutsideEmode": {
|
|
1418
1418
|
return new UpdateDisableUsageAsCollateralOutsideEmode()
|
|
1419
1419
|
}
|
|
1420
|
-
case "
|
|
1421
|
-
return new
|
|
1420
|
+
case "UpdateBlockBorrowingAboveUtilizationPct": {
|
|
1421
|
+
return new UpdateBlockBorrowingAboveUtilizationPct()
|
|
1422
1422
|
}
|
|
1423
1423
|
case "UpdateBlockPriceUsage": {
|
|
1424
1424
|
return new UpdateBlockPriceUsage()
|
|
@@ -1485,7 +1485,7 @@ export function layout(property?: string) {
|
|
|
1485
1485
|
borsh.struct([], "UpdateFarmCollateral"),
|
|
1486
1486
|
borsh.struct([], "UpdateFarmDebt"),
|
|
1487
1487
|
borsh.struct([], "UpdateDisableUsageAsCollateralOutsideEmode"),
|
|
1488
|
-
borsh.struct([], "
|
|
1488
|
+
borsh.struct([], "UpdateBlockBorrowingAboveUtilizationPct"),
|
|
1489
1489
|
borsh.struct([], "UpdateBlockPriceUsage"),
|
|
1490
1490
|
borsh.struct([], "UpdateBorrowLimitOutsideElevationGroup"),
|
|
1491
1491
|
borsh.struct([], "UpdateBorrowLimitsInElevationGroupAgainstThisReserve"),
|
|
@@ -95,25 +95,25 @@ export class UpdateLiquidationMaxValue {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
export interface
|
|
99
|
-
kind: "
|
|
98
|
+
export interface DeprecatedUpdateGlobalUnhealthyBorrowJSON {
|
|
99
|
+
kind: "DeprecatedUpdateGlobalUnhealthyBorrow"
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
export class
|
|
102
|
+
export class DeprecatedUpdateGlobalUnhealthyBorrow {
|
|
103
103
|
static readonly discriminator = 4
|
|
104
|
-
static readonly kind = "
|
|
104
|
+
static readonly kind = "DeprecatedUpdateGlobalUnhealthyBorrow"
|
|
105
105
|
readonly discriminator = 4
|
|
106
|
-
readonly kind = "
|
|
106
|
+
readonly kind = "DeprecatedUpdateGlobalUnhealthyBorrow"
|
|
107
107
|
|
|
108
|
-
toJSON():
|
|
108
|
+
toJSON(): DeprecatedUpdateGlobalUnhealthyBorrowJSON {
|
|
109
109
|
return {
|
|
110
|
-
kind: "
|
|
110
|
+
kind: "DeprecatedUpdateGlobalUnhealthyBorrow",
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
toEncodable() {
|
|
115
115
|
return {
|
|
116
|
-
|
|
116
|
+
DeprecatedUpdateGlobalUnhealthyBorrow: {},
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -504,8 +504,8 @@ export function fromDecoded(obj: any): types.UpdateLendingMarketModeKind {
|
|
|
504
504
|
if ("UpdateLiquidationMaxValue" in obj) {
|
|
505
505
|
return new UpdateLiquidationMaxValue()
|
|
506
506
|
}
|
|
507
|
-
if ("
|
|
508
|
-
return new
|
|
507
|
+
if ("DeprecatedUpdateGlobalUnhealthyBorrow" in obj) {
|
|
508
|
+
return new DeprecatedUpdateGlobalUnhealthyBorrow()
|
|
509
509
|
}
|
|
510
510
|
if ("UpdateGlobalAllowedBorrow" in obj) {
|
|
511
511
|
return new UpdateGlobalAllowedBorrow()
|
|
@@ -575,8 +575,8 @@ export function fromJSON(
|
|
|
575
575
|
case "UpdateLiquidationMaxValue": {
|
|
576
576
|
return new UpdateLiquidationMaxValue()
|
|
577
577
|
}
|
|
578
|
-
case "
|
|
579
|
-
return new
|
|
578
|
+
case "DeprecatedUpdateGlobalUnhealthyBorrow": {
|
|
579
|
+
return new DeprecatedUpdateGlobalUnhealthyBorrow()
|
|
580
580
|
}
|
|
581
581
|
case "UpdateGlobalAllowedBorrow": {
|
|
582
582
|
return new UpdateGlobalAllowedBorrow()
|
|
@@ -635,7 +635,7 @@ export function layout(property?: string) {
|
|
|
635
635
|
borsh.struct([], "UpdateEmergencyMode"),
|
|
636
636
|
borsh.struct([], "UpdateLiquidationCloseFactor"),
|
|
637
637
|
borsh.struct([], "UpdateLiquidationMaxValue"),
|
|
638
|
-
borsh.struct([], "
|
|
638
|
+
borsh.struct([], "DeprecatedUpdateGlobalUnhealthyBorrow"),
|
|
639
639
|
borsh.struct([], "UpdateGlobalAllowedBorrow"),
|
|
640
640
|
borsh.struct([], "UpdateRiskCouncil"),
|
|
641
641
|
borsh.struct([], "UpdateMinFullLiquidationThreshold"),
|
|
@@ -51,7 +51,7 @@ export type UpdateConfigModeKind =
|
|
|
51
51
|
| UpdateConfigMode.UpdateFarmCollateral
|
|
52
52
|
| UpdateConfigMode.UpdateFarmDebt
|
|
53
53
|
| UpdateConfigMode.UpdateDisableUsageAsCollateralOutsideEmode
|
|
54
|
-
| UpdateConfigMode.
|
|
54
|
+
| UpdateConfigMode.UpdateBlockBorrowingAboveUtilizationPct
|
|
55
55
|
| UpdateConfigMode.UpdateBlockPriceUsage
|
|
56
56
|
| UpdateConfigMode.UpdateBorrowLimitOutsideElevationGroup
|
|
57
57
|
| UpdateConfigMode.UpdateBorrowLimitsInElevationGroupAgainstThisReserve
|
|
@@ -101,7 +101,7 @@ export type UpdateConfigModeJSON =
|
|
|
101
101
|
| UpdateConfigMode.UpdateFarmCollateralJSON
|
|
102
102
|
| UpdateConfigMode.UpdateFarmDebtJSON
|
|
103
103
|
| UpdateConfigMode.UpdateDisableUsageAsCollateralOutsideEmodeJSON
|
|
104
|
-
| UpdateConfigMode.
|
|
104
|
+
| UpdateConfigMode.UpdateBlockBorrowingAboveUtilizationPctJSON
|
|
105
105
|
| UpdateConfigMode.UpdateBlockPriceUsageJSON
|
|
106
106
|
| UpdateConfigMode.UpdateBorrowLimitOutsideElevationGroupJSON
|
|
107
107
|
| UpdateConfigMode.UpdateBorrowLimitsInElevationGroupAgainstThisReserveJSON
|
|
@@ -139,7 +139,7 @@ export type UpdateLendingMarketModeKind =
|
|
|
139
139
|
| UpdateLendingMarketMode.UpdateEmergencyMode
|
|
140
140
|
| UpdateLendingMarketMode.UpdateLiquidationCloseFactor
|
|
141
141
|
| UpdateLendingMarketMode.UpdateLiquidationMaxValue
|
|
142
|
-
| UpdateLendingMarketMode.
|
|
142
|
+
| UpdateLendingMarketMode.DeprecatedUpdateGlobalUnhealthyBorrow
|
|
143
143
|
| UpdateLendingMarketMode.UpdateGlobalAllowedBorrow
|
|
144
144
|
| UpdateLendingMarketMode.UpdateRiskCouncil
|
|
145
145
|
| UpdateLendingMarketMode.UpdateMinFullLiquidationThreshold
|
|
@@ -161,7 +161,7 @@ export type UpdateLendingMarketModeJSON =
|
|
|
161
161
|
| UpdateLendingMarketMode.UpdateEmergencyModeJSON
|
|
162
162
|
| UpdateLendingMarketMode.UpdateLiquidationCloseFactorJSON
|
|
163
163
|
| UpdateLendingMarketMode.UpdateLiquidationMaxValueJSON
|
|
164
|
-
| UpdateLendingMarketMode.
|
|
164
|
+
| UpdateLendingMarketMode.DeprecatedUpdateGlobalUnhealthyBorrowJSON
|
|
165
165
|
| UpdateLendingMarketMode.UpdateGlobalAllowedBorrowJSON
|
|
166
166
|
| UpdateLendingMarketMode.UpdateRiskCouncilJSON
|
|
167
167
|
| UpdateLendingMarketMode.UpdateMinFullLiquidationThresholdJSON
|
|
@@ -6,4 +6,8 @@ export const PROGRAM_ID_CLI = new PublicKey(
|
|
|
6
6
|
)
|
|
7
7
|
|
|
8
8
|
// This constant will not get overwritten on subsequent code generations and it's safe to modify it's value.
|
|
9
|
-
export
|
|
9
|
+
export let PROGRAM_ID: PublicKey = PROGRAM_ID_CLI
|
|
10
|
+
|
|
11
|
+
export const setKVaultsProgramId = (programId: PublicKey) => {
|
|
12
|
+
PROGRAM_ID = programId;
|
|
13
|
+
}
|
|
@@ -319,7 +319,7 @@ function getAtaCreationIxns(context: SwapCollContext<any>) {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
function getAtaCloseIxns(context: SwapCollContext<any>) {
|
|
322
|
-
const ataCloseIxns = [];
|
|
322
|
+
const ataCloseIxns: TransactionInstruction[] = [];
|
|
323
323
|
if (
|
|
324
324
|
context.sourceCollReserve.getLiquidityMint().equals(WRAPPED_SOL_MINT) ||
|
|
325
325
|
context.targetCollReserve.getLiquidityMint().equals(WRAPPED_SOL_MINT)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { PriceUpdateV2 } from './PriceUpdateV2';
|
|
2
|
-
export { PriceUpdateV2Fields, PriceUpdateV2JSON } from './PriceUpdateV2';
|
|
2
|
+
export type { PriceUpdateV2Fields, PriceUpdateV2JSON } from './PriceUpdateV2';
|
|
@@ -19,16 +19,18 @@ export type InitObligationArgsModel = {
|
|
|
19
19
|
|
|
20
20
|
export class VanillaObligation {
|
|
21
21
|
readonly programId: PublicKey;
|
|
22
|
+
readonly id: number;
|
|
22
23
|
static tag = 0;
|
|
23
24
|
|
|
24
|
-
constructor(programId: PublicKey) {
|
|
25
|
+
constructor(programId: PublicKey, id?: number) {
|
|
25
26
|
this.programId = programId;
|
|
27
|
+
this.id = id ?? 0;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
toArgs() {
|
|
29
31
|
const initObligationArgs: InitObligationArgsModel = {
|
|
30
32
|
tag: VanillaObligation.tag,
|
|
31
|
-
id:
|
|
33
|
+
id: this.id,
|
|
32
34
|
seed1: PublicKey.default,
|
|
33
35
|
seed2: PublicKey.default,
|
|
34
36
|
};
|
|
@@ -45,18 +47,20 @@ export class MultiplyObligation {
|
|
|
45
47
|
readonly collToken: PublicKey;
|
|
46
48
|
readonly debtToken: PublicKey;
|
|
47
49
|
readonly programId: PublicKey;
|
|
50
|
+
readonly id: number;
|
|
48
51
|
static tag = 1;
|
|
49
52
|
|
|
50
|
-
constructor(collToken: PublicKey, debtToken: PublicKey, programId: PublicKey) {
|
|
53
|
+
constructor(collToken: PublicKey, debtToken: PublicKey, programId: PublicKey, id?: number) {
|
|
51
54
|
this.collToken = collToken;
|
|
52
55
|
this.debtToken = debtToken;
|
|
53
56
|
this.programId = programId;
|
|
57
|
+
this.id = id ?? 0;
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
toArgs() {
|
|
57
61
|
const initObligationArgs: InitObligationArgsModel = {
|
|
58
62
|
tag: MultiplyObligation.tag,
|
|
59
|
-
id:
|
|
63
|
+
id: this.id,
|
|
60
64
|
seed1: this.collToken,
|
|
61
65
|
seed2: this.debtToken,
|
|
62
66
|
};
|
|
@@ -73,18 +77,20 @@ export class LeverageObligation {
|
|
|
73
77
|
readonly collToken: PublicKey;
|
|
74
78
|
readonly debtToken: PublicKey;
|
|
75
79
|
readonly programId: PublicKey;
|
|
80
|
+
readonly id: number;
|
|
76
81
|
static tag = 3;
|
|
77
82
|
|
|
78
|
-
constructor(collToken: PublicKey, debtToken: PublicKey, programId: PublicKey) {
|
|
83
|
+
constructor(collToken: PublicKey, debtToken: PublicKey, programId: PublicKey, id?: number) {
|
|
79
84
|
this.collToken = collToken;
|
|
80
85
|
this.debtToken = debtToken;
|
|
81
86
|
this.programId = programId;
|
|
87
|
+
this.id = id ?? 0;
|
|
82
88
|
}
|
|
83
89
|
|
|
84
90
|
toArgs() {
|
|
85
91
|
const initObligationArgs: InitObligationArgsModel = {
|
|
86
92
|
tag: LeverageObligation.tag,
|
|
87
|
-
id:
|
|
93
|
+
id: this.id,
|
|
88
94
|
seed1: this.collToken,
|
|
89
95
|
seed2: this.debtToken,
|
|
90
96
|
};
|
|
@@ -100,11 +106,13 @@ export class LeverageObligation {
|
|
|
100
106
|
export class LendingObligation {
|
|
101
107
|
readonly token: PublicKey;
|
|
102
108
|
readonly programId: PublicKey;
|
|
109
|
+
readonly id: number;
|
|
103
110
|
static tag = 2;
|
|
104
111
|
|
|
105
|
-
constructor(token: PublicKey, programId: PublicKey) {
|
|
112
|
+
constructor(token: PublicKey, programId: PublicKey, id?: number) {
|
|
106
113
|
this.token = token;
|
|
107
114
|
this.programId = programId;
|
|
115
|
+
this.id = id ?? 0;
|
|
108
116
|
}
|
|
109
117
|
|
|
110
118
|
toArgs() {
|
|
@@ -123,7 +131,7 @@ export class LendingObligation {
|
|
|
123
131
|
}
|
|
124
132
|
}
|
|
125
133
|
|
|
126
|
-
function getObligationPdaWithArgs(
|
|
134
|
+
export function getObligationPdaWithArgs(
|
|
127
135
|
market: PublicKey,
|
|
128
136
|
user: PublicKey,
|
|
129
137
|
args: InitObligationArgsModel,
|
|
@@ -141,6 +149,31 @@ function getObligationPdaWithArgs(
|
|
|
141
149
|
return obligationAddress;
|
|
142
150
|
}
|
|
143
151
|
|
|
152
|
+
export function getObligationType(
|
|
153
|
+
kaminoMarket: KaminoMarket,
|
|
154
|
+
obligationTag: ObligationTypeTag,
|
|
155
|
+
mintAddress1: PublicKey = PublicKey.default,
|
|
156
|
+
mintAddress2: PublicKey = PublicKey.default
|
|
157
|
+
): ObligationType {
|
|
158
|
+
switch (obligationTag) {
|
|
159
|
+
case VanillaObligation.tag: {
|
|
160
|
+
return new VanillaObligation(kaminoMarket.programId);
|
|
161
|
+
}
|
|
162
|
+
case MultiplyObligation.tag: {
|
|
163
|
+
return new MultiplyObligation(mintAddress1, mintAddress2, kaminoMarket.programId);
|
|
164
|
+
}
|
|
165
|
+
case LeverageObligation.tag: {
|
|
166
|
+
return new LeverageObligation(mintAddress1, mintAddress2, kaminoMarket.programId);
|
|
167
|
+
}
|
|
168
|
+
case LendingObligation.tag: {
|
|
169
|
+
return new LendingObligation(mintAddress1, kaminoMarket.programId);
|
|
170
|
+
}
|
|
171
|
+
default: {
|
|
172
|
+
throw new Error('Invalid obligation type');
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
144
177
|
export function getObligationTypeFromObligation(
|
|
145
178
|
kaminoMarket: KaminoMarket,
|
|
146
179
|
obligation: KaminoObligation
|
|
@@ -148,7 +181,6 @@ export function getObligationTypeFromObligation(
|
|
|
148
181
|
switch (obligation.obligationTag) {
|
|
149
182
|
case VanillaObligation.tag: {
|
|
150
183
|
return new VanillaObligation(kaminoMarket.programId);
|
|
151
|
-
break;
|
|
152
184
|
}
|
|
153
185
|
case MultiplyObligation.tag: {
|
|
154
186
|
return new MultiplyObligation(
|
|
@@ -156,7 +188,6 @@ export function getObligationTypeFromObligation(
|
|
|
156
188
|
obligation.getBorrows()[0].mintAddress,
|
|
157
189
|
kaminoMarket.programId
|
|
158
190
|
);
|
|
159
|
-
break;
|
|
160
191
|
}
|
|
161
192
|
case LeverageObligation.tag: {
|
|
162
193
|
return new LeverageObligation(
|
|
@@ -164,11 +195,9 @@ export function getObligationTypeFromObligation(
|
|
|
164
195
|
obligation.getBorrows()[0].mintAddress,
|
|
165
196
|
kaminoMarket.programId
|
|
166
197
|
);
|
|
167
|
-
break;
|
|
168
198
|
}
|
|
169
199
|
case LendingObligation.tag: {
|
|
170
200
|
return new LendingObligation(obligation.getDeposits()[0].mintAddress, kaminoMarket.programId);
|
|
171
|
-
break;
|
|
172
201
|
}
|
|
173
202
|
default: {
|
|
174
203
|
throw new Error('Invalid obligation type');
|