@kamino-finance/klend-sdk 5.10.35-beta.0 → 5.10.35-beta.1
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 +26 -24
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +270 -501
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.js +1 -1
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/obligation.d.ts +1 -1
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +1 -1
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/vault.js +6 -6
- package/dist/classes/vault.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 +9 -5
- package/dist/lending_operations/repay_with_collateral_calcs.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.d.ts +7 -3
- package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +27 -7
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.d.ts +0 -5
- package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +2 -4
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/operations.d.ts +8 -8
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +24 -27
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/types.d.ts +1 -4
- package/dist/leverage/types.d.ts.map +1 -1
- package/dist/utils/lookupTable.d.ts +27 -0
- package/dist/utils/lookupTable.d.ts.map +1 -1
- package/dist/utils/lookupTable.js +58 -0
- package/dist/utils/lookupTable.js.map +1 -1
- package/dist/utils/seeds.d.ts +9 -3
- package/dist/utils/seeds.d.ts.map +1 -1
- package/dist/utils/seeds.js +11 -5
- package/dist/utils/seeds.js.map +1 -1
- package/dist/utils/userMetadata.js +6 -6
- package/dist/utils/userMetadata.js.map +1 -1
- package/package.json +1 -4
- package/src/classes/action.ts +423 -662
- package/src/classes/manager.ts +1 -1
- package/src/classes/obligation.ts +1 -1
- package/src/classes/vault.ts +1 -1
- package/src/client.ts +3 -7
- package/src/lending_operations/repay_with_collateral_calcs.ts +14 -5
- package/src/lending_operations/repay_with_collateral_operations.ts +30 -14
- package/src/lending_operations/swap_collateral_operations.ts +0 -11
- package/src/leverage/operations.ts +11 -38
- package/src/leverage/types.ts +1 -4
- package/src/utils/lookupTable.ts +62 -0
- package/src/utils/seeds.ts +12 -7
- package/src/utils/userMetadata.ts +14 -14
- package/dist/classes/lut_utils.d.ts +0 -29
- package/dist/classes/lut_utils.d.ts.map +0 -1
- package/dist/classes/lut_utils.js +0 -62
- package/dist/classes/lut_utils.js.map +0 -1
- package/src/classes/lut_utils.ts +0 -63
|
@@ -267,18 +267,18 @@ function getMultiplyObligationAndObligationFarmStateAddresses(
|
|
|
267
267
|
if (!collReserve.state.farmCollateral.equals(PublicKey.default)) {
|
|
268
268
|
farmUserStates.push({
|
|
269
269
|
address: obligationFarmStatePda(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
)
|
|
270
|
+
collReserve.state.farmCollateral!,
|
|
271
|
+
multiplyObligation.toPda(kaminoMarket.getAddress(), user)
|
|
272
|
+
),
|
|
273
273
|
log: 'collReserve farmState for multiply obligation coll: ' + collMintString + ' debt: ' + debtMintString,
|
|
274
274
|
});
|
|
275
275
|
}
|
|
276
276
|
if (!debtReserve.state.farmDebt.equals(PublicKey.default)) {
|
|
277
277
|
farmUserStates.push({
|
|
278
278
|
address: obligationFarmStatePda(
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
)
|
|
279
|
+
debtReserve.state.farmDebt!,
|
|
280
|
+
multiplyObligation.toPda(kaminoMarket.getAddress(), user)
|
|
281
|
+
),
|
|
282
282
|
log: 'debtReserve farmState for multiply obligation coll: ' + collMintString + ' debt: ' + debtMintString,
|
|
283
283
|
});
|
|
284
284
|
}
|
|
@@ -310,18 +310,18 @@ function getLeverageObligationAndObligationFarmStateAddresses(
|
|
|
310
310
|
if (!collReserve.state.farmCollateral.equals(PublicKey.default)) {
|
|
311
311
|
farmUserStates.push({
|
|
312
312
|
address: obligationFarmStatePda(
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
)
|
|
313
|
+
collReserve.state.farmCollateral!,
|
|
314
|
+
leverageObligation.toPda(kaminoMarket.getAddress(), user)
|
|
315
|
+
),
|
|
316
316
|
log: 'collReserve farmState for leverage obligation coll: ' + collMintString + ' debt: ' + debtMintString,
|
|
317
317
|
});
|
|
318
318
|
}
|
|
319
319
|
if (!debtReserve.state.farmDebt.equals(PublicKey.default)) {
|
|
320
320
|
farmUserStates.push({
|
|
321
321
|
address: obligationFarmStatePda(
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
)
|
|
322
|
+
debtReserve.state.farmDebt!,
|
|
323
|
+
leverageObligation.toPda(kaminoMarket.getAddress(), user)
|
|
324
|
+
),
|
|
325
325
|
log: 'debtReserve farmState for leverage obligation coll: ' + collMintString + ' debt: ' + debtMintString,
|
|
326
326
|
});
|
|
327
327
|
}
|
|
@@ -342,7 +342,7 @@ function getRepayWithCollObligationFarmStateAddresses(
|
|
|
342
342
|
const borrowReserve = kaminoMarket.getReserveByMint(borrow.mintAddress)!;
|
|
343
343
|
if (!borrowReserve.state.farmDebt.equals(PublicKey.default)) {
|
|
344
344
|
farmUserStates.push({
|
|
345
|
-
address: obligationFarmStatePda(
|
|
345
|
+
address: obligationFarmStatePda(borrowReserve.state.farmDebt!, obligation.obligationAddress),
|
|
346
346
|
log: 'debtReserve farmState for vanilla obligation: ' + obligationString,
|
|
347
347
|
});
|
|
348
348
|
}
|
|
@@ -352,7 +352,7 @@ function getRepayWithCollObligationFarmStateAddresses(
|
|
|
352
352
|
const depositReserve = kaminoMarket.getReserveByMint(deposit.mintAddress)!;
|
|
353
353
|
if (!depositReserve.state.farmCollateral.equals(PublicKey.default)) {
|
|
354
354
|
farmUserStates.push({
|
|
355
|
-
address: obligationFarmStatePda(
|
|
355
|
+
address: obligationFarmStatePda(depositReserve.state.farmCollateral!, obligation.obligationAddress),
|
|
356
356
|
log: 'collReserve farmState for vanilla obligation' + obligationString,
|
|
357
357
|
});
|
|
358
358
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
-
/**
|
|
3
|
-
* This method retuns an instruction that creates a lookup table, alongside the pubkey of the lookup table
|
|
4
|
-
* @param payer - the owner of the lookup table
|
|
5
|
-
* @param slot - the current slot
|
|
6
|
-
* @returns - the instruction to create the lookup table and its address
|
|
7
|
-
*/
|
|
8
|
-
export declare function initLookupTableIx(payer: PublicKey, slot: number): [TransactionInstruction, PublicKey];
|
|
9
|
-
/**
|
|
10
|
-
* This method retuns an instruction that deactivates a lookup table, which is needed to close it
|
|
11
|
-
* @param payer - the owner of the lookup table
|
|
12
|
-
* @param lookupTable - the lookup table to deactivate
|
|
13
|
-
* @returns - the instruction to deactivate the lookup table
|
|
14
|
-
*/
|
|
15
|
-
export declare function deactivateLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction;
|
|
16
|
-
/**
|
|
17
|
-
* This method returns an instruction that closes a lookup table. That lookup table needs to be disabled at least 500 blocks before closing it.
|
|
18
|
-
* @param payer - the owner of the lookup table
|
|
19
|
-
* @param lookupTable - the lookup table to close
|
|
20
|
-
* @returns - the instruction to close the lookup table
|
|
21
|
-
*/
|
|
22
|
-
export declare function closeLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction;
|
|
23
|
-
/**
|
|
24
|
-
* Returns the accounts in a lookup table
|
|
25
|
-
* @param lookupTable - lookup table to get the accounts from
|
|
26
|
-
* @returns - an array of accounts in the lookup table
|
|
27
|
-
*/
|
|
28
|
-
export declare function getAccountsInLUT(connection: Connection, lookupTable: PublicKey): Promise<PublicKey[]>;
|
|
29
|
-
//# sourceMappingURL=lut_utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lut_utils.d.ts","sourceRoot":"","sources":["../../src/classes/lut_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,UAAU,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE3G;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAQrG;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,GAAG,sBAAsB,CAOxG;AAED;;;;;GAKG;AAEH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,GAAG,sBAAsB,CAQnG;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAO3G"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initLookupTableIx = initLookupTableIx;
|
|
4
|
-
exports.deactivateLookupTableIx = deactivateLookupTableIx;
|
|
5
|
-
exports.closeLookupTableIx = closeLookupTableIx;
|
|
6
|
-
exports.getAccountsInLUT = getAccountsInLUT;
|
|
7
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
8
|
-
/**
|
|
9
|
-
* This method retuns an instruction that creates a lookup table, alongside the pubkey of the lookup table
|
|
10
|
-
* @param payer - the owner of the lookup table
|
|
11
|
-
* @param slot - the current slot
|
|
12
|
-
* @returns - the instruction to create the lookup table and its address
|
|
13
|
-
*/
|
|
14
|
-
function initLookupTableIx(payer, slot) {
|
|
15
|
-
const [ixn, address] = web3_js_1.AddressLookupTableProgram.createLookupTable({
|
|
16
|
-
authority: payer,
|
|
17
|
-
payer,
|
|
18
|
-
recentSlot: slot,
|
|
19
|
-
});
|
|
20
|
-
return [ixn, address];
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* This method retuns an instruction that deactivates a lookup table, which is needed to close it
|
|
24
|
-
* @param payer - the owner of the lookup table
|
|
25
|
-
* @param lookupTable - the lookup table to deactivate
|
|
26
|
-
* @returns - the instruction to deactivate the lookup table
|
|
27
|
-
*/
|
|
28
|
-
function deactivateLookupTableIx(payer, lookupTable) {
|
|
29
|
-
const ixn = web3_js_1.AddressLookupTableProgram.deactivateLookupTable({
|
|
30
|
-
authority: payer,
|
|
31
|
-
lookupTable: lookupTable,
|
|
32
|
-
});
|
|
33
|
-
return ixn;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* This method returns an instruction that closes a lookup table. That lookup table needs to be disabled at least 500 blocks before closing it.
|
|
37
|
-
* @param payer - the owner of the lookup table
|
|
38
|
-
* @param lookupTable - the lookup table to close
|
|
39
|
-
* @returns - the instruction to close the lookup table
|
|
40
|
-
*/
|
|
41
|
-
/// this require the LUT to be deactivated at least 500 blocks before
|
|
42
|
-
function closeLookupTableIx(payer, lookupTable) {
|
|
43
|
-
const ixn = web3_js_1.AddressLookupTableProgram.closeLookupTable({
|
|
44
|
-
authority: payer,
|
|
45
|
-
recipient: payer,
|
|
46
|
-
lookupTable: lookupTable,
|
|
47
|
-
});
|
|
48
|
-
return ixn;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Returns the accounts in a lookup table
|
|
52
|
-
* @param lookupTable - lookup table to get the accounts from
|
|
53
|
-
* @returns - an array of accounts in the lookup table
|
|
54
|
-
*/
|
|
55
|
-
async function getAccountsInLUT(connection, lookupTable) {
|
|
56
|
-
const lutState = await connection.getAddressLookupTable(lookupTable);
|
|
57
|
-
if (!lutState || !lutState.value) {
|
|
58
|
-
throw new Error(`Lookup table ${lookupTable} not found`);
|
|
59
|
-
}
|
|
60
|
-
return lutState.value.state.addresses;
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=lut_utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lut_utils.js","sourceRoot":"","sources":["../../src/classes/lut_utils.ts"],"names":[],"mappings":";;AAQA,8CAQC;AAQD,0DAOC;AASD,gDAQC;AAOD,4CAOC;AA9DD,6CAA2G;AAE3G;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,KAAgB,EAAE,IAAY;IAC9D,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,mCAAyB,CAAC,iBAAiB,CAAC;QACjE,SAAS,EAAE,KAAK;QAChB,KAAK;QACL,UAAU,EAAE,IAAI;KACjB,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACxB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,KAAgB,EAAE,WAAsB;IAC9E,MAAM,GAAG,GAAG,mCAAyB,CAAC,qBAAqB,CAAC;QAC1D,SAAS,EAAE,KAAK;QAChB,WAAW,EAAE,WAAW;KACzB,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,qEAAqE;AACrE,SAAgB,kBAAkB,CAAC,KAAgB,EAAE,WAAsB;IACzE,MAAM,GAAG,GAAG,mCAAyB,CAAC,gBAAgB,CAAC;QACrD,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,KAAK;QAChB,WAAW,EAAE,WAAW;KACzB,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,gBAAgB,CAAC,UAAsB,EAAE,WAAsB;IACnF,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;IACrE,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,gBAAgB,WAAW,YAAY,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC;AACxC,CAAC"}
|
package/src/classes/lut_utils.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { AddressLookupTableProgram, Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This method retuns an instruction that creates a lookup table, alongside the pubkey of the lookup table
|
|
5
|
-
* @param payer - the owner of the lookup table
|
|
6
|
-
* @param slot - the current slot
|
|
7
|
-
* @returns - the instruction to create the lookup table and its address
|
|
8
|
-
*/
|
|
9
|
-
export function initLookupTableIx(payer: PublicKey, slot: number): [TransactionInstruction, PublicKey] {
|
|
10
|
-
const [ixn, address] = AddressLookupTableProgram.createLookupTable({
|
|
11
|
-
authority: payer,
|
|
12
|
-
payer,
|
|
13
|
-
recentSlot: slot,
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
return [ixn, address];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* This method retuns an instruction that deactivates a lookup table, which is needed to close it
|
|
21
|
-
* @param payer - the owner of the lookup table
|
|
22
|
-
* @param lookupTable - the lookup table to deactivate
|
|
23
|
-
* @returns - the instruction to deactivate the lookup table
|
|
24
|
-
*/
|
|
25
|
-
export function deactivateLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction {
|
|
26
|
-
const ixn = AddressLookupTableProgram.deactivateLookupTable({
|
|
27
|
-
authority: payer,
|
|
28
|
-
lookupTable: lookupTable,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
return ixn;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* This method returns an instruction that closes a lookup table. That lookup table needs to be disabled at least 500 blocks before closing it.
|
|
36
|
-
* @param payer - the owner of the lookup table
|
|
37
|
-
* @param lookupTable - the lookup table to close
|
|
38
|
-
* @returns - the instruction to close the lookup table
|
|
39
|
-
*/
|
|
40
|
-
/// this require the LUT to be deactivated at least 500 blocks before
|
|
41
|
-
export function closeLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction {
|
|
42
|
-
const ixn = AddressLookupTableProgram.closeLookupTable({
|
|
43
|
-
authority: payer,
|
|
44
|
-
recipient: payer,
|
|
45
|
-
lookupTable: lookupTable,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
return ixn;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Returns the accounts in a lookup table
|
|
53
|
-
* @param lookupTable - lookup table to get the accounts from
|
|
54
|
-
* @returns - an array of accounts in the lookup table
|
|
55
|
-
*/
|
|
56
|
-
export async function getAccountsInLUT(connection: Connection, lookupTable: PublicKey): Promise<PublicKey[]> {
|
|
57
|
-
const lutState = await connection.getAddressLookupTable(lookupTable);
|
|
58
|
-
if (!lutState || !lutState.value) {
|
|
59
|
-
throw new Error(`Lookup table ${lookupTable} not found`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return lutState.value.state.addresses;
|
|
63
|
-
}
|