@kamino-finance/klend-sdk 3.2.19 → 3.2.20
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 +4 -4
- package/dist/classes/action.js +12 -10
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/market.d.ts +18 -2
- package/dist/classes/market.js +0 -32
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.d.ts +8 -4
- package/dist/classes/obligation.js +137 -8
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.d.ts +5 -3
- package/dist/classes/reserve.js +72 -2
- package/dist/classes/reserve.js.map +1 -1
- package/package.json +1 -1
package/dist/classes/action.d.ts
CHANGED
|
@@ -59,13 +59,13 @@ export declare class KaminoAction {
|
|
|
59
59
|
static buildDepositTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
60
60
|
includeAtaIxns?: boolean, // if true it includes create and close wsol and token atas,
|
|
61
61
|
requestElevationGroup?: boolean, includeUserMetadata?: boolean, // if true it includes user metadata
|
|
62
|
-
referrer?: PublicKey, currentSlot?: number, scopeRefresh?: ScopeRefresh): Promise<KaminoAction>;
|
|
62
|
+
referrer?: PublicKey, currentSlot?: number, scopeRefresh?: ScopeRefresh, overrideElevationGroupRequest?: number | undefined): Promise<KaminoAction>;
|
|
63
63
|
getTokenIdsForScopeRefresh(kaminoMarket: KaminoMarket, reserves: PublicKey[]): number[];
|
|
64
64
|
addScopeRefreshIxs(tokens: number[], feed?: string): Promise<void>;
|
|
65
65
|
static buildBorrowTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
66
66
|
includeAtaIxns?: boolean, // if true it includes create and close wsol and token atas,
|
|
67
67
|
requestElevationGroup?: boolean, includeUserMetadata?: boolean, // if true it includes user metadata
|
|
68
|
-
referrer?: PublicKey, currentSlot?: number, scopeRefresh?: ScopeRefresh): Promise<KaminoAction>;
|
|
68
|
+
referrer?: PublicKey, currentSlot?: number, scopeRefresh?: ScopeRefresh, overrideElevationGroupRequest?: number | undefined): Promise<KaminoAction>;
|
|
69
69
|
static buildDepositReserveLiquidityTxns(kaminoMarket: KaminoMarket, amount: string | BN, mint: PublicKey, owner: PublicKey, obligation: KaminoObligation | ObligationType, extraComputeBudget?: number, // if > 0 then adds the ixn
|
|
70
70
|
includeAtaIxns?: boolean, // if true it includes create and close wsol and token atas
|
|
71
71
|
requestElevationGroup?: boolean, includeUserMetadata?: boolean, // if true it includes user metadata
|
|
@@ -132,8 +132,8 @@ export declare class KaminoAction {
|
|
|
132
132
|
addLiquidateIx(maxAllowedLtvOverridePercent?: number): Promise<void>;
|
|
133
133
|
addInBetweenIxs(action: ActionType, includeAtaIxns: boolean, requestElevationGroup: boolean, addInitObligationForFarm: boolean, isClosingPosition?: boolean): Promise<void>;
|
|
134
134
|
addRefreshObligation(crank: PublicKey): void;
|
|
135
|
-
addSupportIxsWithoutInitObligation(action: ActionType, includeAtaIxns: boolean, addAsSupportIx?: AuxiliaryIx, requestElevationGroup?: boolean, addInitObligationForFarm?: boolean, isClosingPosition?: boolean, twoTokenAction?: boolean): Promise<void>;
|
|
136
|
-
addSupportIxs(action: ActionType, includeAtaIxns: boolean, requestElevationGroup: boolean, includeUserMetadata: boolean, addInitObligationForFarm: boolean, twoTokenAction?: boolean): Promise<void>;
|
|
135
|
+
addSupportIxsWithoutInitObligation(action: ActionType, includeAtaIxns: boolean, addAsSupportIx?: AuxiliaryIx, requestElevationGroup?: boolean, addInitObligationForFarm?: boolean, isClosingPosition?: boolean, twoTokenAction?: boolean, overrideElevationGroupRequest?: number): Promise<void>;
|
|
136
|
+
addSupportIxs(action: ActionType, includeAtaIxns: boolean, requestElevationGroup: boolean, includeUserMetadata: boolean, addInitObligationForFarm: boolean, twoTokenAction?: boolean, overrideElevationGroupRequest?: number): Promise<void>;
|
|
137
137
|
private static optionalAccount;
|
|
138
138
|
private addRefreshReserveIxs;
|
|
139
139
|
static getRefreshAllReserves(kaminoMarket: KaminoMarket, reserves: PublicKey[]): TransactionInstruction[];
|
package/dist/classes/action.js
CHANGED
|
@@ -172,7 +172,8 @@ class KaminoAction {
|
|
|
172
172
|
return __awaiter(this, arguments, void 0, function* (kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
|
|
173
173
|
includeAtaIxns = true, // if true it includes create and close wsol and token atas,
|
|
174
174
|
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
|
|
175
|
-
referrer = web3_js_1.PublicKey.default, currentSlot = 0, scopeRefresh = { includeScopeRefresh: false, scopeFeed: 'hubble' }
|
|
175
|
+
referrer = web3_js_1.PublicKey.default, currentSlot = 0, scopeRefresh = { includeScopeRefresh: false, scopeFeed: 'hubble' }, overrideElevationGroupRequest = undefined // if set, when an elevationgroup request is made, it will use this value
|
|
176
|
+
) {
|
|
176
177
|
const axn = yield KaminoAction.initialize('deposit', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
|
|
177
178
|
const addInitObligationForFarm = true;
|
|
178
179
|
if (extraComputeBudget > 0) {
|
|
@@ -187,7 +188,7 @@ class KaminoAction {
|
|
|
187
188
|
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
188
189
|
yield axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
189
190
|
}
|
|
190
|
-
yield axn.addSupportIxs('deposit', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm);
|
|
191
|
+
yield axn.addSupportIxs('deposit', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, undefined, overrideElevationGroupRequest);
|
|
191
192
|
axn.addDepositIx();
|
|
192
193
|
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
193
194
|
return axn;
|
|
@@ -227,7 +228,8 @@ class KaminoAction {
|
|
|
227
228
|
return __awaiter(this, arguments, void 0, function* (kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
|
|
228
229
|
includeAtaIxns = true, // if true it includes create and close wsol and token atas,
|
|
229
230
|
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
|
|
230
|
-
referrer = web3_js_1.PublicKey.default, currentSlot = 0, scopeRefresh = { includeScopeRefresh: false, scopeFeed: 'hubble' }
|
|
231
|
+
referrer = web3_js_1.PublicKey.default, currentSlot = 0, scopeRefresh = { includeScopeRefresh: false, scopeFeed: 'hubble' }, overrideElevationGroupRequest = undefined // if set, when an elevationgroup request is made, it will use this value
|
|
232
|
+
) {
|
|
231
233
|
const axn = yield KaminoAction.initialize('borrow', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
|
|
232
234
|
const addInitObligationForFarm = true;
|
|
233
235
|
if (extraComputeBudget > 0) {
|
|
@@ -242,7 +244,7 @@ class KaminoAction {
|
|
|
242
244
|
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
243
245
|
yield axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
244
246
|
}
|
|
245
|
-
yield axn.addSupportIxs('borrow', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm);
|
|
247
|
+
yield axn.addSupportIxs('borrow', includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, undefined, overrideElevationGroupRequest);
|
|
246
248
|
axn.addBorrowIx();
|
|
247
249
|
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
248
250
|
return axn;
|
|
@@ -877,7 +879,7 @@ class KaminoAction {
|
|
|
877
879
|
this.addRefreshObligationIx(addAllToSetupIxns, false);
|
|
878
880
|
}
|
|
879
881
|
addSupportIxsWithoutInitObligation(action_1, includeAtaIxns_1) {
|
|
880
|
-
return __awaiter(this, arguments, void 0, function* (action, includeAtaIxns, addAsSupportIx = 'setup', requestElevationGroup = false, addInitObligationForFarm = false, isClosingPosition = false, twoTokenAction = false) {
|
|
882
|
+
return __awaiter(this, arguments, void 0, function* (action, includeAtaIxns, addAsSupportIx = 'setup', requestElevationGroup = false, addInitObligationForFarm = false, isClosingPosition = false, twoTokenAction = false, overrideElevationGroupRequest) {
|
|
881
883
|
var _a, _b;
|
|
882
884
|
// TODO: why are we not doing this first?
|
|
883
885
|
if (includeAtaIxns) {
|
|
@@ -1008,7 +1010,7 @@ class KaminoAction {
|
|
|
1008
1010
|
this.addRefreshReserveIxs(allReservesExcludingCurrent, 'cleanup');
|
|
1009
1011
|
// Skip the borrow reserve, since we repay in the same tx
|
|
1010
1012
|
this.addRefreshObligationIx('cleanup', true);
|
|
1011
|
-
this.addRequestElevationIx(0, 'cleanup', true);
|
|
1013
|
+
this.addRequestElevationIx(overrideElevationGroupRequest !== null && overrideElevationGroupRequest !== void 0 ? overrideElevationGroupRequest : 0, 'cleanup', true);
|
|
1012
1014
|
}
|
|
1013
1015
|
}
|
|
1014
1016
|
if ((action === 'depositAndBorrow' || action === 'borrow') && requestElevationGroup) {
|
|
@@ -1037,14 +1039,14 @@ class KaminoAction {
|
|
|
1037
1039
|
return prevGroup.ltvPct > currGroup.ltvPct ? prev : curr;
|
|
1038
1040
|
});
|
|
1039
1041
|
const eModeGroup = groups.find((group) => group.id === eModeGroupWithMaxLtvAndDebtReserve).id;
|
|
1040
|
-
console.log('Setting eModeGroup to', eModeGroup);
|
|
1042
|
+
console.log('Setting eModeGroup to', overrideElevationGroupRequest !== null && overrideElevationGroupRequest !== void 0 ? overrideElevationGroupRequest : eModeGroup);
|
|
1041
1043
|
let addAsSupportIx = 'inBetween';
|
|
1042
1044
|
if (eModeGroup !== 0 && eModeGroup !== ((_b = this.obligation) === null || _b === void 0 ? void 0 : _b.state.elevationGroup)) {
|
|
1043
1045
|
if (action === 'borrow') {
|
|
1044
1046
|
this.obligation.refreshedStats.potentialElevationGroupUpdate = eModeGroup;
|
|
1045
1047
|
addAsSupportIx = 'setup';
|
|
1046
1048
|
}
|
|
1047
|
-
this.addRequestElevationIx(eModeGroup, addAsSupportIx);
|
|
1049
|
+
this.addRequestElevationIx(overrideElevationGroupRequest !== null && overrideElevationGroupRequest !== void 0 ? overrideElevationGroupRequest : eModeGroup, addAsSupportIx);
|
|
1048
1050
|
this.addRefreshReserveIxs(allReservesExcludingCurrent, addAsSupportIx);
|
|
1049
1051
|
this.addRefreshReserveIxs(currentReserveAddresses.toArray(), addAsSupportIx);
|
|
1050
1052
|
this.addRefreshObligationIx(addAsSupportIx);
|
|
@@ -1089,7 +1091,7 @@ class KaminoAction {
|
|
|
1089
1091
|
});
|
|
1090
1092
|
}
|
|
1091
1093
|
addSupportIxs(action_1, includeAtaIxns_1, requestElevationGroup_1, includeUserMetadata_1, addInitObligationForFarm_1) {
|
|
1092
|
-
return __awaiter(this, arguments, void 0, function* (action, includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, twoTokenAction = false) {
|
|
1094
|
+
return __awaiter(this, arguments, void 0, function* (action, includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, twoTokenAction = false, overrideElevationGroupRequest) {
|
|
1093
1095
|
if (!['mint', 'redeem'].includes(action)) {
|
|
1094
1096
|
const [, ownerUserMetadata] = yield this.kaminoMarket.getUserMetadata(this.owner);
|
|
1095
1097
|
if (!ownerUserMetadata && includeUserMetadata) {
|
|
@@ -1098,7 +1100,7 @@ class KaminoAction {
|
|
|
1098
1100
|
yield this.addInitReferrerTokenStateIxs();
|
|
1099
1101
|
yield this.addInitObligationIxs();
|
|
1100
1102
|
}
|
|
1101
|
-
yield this.addSupportIxsWithoutInitObligation(action, includeAtaIxns, 'setup', requestElevationGroup, addInitObligationForFarm, false, twoTokenAction);
|
|
1103
|
+
yield this.addSupportIxsWithoutInitObligation(action, includeAtaIxns, 'setup', requestElevationGroup, addInitObligationForFarm, false, twoTokenAction, overrideElevationGroupRequest);
|
|
1102
1104
|
});
|
|
1103
1105
|
}
|
|
1104
1106
|
static optionalAccount(pubkey, programId = lib_1.PROGRAM_ID) {
|