@kamino-finance/klend-sdk 5.11.5-beta.0 → 5.11.6-beta.0
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/action.d.ts +25 -35
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +225 -350
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/index.d.ts +0 -1
- package/dist/classes/index.d.ts.map +1 -1
- package/dist/classes/index.js +0 -1
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/lut_utils.d.ts +29 -0
- package/dist/classes/lut_utils.d.ts.map +1 -0
- package/dist/classes/lut_utils.js +62 -0
- package/dist/classes/lut_utils.js.map +1 -0
- package/dist/classes/manager.d.ts +1 -6
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +1 -17
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +3 -3
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +16 -30
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.d.ts +1 -3
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +1 -6
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/vault.d.ts +0 -1
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +22 -25
- package/dist/classes/vault.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +3 -6
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +7 -13
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts +1 -25
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.js +1 -43
- package/dist/idl_codegen_kamino_vault/errors/custom.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts +0 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js +0 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts +1 -1
- 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/updateSharesMetadata.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts +0 -13
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js +1 -25
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/index.d.ts +2 -2
- package/dist/idl_codegen_kamino_vault/types/index.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/index.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.js +5 -9
- package/dist/lending_operations/repay_with_collateral_calcs.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.d.ts +4 -9
- package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +8 -35
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.d.ts +2 -2
- package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +6 -11
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/operations.d.ts +7 -9
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +66 -78
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/types.d.ts +4 -4
- package/dist/leverage/types.d.ts.map +1 -1
- package/dist/utils/ObligationType.d.ts +1 -1
- package/dist/utils/ObligationType.d.ts.map +1 -1
- package/dist/utils/constants.d.ts +0 -1
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +1 -2
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/lookupTable.d.ts +0 -27
- package/dist/utils/lookupTable.d.ts.map +1 -1
- package/dist/utils/lookupTable.js +0 -58
- package/dist/utils/lookupTable.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +52 -7
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/oracle.d.ts +3 -3
- package/dist/utils/oracle.d.ts.map +1 -1
- package/dist/utils/oracle.js +3 -4
- package/dist/utils/oracle.js.map +1 -1
- package/dist/utils/seeds.d.ts +1 -11
- package/dist/utils/seeds.d.ts.map +1 -1
- package/dist/utils/seeds.js +3 -13
- package/dist/utils/seeds.js.map +1 -1
- package/dist/utils/userMetadata.d.ts.map +1 -1
- package/dist/utils/userMetadata.js +7 -8
- package/dist/utils/userMetadata.js.map +1 -1
- package/package.json +2 -2
- package/src/classes/action.ts +261 -504
- package/src/classes/index.ts +0 -1
- package/src/classes/lut_utils.ts +63 -0
- package/src/classes/manager.ts +1 -30
- package/src/classes/market.ts +25 -34
- package/src/classes/obligation.ts +1 -7
- package/src/classes/vault.ts +23 -24
- package/src/client.ts +3 -8
- package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +9 -17
- package/src/idl_codegen_kamino_vault/errors/custom.ts +0 -42
- package/src/idl_codegen_kamino_vault/instructions/giveUpPendingFees.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/initVault.ts +0 -2
- package/src/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/updateReserveAllocation.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/updateSharesMetadata.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/updateVaultConfig.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/withdrawPendingFees.ts +2 -2
- package/src/idl_codegen_kamino_vault/types/VaultConfigField.ts +0 -30
- package/src/idl_codegen_kamino_vault/types/index.ts +0 -2
- package/src/idl_kamino_vault.json +8 -35
- package/src/lending_operations/repay_with_collateral_calcs.ts +5 -14
- package/src/lending_operations/repay_with_collateral_operations.ts +29 -76
- package/src/lending_operations/swap_collateral_operations.ts +7 -19
- package/src/leverage/operations.ts +66 -114
- package/src/leverage/types.ts +4 -4
- package/src/utils/ObligationType.ts +1 -1
- package/src/utils/constants.ts +0 -1
- package/src/utils/lookupTable.ts +0 -62
- package/src/utils/managerTypes.ts +52 -10
- package/src/utils/oracle.ts +6 -7
- package/src/utils/seeds.ts +4 -14
- package/src/utils/userMetadata.ts +15 -16
package/src/utils/lookupTable.ts
CHANGED
|
@@ -53,65 +53,3 @@ export const extendLookupTableIxs = (
|
|
|
53
53
|
|
|
54
54
|
return extendLookupIxs;
|
|
55
55
|
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* This method retuns an instruction that creates a lookup table, alongside the pubkey of the lookup table
|
|
59
|
-
* @param payer - the owner of the lookup table
|
|
60
|
-
* @param slot - the current slot
|
|
61
|
-
* @returns - the instruction to create the lookup table and its address
|
|
62
|
-
*/
|
|
63
|
-
export function initLookupTableIx(payer: PublicKey, slot: number): [TransactionInstruction, PublicKey] {
|
|
64
|
-
const [ixn, address] = AddressLookupTableProgram.createLookupTable({
|
|
65
|
-
authority: payer,
|
|
66
|
-
payer,
|
|
67
|
-
recentSlot: slot,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
return [ixn, address];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* This method retuns an instruction that deactivates a lookup table, which is needed to close it
|
|
75
|
-
* @param payer - the owner of the lookup table
|
|
76
|
-
* @param lookupTable - the lookup table to deactivate
|
|
77
|
-
* @returns - the instruction to deactivate the lookup table
|
|
78
|
-
*/
|
|
79
|
-
export function deactivateLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction {
|
|
80
|
-
const ixn = AddressLookupTableProgram.deactivateLookupTable({
|
|
81
|
-
authority: payer,
|
|
82
|
-
lookupTable: lookupTable,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
return ixn;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* This method returns an instruction that closes a lookup table. That lookup table needs to be disabled at least 500 blocks before closing it.
|
|
90
|
-
* @param payer - the owner of the lookup table
|
|
91
|
-
* @param lookupTable - the lookup table to close
|
|
92
|
-
* @returns - the instruction to close the lookup table
|
|
93
|
-
*/
|
|
94
|
-
/// this require the LUT to be deactivated at least 500 blocks before
|
|
95
|
-
export function closeLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction {
|
|
96
|
-
const ixn = AddressLookupTableProgram.closeLookupTable({
|
|
97
|
-
authority: payer,
|
|
98
|
-
recipient: payer,
|
|
99
|
-
lookupTable: lookupTable,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
return ixn;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Returns the accounts in a lookup table
|
|
107
|
-
* @param lookupTable - lookup table to get the accounts from
|
|
108
|
-
* @returns - an array of accounts in the lookup table
|
|
109
|
-
*/
|
|
110
|
-
export async function getAccountsInLUT(connection: Connection, lookupTable: PublicKey): Promise<PublicKey[]> {
|
|
111
|
-
const lutState = await connection.getAddressLookupTable(lookupTable);
|
|
112
|
-
if (!lutState || !lutState.value) {
|
|
113
|
-
throw new Error(`Lookup table ${lookupTable} not found`);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return lutState.value.state.addresses;
|
|
117
|
-
}
|
|
@@ -397,17 +397,59 @@ export function getReserveOracleConfigs(priceFeed: PriceFeed | null): {
|
|
|
397
397
|
};
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
-
const ORACLE_TYPE_MAP = Object.fromEntries(
|
|
401
|
-
Object.values(OracleType)
|
|
402
|
-
// Filter for oracle types that have a discriminator property
|
|
403
|
-
// This ensures we only include actual oracle implementations in the mapping
|
|
404
|
-
// Pyth is used as a type assertion here but actually any oracle type with a discriminator will pass
|
|
405
|
-
.filter((T): T is typeof OracleType.Pyth => 'discriminator' in T)
|
|
406
|
-
.map((T) => [T.discriminator, T.name])
|
|
407
|
-
);
|
|
408
|
-
|
|
409
400
|
export function parseOracleType(type: number): string {
|
|
410
|
-
|
|
401
|
+
switch (type) {
|
|
402
|
+
case new OracleType.Pyth().discriminator:
|
|
403
|
+
return 'Pyth';
|
|
404
|
+
case new OracleType.SwitchboardV2().discriminator:
|
|
405
|
+
return 'SwitchboardV2';
|
|
406
|
+
case new OracleType.CToken().discriminator:
|
|
407
|
+
return 'CToken';
|
|
408
|
+
case new OracleType.KToken().discriminator:
|
|
409
|
+
return 'KToken';
|
|
410
|
+
case new OracleType.SplStake().discriminator:
|
|
411
|
+
return 'SplStake';
|
|
412
|
+
case new OracleType.PythEMA().discriminator:
|
|
413
|
+
return 'PythEMA';
|
|
414
|
+
case new OracleType.DeprecatedPlaceholder1().discriminator:
|
|
415
|
+
return 'DeprecatedPlaceholder1';
|
|
416
|
+
case new OracleType.DeprecatedPlaceholder2().discriminator:
|
|
417
|
+
return 'DeprecatedPlaceholder2';
|
|
418
|
+
case new OracleType.MsolStake().discriminator:
|
|
419
|
+
return 'MsolStake';
|
|
420
|
+
case new OracleType.KTokenToTokenA().discriminator:
|
|
421
|
+
return 'KTokenToTokenA';
|
|
422
|
+
case new OracleType.KTokenToTokenB().discriminator:
|
|
423
|
+
return 'KTokenToTokenB';
|
|
424
|
+
case new OracleType.JupiterLpFetch().discriminator:
|
|
425
|
+
return 'JupiterLpFetch';
|
|
426
|
+
case new OracleType.ScopeTwap().discriminator:
|
|
427
|
+
return 'ScopeTwap';
|
|
428
|
+
case new OracleType.OrcaWhirlpoolAtoB().discriminator:
|
|
429
|
+
return 'OrcaWhirlpoolAtoB';
|
|
430
|
+
case new OracleType.OrcaWhirlpoolBtoA().discriminator:
|
|
431
|
+
return 'OrcaWhirlpoolBtoA';
|
|
432
|
+
case new OracleType.RaydiumAmmV3AtoB().discriminator:
|
|
433
|
+
return 'RaydiumAmmV3AtoB';
|
|
434
|
+
case new OracleType.RaydiumAmmV3BtoA().discriminator:
|
|
435
|
+
return 'RaydiumAmmV3BtoA';
|
|
436
|
+
case new OracleType.JupiterLpCompute().discriminator:
|
|
437
|
+
return 'JupiterLpCompute';
|
|
438
|
+
case new OracleType.MeteoraDlmmAtoB().discriminator:
|
|
439
|
+
return 'MeteoraDlmmAtoB';
|
|
440
|
+
case new OracleType.MeteoraDlmmBtoA().discriminator:
|
|
441
|
+
return 'MeteoraDlmmBtoA';
|
|
442
|
+
case new OracleType.JupiterLpScope().discriminator:
|
|
443
|
+
return 'JupiterLpScope';
|
|
444
|
+
case new OracleType.PythPullBased().discriminator:
|
|
445
|
+
return 'PythPullBased';
|
|
446
|
+
case new OracleType.PythPullBasedEMA().discriminator:
|
|
447
|
+
return 'PythPullBasedEMA';
|
|
448
|
+
case new OracleType.FixedPrice().discriminator:
|
|
449
|
+
return 'FixedPrice';
|
|
450
|
+
default:
|
|
451
|
+
return 'Unknown';
|
|
452
|
+
}
|
|
411
453
|
}
|
|
412
454
|
|
|
413
455
|
export type MarketWithAddress = {
|
package/src/utils/oracle.ts
CHANGED
|
@@ -35,8 +35,8 @@ export type CandidatePrice = {
|
|
|
35
35
|
valid: boolean;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
export type
|
|
39
|
-
|
|
38
|
+
export type ScopeRefresh = {
|
|
39
|
+
includeScopeRefresh: boolean;
|
|
40
40
|
scopeFeed: string;
|
|
41
41
|
};
|
|
42
42
|
|
|
@@ -170,11 +170,10 @@ export function cacheOrGetPythPrices(
|
|
|
170
170
|
const { price, exponent, conf: confidence, publishTime: timestamp, emaPrice } = priceMessage;
|
|
171
171
|
if (price) {
|
|
172
172
|
const px = new Decimal(price.toString()).div(10 ** Math.abs(exponent));
|
|
173
|
-
const conf = new Decimal(confidence.toString());
|
|
174
173
|
prices.spot = {
|
|
175
174
|
price: px,
|
|
176
175
|
timestamp: BigInt(timestamp.toString()),
|
|
177
|
-
valid: validatePythPx(px,
|
|
176
|
+
valid: validatePythPx(px, confidence.toNumber()),
|
|
178
177
|
};
|
|
179
178
|
}
|
|
180
179
|
if (emaPrice !== undefined && emaPrice !== null) {
|
|
@@ -298,9 +297,9 @@ function isBetterPrice(current: CandidatePrice | undefined, next: CandidatePrice
|
|
|
298
297
|
return next.timestamp > current.timestamp;
|
|
299
298
|
}
|
|
300
299
|
|
|
301
|
-
function validatePythPx(price: Decimal, confidence:
|
|
302
|
-
const conf50x = confidence.mul(CONFIDENCE_FACTOR);
|
|
303
|
-
return
|
|
300
|
+
function validatePythPx(price: Decimal, confidence: number | undefined): boolean {
|
|
301
|
+
const conf50x = new Decimal(confidence || 0).mul(CONFIDENCE_FACTOR);
|
|
302
|
+
return price.gt(conf50x);
|
|
304
303
|
}
|
|
305
304
|
|
|
306
305
|
function validateSwitchboardV2Px(agg: any): boolean {
|
package/src/utils/seeds.ts
CHANGED
|
@@ -38,10 +38,6 @@ export const BASE_SEED_REFERRER_STATE = 'ref_state';
|
|
|
38
38
|
* Short url seed
|
|
39
39
|
*/
|
|
40
40
|
export const BASE_SEED_SHORT_URL = 'short_url';
|
|
41
|
-
/**
|
|
42
|
-
* Farm user state seed
|
|
43
|
-
*/
|
|
44
|
-
export const BASE_SEED_USER_STATE = 'user';
|
|
45
41
|
|
|
46
42
|
/**
|
|
47
43
|
* User farm state seed
|
|
@@ -192,15 +188,9 @@ export function shortUrlPda(shortUrl: string, programId: PublicKey = PROGRAM_ID)
|
|
|
192
188
|
return PublicKey.findProgramAddressSync([Buffer.from(BASE_SEED_SHORT_URL), Buffer.from(shortUrl)], programId);
|
|
193
189
|
}
|
|
194
190
|
|
|
195
|
-
|
|
196
|
-
* Returns the PDA for the obligation farm state
|
|
197
|
-
* @param farm
|
|
198
|
-
* @param obligation
|
|
199
|
-
* @returns pda
|
|
200
|
-
*/
|
|
201
|
-
export function obligationFarmStatePda(farm: PublicKey, obligation: PublicKey) {
|
|
191
|
+
export function obligationFarmStatePda(obligation: PublicKey, farm: PublicKey, programId: PublicKey = farmsId) {
|
|
202
192
|
return PublicKey.findProgramAddressSync(
|
|
203
|
-
[Buffer.from(
|
|
204
|
-
|
|
205
|
-
)
|
|
193
|
+
[Buffer.from(BASE_SEED_FARM_USER_STATE), farm.toBuffer(), obligation.toBuffer()],
|
|
194
|
+
programId
|
|
195
|
+
);
|
|
206
196
|
}
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
Connection,
|
|
7
7
|
GetProgramAccountsFilter,
|
|
8
8
|
} from '@solana/web3.js';
|
|
9
|
-
import { NATIVE_MINT } from '@solana/spl-token';
|
|
10
9
|
import { KaminoMarket, KaminoObligation } from '../classes';
|
|
11
10
|
import {
|
|
12
11
|
LeverageObligation,
|
|
@@ -259,7 +258,7 @@ function getMultiplyObligationAndObligationFarmStateAddresses(
|
|
|
259
258
|
const collMintString = collMint.toString();
|
|
260
259
|
const debtMintString = debtMint.toString();
|
|
261
260
|
if (collReserve && debtReserve) {
|
|
262
|
-
const multiplyObligation = new MultiplyObligation(collMint,
|
|
261
|
+
const multiplyObligation = new MultiplyObligation(collMint, debtMint, kaminoMarket.programId);
|
|
263
262
|
obligationPdas.push({
|
|
264
263
|
address: multiplyObligation.toPda(kaminoMarket.getAddress(), user),
|
|
265
264
|
log: 'multiply obligation coll: ' + collMintString + ' debt: ' + debtMintString,
|
|
@@ -267,18 +266,18 @@ function getMultiplyObligationAndObligationFarmStateAddresses(
|
|
|
267
266
|
if (!collReserve.state.farmCollateral.equals(PublicKey.default)) {
|
|
268
267
|
farmUserStates.push({
|
|
269
268
|
address: obligationFarmStatePda(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
),
|
|
269
|
+
multiplyObligation.toPda(kaminoMarket.getAddress(), user),
|
|
270
|
+
collReserve.state.farmCollateral!
|
|
271
|
+
)[0],
|
|
273
272
|
log: 'collReserve farmState for multiply obligation coll: ' + collMintString + ' debt: ' + debtMintString,
|
|
274
273
|
});
|
|
275
274
|
}
|
|
276
275
|
if (!debtReserve.state.farmDebt.equals(PublicKey.default)) {
|
|
277
276
|
farmUserStates.push({
|
|
278
277
|
address: obligationFarmStatePda(
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
),
|
|
278
|
+
multiplyObligation.toPda(kaminoMarket.getAddress(), user),
|
|
279
|
+
debtReserve.state.farmDebt!
|
|
280
|
+
)[0],
|
|
282
281
|
log: 'debtReserve farmState for multiply obligation coll: ' + collMintString + ' debt: ' + debtMintString,
|
|
283
282
|
});
|
|
284
283
|
}
|
|
@@ -310,18 +309,18 @@ function getLeverageObligationAndObligationFarmStateAddresses(
|
|
|
310
309
|
if (!collReserve.state.farmCollateral.equals(PublicKey.default)) {
|
|
311
310
|
farmUserStates.push({
|
|
312
311
|
address: obligationFarmStatePda(
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
),
|
|
312
|
+
leverageObligation.toPda(kaminoMarket.getAddress(), user),
|
|
313
|
+
collReserve.state.farmCollateral!
|
|
314
|
+
)[0],
|
|
316
315
|
log: 'collReserve farmState for leverage obligation coll: ' + collMintString + ' debt: ' + debtMintString,
|
|
317
316
|
});
|
|
318
317
|
}
|
|
319
318
|
if (!debtReserve.state.farmDebt.equals(PublicKey.default)) {
|
|
320
319
|
farmUserStates.push({
|
|
321
320
|
address: obligationFarmStatePda(
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
),
|
|
321
|
+
leverageObligation.toPda(kaminoMarket.getAddress(), user),
|
|
322
|
+
debtReserve.state.farmDebt!
|
|
323
|
+
)[0],
|
|
325
324
|
log: 'debtReserve farmState for leverage obligation coll: ' + collMintString + ' debt: ' + debtMintString,
|
|
326
325
|
});
|
|
327
326
|
}
|
|
@@ -342,7 +341,7 @@ function getRepayWithCollObligationFarmStateAddresses(
|
|
|
342
341
|
const borrowReserve = kaminoMarket.getReserveByMint(borrow.mintAddress)!;
|
|
343
342
|
if (!borrowReserve.state.farmDebt.equals(PublicKey.default)) {
|
|
344
343
|
farmUserStates.push({
|
|
345
|
-
address: obligationFarmStatePda(borrowReserve.state.farmDebt
|
|
344
|
+
address: obligationFarmStatePda(obligation.obligationAddress, borrowReserve.state.farmDebt!)[0],
|
|
346
345
|
log: 'debtReserve farmState for vanilla obligation: ' + obligationString,
|
|
347
346
|
});
|
|
348
347
|
}
|
|
@@ -352,7 +351,7 @@ function getRepayWithCollObligationFarmStateAddresses(
|
|
|
352
351
|
const depositReserve = kaminoMarket.getReserveByMint(deposit.mintAddress)!;
|
|
353
352
|
if (!depositReserve.state.farmCollateral.equals(PublicKey.default)) {
|
|
354
353
|
farmUserStates.push({
|
|
355
|
-
address: obligationFarmStatePda(depositReserve.state.farmCollateral
|
|
354
|
+
address: obligationFarmStatePda(obligation.obligationAddress, depositReserve.state.farmCollateral!)[0],
|
|
356
355
|
log: 'collReserve farmState for vanilla obligation' + obligationString,
|
|
357
356
|
});
|
|
358
357
|
}
|