@kamino-finance/klend-sdk 5.12.7 → 5.13.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 +2 -2
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +5 -3
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +10 -0
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +17 -10
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.d.ts +2 -2
- package/dist/classes/obligation.js +1 -1
- package/dist/classes/obligationOrder.d.ts +30 -7
- package/dist/classes/obligationOrder.d.ts.map +1 -1
- package/dist/classes/obligationOrder.js +47 -12
- package/dist/classes/obligationOrder.js.map +1 -1
- package/dist/classes/utils.d.ts +0 -1
- package/dist/classes/utils.d.ts.map +1 -1
- package/dist/classes/utils.js +0 -7
- package/dist/classes/utils.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +1 -1
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/operations.js +4 -4
- package/dist/leverage/operations.js.map +1 -1
- package/dist/lib.d.ts +1 -0
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +1 -0
- package/dist/lib.js.map +1 -1
- package/dist/obligation_orders/common.d.ts +62 -0
- package/dist/obligation_orders/common.d.ts.map +1 -0
- package/dist/obligation_orders/common.js +20 -0
- package/dist/obligation_orders/common.js.map +1 -0
- package/dist/obligation_orders/index.d.ts +4 -0
- package/dist/obligation_orders/index.d.ts.map +1 -0
- package/dist/obligation_orders/index.js +20 -0
- package/dist/obligation_orders/index.js.map +1 -0
- package/dist/obligation_orders/internal.d.ts +6 -0
- package/dist/obligation_orders/internal.d.ts.map +1 -0
- package/dist/obligation_orders/internal.js +72 -0
- package/dist/obligation_orders/internal.js.map +1 -0
- package/dist/obligation_orders/ltv_based.d.ts +51 -0
- package/dist/obligation_orders/ltv_based.d.ts.map +1 -0
- package/dist/obligation_orders/ltv_based.js +107 -0
- package/dist/obligation_orders/ltv_based.js.map +1 -0
- package/dist/obligation_orders/price_based.d.ts +81 -0
- package/dist/obligation_orders/price_based.d.ts.map +1 -0
- package/dist/obligation_orders/price_based.js +167 -0
- package/dist/obligation_orders/price_based.js.map +1 -0
- package/dist/utils/instruction.d.ts +1 -1
- package/dist/utils/instruction.d.ts.map +1 -1
- package/dist/utils/instruction.js +3 -2
- package/dist/utils/instruction.js.map +1 -1
- package/dist/utils/validations.d.ts +5 -0
- package/dist/utils/validations.d.ts.map +1 -0
- package/dist/utils/validations.js +36 -0
- package/dist/utils/validations.js.map +1 -0
- package/package.json +1 -1
- package/src/classes/action.ts +6 -4
- package/src/classes/manager.ts +1 -4
- package/src/classes/market.ts +21 -11
- package/src/classes/obligation.ts +2 -2
- package/src/classes/obligationOrder.ts +57 -20
- package/src/classes/utils.ts +0 -7
- package/src/lending_operations/repay_with_collateral_operations.ts +2 -2
- package/src/lending_operations/swap_collateral_operations.ts +2 -2
- package/src/leverage/operations.ts +5 -5
- package/src/lib.ts +1 -0
- package/src/obligation_orders/common.ts +70 -0
- package/src/obligation_orders/index.ts +3 -0
- package/src/obligation_orders/internal.ts +92 -0
- package/src/obligation_orders/ltv_based.ts +143 -0
- package/src/obligation_orders/price_based.ts +256 -0
- package/src/utils/instruction.ts +2 -1
- package/src/utils/validations.ts +31 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import Decimal from 'decimal.js';
|
|
2
|
+
import { ObligationOrderAtIndex } from '../classes/obligationOrder';
|
|
3
|
+
import { PublicKey } from '@solana/web3.js';
|
|
4
|
+
import { OrderContext, OrderSpecification, OrderType } from './common';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a price-based {@link ObligationOrderAtIndex} based on the given stop-loss or take-profit specification.
|
|
7
|
+
*
|
|
8
|
+
* The returned object can then be passed directly to {@link KaminoAction.buildSetObligationOrderIxn()} to build an
|
|
9
|
+
* instruction which replaces (or cancels, if the specification is `null`) the given obligation's stop-loss or
|
|
10
|
+
* take-profit order on-chain.
|
|
11
|
+
*
|
|
12
|
+
* The given obligation is expected to be a "price-based position" - a single-debt, single-coll obligation which either
|
|
13
|
+
* deposits or borrows a stablecoin (i.e. a long or short position of some token against a stablecoin).
|
|
14
|
+
*/
|
|
15
|
+
export declare function createPriceBasedOrder(context: PriceBasedOrderContext, orderType: OrderType, specification: PriceBasedOrderSpecification | null): ObligationOrderAtIndex;
|
|
16
|
+
/**
|
|
17
|
+
* Parses an {@link PriceBasedOrderSpecification} from the selected stop-loss or take-profit order of the given obligation.
|
|
18
|
+
*
|
|
19
|
+
* The given obligation is expected to be a "price-based position" - a single-debt, single-coll obligation which either
|
|
20
|
+
* deposits or borrows a stablecoin (i.e. a long or short position of some token against a stablecoin).
|
|
21
|
+
*
|
|
22
|
+
* The selected order is expected to be of matching type (i.e. as if it was created using the
|
|
23
|
+
* {@link createPriceBasedOrder()}).
|
|
24
|
+
*/
|
|
25
|
+
export declare function readPriceBasedOrder(context: PriceBasedOrderContext, orderType: OrderType): PriceBasedOrderSpecification | null;
|
|
26
|
+
/**
|
|
27
|
+
* An extended {@link OrderContext} needed to interpret orders on "price-based position" obligations.
|
|
28
|
+
*/
|
|
29
|
+
export type PriceBasedOrderContext = OrderContext & {
|
|
30
|
+
stablecoins: SymbolOrMintAddress[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* A convenient multi-way of specifying a token.
|
|
34
|
+
*/
|
|
35
|
+
export type SymbolOrMintAddress = string | PublicKey;
|
|
36
|
+
/**
|
|
37
|
+
* A high-level specification of a price-based order.
|
|
38
|
+
*/
|
|
39
|
+
export type PriceBasedOrderSpecification = OrderSpecification<PriceBasedOrderTrigger>;
|
|
40
|
+
/**
|
|
41
|
+
* A discriminator enum for {@link PriceBasedOrderTrigger};
|
|
42
|
+
*/
|
|
43
|
+
export declare enum PriceBasedOrderTriggerType {
|
|
44
|
+
LongStopLoss = "LongStopLoss",
|
|
45
|
+
LongTakeProfit = "LongTakeProfit",
|
|
46
|
+
ShortStopLoss = "ShortStopLoss",
|
|
47
|
+
ShortTakeProfit = "ShortTakeProfit"
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* One of possible triggers depending on the obligation's type and the price bracket's side.
|
|
51
|
+
*/
|
|
52
|
+
export type PriceBasedOrderTrigger = LongStopLoss | LongTakeProfit | ShortStopLoss | ShortTakeProfit;
|
|
53
|
+
/**
|
|
54
|
+
* A trigger for a stop-loss on a long position.
|
|
55
|
+
*/
|
|
56
|
+
export type LongStopLoss = {
|
|
57
|
+
type: PriceBasedOrderTriggerType.LongStopLoss;
|
|
58
|
+
whenCollateralPriceBelow: Decimal;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* A trigger for a take-profit on a long position.
|
|
62
|
+
*/
|
|
63
|
+
export type LongTakeProfit = {
|
|
64
|
+
type: PriceBasedOrderTriggerType.LongTakeProfit;
|
|
65
|
+
whenCollateralPriceAbove: Decimal;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* A trigger for a stop-loss on a short position.
|
|
69
|
+
*/
|
|
70
|
+
export type ShortStopLoss = {
|
|
71
|
+
type: PriceBasedOrderTriggerType.ShortStopLoss;
|
|
72
|
+
whenDebtPriceAbove: Decimal;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* A trigger for a take-profit on a short position.
|
|
76
|
+
*/
|
|
77
|
+
export type ShortTakeProfit = {
|
|
78
|
+
type: PriceBasedOrderTriggerType.ShortTakeProfit;
|
|
79
|
+
whenDebtPriceBelow: Decimal;
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=price_based.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"price_based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AC,cAAc,CAAC;IAChD,wBAAwB,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,0BAA0B,CAAC,aAAa,CAAC;IAC/C,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,0BAA0B,CAAC,eAAe,CAAC;IACjD,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PriceBasedOrderTriggerType = void 0;
|
|
7
|
+
exports.createPriceBasedOrder = createPriceBasedOrder;
|
|
8
|
+
exports.readPriceBasedOrder = readPriceBasedOrder;
|
|
9
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
10
|
+
const obligationOrder_1 = require("../classes/obligationOrder");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
const validations_1 = require("../utils/validations");
|
|
13
|
+
const common_1 = require("./common");
|
|
14
|
+
const internal_1 = require("./internal");
|
|
15
|
+
/**
|
|
16
|
+
* Creates a price-based {@link ObligationOrderAtIndex} based on the given stop-loss or take-profit specification.
|
|
17
|
+
*
|
|
18
|
+
* The returned object can then be passed directly to {@link KaminoAction.buildSetObligationOrderIxn()} to build an
|
|
19
|
+
* instruction which replaces (or cancels, if the specification is `null`) the given obligation's stop-loss or
|
|
20
|
+
* take-profit order on-chain.
|
|
21
|
+
*
|
|
22
|
+
* The given obligation is expected to be a "price-based position" - a single-debt, single-coll obligation which either
|
|
23
|
+
* deposits or borrows a stablecoin (i.e. a long or short position of some token against a stablecoin).
|
|
24
|
+
*/
|
|
25
|
+
function createPriceBasedOrder(context, orderType, specification) {
|
|
26
|
+
const positionType = resolvePositionType(context); // resolving this first has an intentional side effect of validating the obligation being compatible
|
|
27
|
+
const index = (0, internal_1.toOrderIndex)(orderType);
|
|
28
|
+
if (specification === null) {
|
|
29
|
+
return obligationOrder_1.ObligationOrderAtIndex.empty(index);
|
|
30
|
+
}
|
|
31
|
+
const condition = toOrderCondition(positionType, orderType, specification.trigger);
|
|
32
|
+
return (0, internal_1.createConditionBasedOrder)(context, condition, specification).atIndex(index);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parses an {@link PriceBasedOrderSpecification} from the selected stop-loss or take-profit order of the given obligation.
|
|
36
|
+
*
|
|
37
|
+
* The given obligation is expected to be a "price-based position" - a single-debt, single-coll obligation which either
|
|
38
|
+
* deposits or borrows a stablecoin (i.e. a long or short position of some token against a stablecoin).
|
|
39
|
+
*
|
|
40
|
+
* The selected order is expected to be of matching type (i.e. as if it was created using the
|
|
41
|
+
* {@link createPriceBasedOrder()}).
|
|
42
|
+
*/
|
|
43
|
+
function readPriceBasedOrder(context, orderType) {
|
|
44
|
+
const positionType = resolvePositionType(context); // resolving this first has an intentional side effect of validating the obligation being compatible
|
|
45
|
+
const kaminoOrder = context.kaminoObligation.getOrders()[(0, internal_1.toOrderIndex)(orderType)];
|
|
46
|
+
if (kaminoOrder === null) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const trigger = toTrigger(positionType, kaminoOrder.condition, orderType);
|
|
50
|
+
return (0, internal_1.readTriggerBasedOrder)(kaminoOrder, trigger);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A discriminator enum for {@link PriceBasedOrderTrigger};
|
|
54
|
+
*/
|
|
55
|
+
var PriceBasedOrderTriggerType;
|
|
56
|
+
(function (PriceBasedOrderTriggerType) {
|
|
57
|
+
PriceBasedOrderTriggerType["LongStopLoss"] = "LongStopLoss";
|
|
58
|
+
PriceBasedOrderTriggerType["LongTakeProfit"] = "LongTakeProfit";
|
|
59
|
+
PriceBasedOrderTriggerType["ShortStopLoss"] = "ShortStopLoss";
|
|
60
|
+
PriceBasedOrderTriggerType["ShortTakeProfit"] = "ShortTakeProfit";
|
|
61
|
+
})(PriceBasedOrderTriggerType || (exports.PriceBasedOrderTriggerType = PriceBasedOrderTriggerType = {}));
|
|
62
|
+
// Only internals below:
|
|
63
|
+
function toOrderCondition(positionType, orderType, trigger) {
|
|
64
|
+
switch (positionType) {
|
|
65
|
+
case PositionType.Long:
|
|
66
|
+
switch (orderType) {
|
|
67
|
+
case common_1.OrderType.StopLoss:
|
|
68
|
+
if (trigger.type === PriceBasedOrderTriggerType.LongStopLoss) {
|
|
69
|
+
return new obligationOrder_1.DebtCollPriceRatioAbove(invertPriceRatio(trigger.whenCollateralPriceBelow));
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
case common_1.OrderType.TakeProfit:
|
|
73
|
+
if (trigger.type === PriceBasedOrderTriggerType.LongTakeProfit) {
|
|
74
|
+
return new obligationOrder_1.DebtCollPriceRatioBelow(invertPriceRatio(trigger.whenCollateralPriceAbove));
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
case PositionType.Short:
|
|
80
|
+
switch (orderType) {
|
|
81
|
+
case common_1.OrderType.StopLoss:
|
|
82
|
+
if (trigger.type === PriceBasedOrderTriggerType.ShortStopLoss) {
|
|
83
|
+
return new obligationOrder_1.DebtCollPriceRatioAbove(trigger.whenDebtPriceAbove);
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case common_1.OrderType.TakeProfit:
|
|
87
|
+
if (trigger.type === PriceBasedOrderTriggerType.ShortTakeProfit) {
|
|
88
|
+
return new obligationOrder_1.DebtCollPriceRatioBelow(trigger.whenDebtPriceBelow);
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
throw new Error(`a ${orderType} order on a ${positionType} position cannot use ${trigger.type} condition`);
|
|
95
|
+
}
|
|
96
|
+
function toTrigger(positionType, condition, orderType) {
|
|
97
|
+
switch (positionType) {
|
|
98
|
+
case PositionType.Long:
|
|
99
|
+
switch (orderType) {
|
|
100
|
+
case common_1.OrderType.StopLoss:
|
|
101
|
+
if (condition instanceof obligationOrder_1.DebtCollPriceRatioAbove) {
|
|
102
|
+
return {
|
|
103
|
+
type: PriceBasedOrderTriggerType.LongStopLoss,
|
|
104
|
+
whenCollateralPriceBelow: invertPriceRatio(condition.minDebtCollPriceRatioExclusive),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
case common_1.OrderType.TakeProfit:
|
|
109
|
+
if (condition instanceof obligationOrder_1.DebtCollPriceRatioBelow) {
|
|
110
|
+
return {
|
|
111
|
+
type: PriceBasedOrderTriggerType.LongTakeProfit,
|
|
112
|
+
whenCollateralPriceAbove: invertPriceRatio(condition.maxDebtCollPriceRatioExclusive),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
case PositionType.Short:
|
|
119
|
+
switch (orderType) {
|
|
120
|
+
case common_1.OrderType.StopLoss:
|
|
121
|
+
if (condition instanceof obligationOrder_1.DebtCollPriceRatioAbove) {
|
|
122
|
+
return {
|
|
123
|
+
type: PriceBasedOrderTriggerType.ShortStopLoss,
|
|
124
|
+
whenDebtPriceAbove: condition.minDebtCollPriceRatioExclusive,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
case common_1.OrderType.TakeProfit:
|
|
129
|
+
if (condition instanceof obligationOrder_1.DebtCollPriceRatioBelow) {
|
|
130
|
+
return {
|
|
131
|
+
type: PriceBasedOrderTriggerType.ShortTakeProfit,
|
|
132
|
+
whenDebtPriceBelow: condition.maxDebtCollPriceRatioExclusive,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
throw new Error(`a ${orderType} order on a ${positionType} position has an incompatible on-chain condition ${condition.constructor.name}`);
|
|
140
|
+
}
|
|
141
|
+
function invertPriceRatio(priceRatio) {
|
|
142
|
+
return new decimal_js_1.default(1).div(priceRatio);
|
|
143
|
+
}
|
|
144
|
+
var PositionType;
|
|
145
|
+
(function (PositionType) {
|
|
146
|
+
PositionType["Long"] = "Long";
|
|
147
|
+
PositionType["Short"] = "Short";
|
|
148
|
+
})(PositionType || (PositionType = {}));
|
|
149
|
+
function resolvePositionType(context) {
|
|
150
|
+
const collateralReserveAddress = (0, validations_1.getSingleElement)(context.kaminoObligation.deposits.keys(), 'deposit');
|
|
151
|
+
const debtReserveAddress = (0, validations_1.getSingleElement)(context.kaminoObligation.borrows.keys(), 'borrow');
|
|
152
|
+
const stablecoinReserveAddresses = collectReserveAddresses(context.kaminoMarket, context.stablecoins);
|
|
153
|
+
if (stablecoinReserveAddresses.contains(collateralReserveAddress)) {
|
|
154
|
+
(0, validations_1.checkThat)(!stablecoinReserveAddresses.contains(debtReserveAddress), 'cannot resolve long vs short position from all-stablecoins obligation');
|
|
155
|
+
return PositionType.Short;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
(0, validations_1.checkThat)(stablecoinReserveAddresses.contains(debtReserveAddress), 'cannot resolve long vs short position from no-stablecoins obligation');
|
|
159
|
+
return PositionType.Long;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function collectReserveAddresses(kaminoMarket, symbolOrMintAddresses) {
|
|
163
|
+
return new utils_1.PublicKeySet(symbolOrMintAddresses.map((symbolOrMintAddress) => typeof symbolOrMintAddress === 'string'
|
|
164
|
+
? kaminoMarket.getExistingReserveBySymbol(symbolOrMintAddress).address
|
|
165
|
+
: kaminoMarket.getExistingReserveByMint(symbolOrMintAddress).address));
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=price_based.js.map
|
|
@@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SAAS,uBAAuB,CAC9B,YAA0B,EAC1B,qBAA4C;IAE5C,OAAO,IAAI,oBAAY,CACrB,qBAAqB,CAAC,GAAG,CAAC,CAAC,mBAAmB,EAAE,EAAE,CAChD,OAAO,mBAAmB,KAAK,QAAQ;QACrC,CAAC,CAAC,YAAY,CAAC,0BAA0B,CAAC,mBAAmB,CAAC,CAAC,OAAO;QACtE,CAAC,CAAC,YAAY,CAAC,wBAAwB,CAAC,mBAAmB,CAAC,CAAC,OAAO,CACvE,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -20,5 +20,5 @@ export declare const getLookupTableAccount: (connection: Connection, address: Pu
|
|
|
20
20
|
export declare function getLookupTableAccounts(connection: Connection, addresses: PublicKey[]): Promise<AddressLookupTableAccount[]>;
|
|
21
21
|
export declare const getComputeBudgetAndPriorityFeeIxns: (units: number, priorityFeeLamports?: Decimal) => TransactionInstruction[];
|
|
22
22
|
export declare function notEmpty<TValue>(value: TValue | null | undefined): value is TValue;
|
|
23
|
-
export declare function
|
|
23
|
+
export declare function uniqueAccountsWithProgramIds(ixs: TransactionInstruction[], addressLookupTables?: PublicKey[] | AddressLookupTableAccount[]): Array<PublicKey>;
|
|
24
24
|
//# sourceMappingURL=instruction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruction.d.ts","sourceRoot":"","sources":["../../src/utils/instruction.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EACL,yBAAyB,EACzB,UAAU,EAEV,UAAU,EACV,OAAO,EACP,SAAS,EACT,WAAW,EACX,MAAM,EACN,WAAW,EACX,sBAAsB,EAGtB,oBAAoB,EACpB,oBAAoB,EAErB,MAAM,iBAAiB,CAAC;AAMzB,wBAAsB,uBAAuB,CAC3C,CAAC,EAAE,UAAU,EACb,EAAE,EAAE,oBAAoB,EACxB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,EAAE,EACjB,iBAAiB,GAAE,O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AC,CAiBlB"}
|
|
@@ -10,7 +10,7 @@ exports.sendTransactionV0 = sendTransactionV0;
|
|
|
10
10
|
exports.simulateTransactionV0 = simulateTransactionV0;
|
|
11
11
|
exports.getLookupTableAccounts = getLookupTableAccounts;
|
|
12
12
|
exports.notEmpty = notEmpty;
|
|
13
|
-
exports.
|
|
13
|
+
exports.uniqueAccountsWithProgramIds = uniqueAccountsWithProgramIds;
|
|
14
14
|
const web3_js_1 = require("@solana/web3.js");
|
|
15
15
|
const errors_1 = require("../idl_codegen/errors");
|
|
16
16
|
const utils_1 = require("../classes/utils");
|
|
@@ -188,7 +188,7 @@ function notEmpty(value) {
|
|
|
188
188
|
const testDummy = value;
|
|
189
189
|
return true;
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function uniqueAccountsWithProgramIds(ixs, addressLookupTables = []) {
|
|
192
192
|
let luts;
|
|
193
193
|
if (addressLookupTables.length > 0 && addressLookupTables[0] instanceof web3_js_1.AddressLookupTableAccount) {
|
|
194
194
|
luts = addressLookupTables.map((lut) => lut.key);
|
|
@@ -198,6 +198,7 @@ function uniqueAccounts(ixs, addressLookupTables = []) {
|
|
|
198
198
|
}
|
|
199
199
|
const uniqueAccounts = new pubkey_1.PublicKeySet(luts);
|
|
200
200
|
ixs.forEach((ixn) => {
|
|
201
|
+
uniqueAccounts.add(ixn.programId);
|
|
201
202
|
ixn.keys.forEach((key) => {
|
|
202
203
|
uniqueAccounts.add(key.pubkey);
|
|
203
204
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruction.js","sourceRoot":"","sources":["../../src/utils/instruction.ts"],"names":[],"mappings":";;;AAwBA,0DAuCC;AAED,0CAWC;AAED,gFA6BC;AAED,kCAkBC;AAED,oDAEC;AAUD,8CAsBC;AAED,sDAqBC;AA6BD,wDAmBC;AAkBD,4BAQC;AAED,
|
|
1
|
+
{"version":3,"file":"instruction.js","sourceRoot":"","sources":["../../src/utils/instruction.ts"],"names":[],"mappings":";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AAC,CAAC,GAAG,EAAE,EAAE;QAClB,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAClC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACvB,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC,OAAO,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function checkThat(evaluationResult: boolean, message?: string): void;
|
|
2
|
+
export declare function checkDefined<T>(value: T | undefined, message?: string): T;
|
|
3
|
+
export declare function checkNotNull<T>(value: T | null, message?: string): T;
|
|
4
|
+
export declare function getSingleElement<T>(iterable: Iterable<T>, nameWithinMessage?: string): T;
|
|
5
|
+
//# sourceMappingURL=validations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validations.d.ts","sourceRoot":"","sources":["../../src/utils/validations.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,gBAAgB,EAAE,OAAO,EAAE,OAAO,GAAE,MAA8B,GAAG,IAAI,CAIlG;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,OAAO,GAAE,MAA0B,GAAG,CAAC,CAG5F;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,GAAE,MAAqB,GAAG,CAAC,CAGlF;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,iBAAiB,GAAE,MAAkB,GAAG,CAAC,CAcnG"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkThat = checkThat;
|
|
4
|
+
exports.checkDefined = checkDefined;
|
|
5
|
+
exports.checkNotNull = checkNotNull;
|
|
6
|
+
exports.getSingleElement = getSingleElement;
|
|
7
|
+
function checkThat(evaluationResult, message = 'precondition failed') {
|
|
8
|
+
if (!evaluationResult) {
|
|
9
|
+
throw new Error(message);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function checkDefined(value, message = 'value undefined') {
|
|
13
|
+
checkThat(value !== undefined, message);
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
function checkNotNull(value, message = 'value null') {
|
|
17
|
+
checkThat(value !== null, message);
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
function getSingleElement(iterable, nameWithinMessage = 'element') {
|
|
21
|
+
const nothingReturnedMarker = {};
|
|
22
|
+
let single = nothingReturnedMarker;
|
|
23
|
+
for (const element of iterable) {
|
|
24
|
+
if (single === nothingReturnedMarker) {
|
|
25
|
+
single = element;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
throw new Error(`exactly one ${nameWithinMessage} expected, but multiple found`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (single === nothingReturnedMarker) {
|
|
32
|
+
throw new Error(`exactly one ${nameWithinMessage} expected, but none found`);
|
|
33
|
+
}
|
|
34
|
+
return single;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=validations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validations.js","sourceRoot":"","sources":["../../src/utils/validations.ts"],"names":[],"mappings":";;AAAA,8BAIC;AAED,oCAGC;AAED,oCAGC;AAED,4CAcC;AA9BD,SAAgB,SAAS,CAAC,gBAAyB,EAAE,UAAkB,qBAAqB;IAC1F,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,SAAgB,YAAY,CAAI,KAAoB,EAAE,UAAkB,iBAAiB;IACvF,SAAS,CAAC,KAAK,KAAK,SAAS,EAAE,OAAO,CAAC,CAAC;IACxC,OAAO,KAAU,CAAC;AACpB,CAAC;AAED,SAAgB,YAAY,CAAI,KAAe,EAAE,UAAkB,YAAY;IAC7E,SAAS,CAAC,KAAK,KAAK,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,OAAO,KAAU,CAAC;AACpB,CAAC;AAED,SAAgB,gBAAgB,CAAI,QAAqB,EAAE,oBAA4B,SAAS;IAC9F,MAAM,qBAAqB,GAAG,EAAE,CAAC;IACjC,IAAI,MAAM,GAAW,qBAAqB,CAAC;IAC3C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,MAAM,KAAK,qBAAqB,EAAE,CAAC;YACrC,MAAM,GAAG,OAAO,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,eAAe,iBAAiB,+BAA+B,CAAC,CAAC;QACnF,CAAC;IACH,CAAC;IACD,IAAI,MAAM,KAAK,qBAAqB,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,eAAe,iBAAiB,2BAA2B,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,MAAW,CAAC;AACrB,CAAC"}
|
package/package.json
CHANGED
package/src/classes/action.ts
CHANGED
|
@@ -78,7 +78,7 @@ import { Reserve } from '../idl_codegen/accounts';
|
|
|
78
78
|
import { VanillaObligation } from '../utils/ObligationType';
|
|
79
79
|
import { PROGRAM_ID } from '../lib';
|
|
80
80
|
import { Scope } from '@kamino-finance/scope-sdk';
|
|
81
|
-
import {
|
|
81
|
+
import { ObligationOrderAtIndex } from './obligationOrder';
|
|
82
82
|
|
|
83
83
|
export type ActionType =
|
|
84
84
|
| 'deposit'
|
|
@@ -1165,11 +1165,13 @@ export class KaminoAction {
|
|
|
1165
1165
|
static buildSetObligationOrderIxn(
|
|
1166
1166
|
kaminoMarket: KaminoMarket,
|
|
1167
1167
|
obligation: KaminoObligation,
|
|
1168
|
-
|
|
1169
|
-
order: KaminoObligationOrder | null
|
|
1168
|
+
orderAtIndex: ObligationOrderAtIndex
|
|
1170
1169
|
): TransactionInstruction {
|
|
1171
1170
|
return setObligationOrder(
|
|
1172
|
-
{
|
|
1171
|
+
{
|
|
1172
|
+
index: orderAtIndex.index,
|
|
1173
|
+
order: orderAtIndex.orderState(),
|
|
1174
|
+
},
|
|
1173
1175
|
{
|
|
1174
1176
|
lendingMarket: kaminoMarket.getAddress(),
|
|
1175
1177
|
obligation: obligation.obligationAddress,
|
package/src/classes/manager.ts
CHANGED
|
@@ -629,10 +629,7 @@ export class KaminoManager {
|
|
|
629
629
|
const switchboardV2 = await SwitchboardProgram.loadMainnet(this.getConnection());
|
|
630
630
|
|
|
631
631
|
// Group reserves by market
|
|
632
|
-
const marketToReserve = new PubkeyHashMap<
|
|
633
|
-
PublicKey,
|
|
634
|
-
[PublicKey, Reserve, AccountInfo<Buffer>][]
|
|
635
|
-
>();
|
|
632
|
+
const marketToReserve = new PubkeyHashMap<PublicKey, [PublicKey, Reserve, AccountInfo<Buffer>][]>();
|
|
636
633
|
for (const [reserveAddress, reserveState, buffer] of reservePairs) {
|
|
637
634
|
const marketAddress = reserveState.lendingMarket;
|
|
638
635
|
if (!marketToReserve.has(marketAddress)) {
|
package/src/classes/market.ts
CHANGED
|
@@ -36,6 +36,7 @@ import { parseTokenSymbol, parseZeroPaddedUtf8 } from './utils';
|
|
|
36
36
|
import SwitchboardProgram from '@switchboard-xyz/sbv2-lite';
|
|
37
37
|
import { ObligationZP } from '../idl_codegen/zero_padding';
|
|
38
38
|
import { getProgramAccounts } from '../utils';
|
|
39
|
+
import { checkDefined } from '../utils/validations';
|
|
39
40
|
|
|
40
41
|
export interface ReserveRewardInfo {
|
|
41
42
|
rewardsPerSecond: Decimal; // not lamport
|
|
@@ -175,13 +176,10 @@ export class KaminoMarket {
|
|
|
175
176
|
if (elevationGroupId === 0) {
|
|
176
177
|
return null;
|
|
177
178
|
}
|
|
178
|
-
|
|
179
|
-
(candidate) => candidate.elevationGroup === elevationGroupId
|
|
179
|
+
return checkDefined(
|
|
180
|
+
this.getMarketElevationGroupDescriptions().find((candidate) => candidate.elevationGroup === elevationGroupId),
|
|
181
|
+
`${description} elevation group ${elevationGroupId} not found`
|
|
180
182
|
);
|
|
181
|
-
if (elevationGroup === undefined) {
|
|
182
|
-
throw new Error(`${description} elevation group ${elevationGroupId} not found in market ${this.getAddress()}`);
|
|
183
|
-
}
|
|
184
|
-
return elevationGroup;
|
|
185
183
|
}
|
|
186
184
|
|
|
187
185
|
getMinNetValueObligation(): Decimal {
|
|
@@ -420,6 +418,14 @@ export class KaminoMarket {
|
|
|
420
418
|
return this.reserves.get(address);
|
|
421
419
|
}
|
|
422
420
|
|
|
421
|
+
/**
|
|
422
|
+
* Returns this market's reserve of the given address, or throws an error (including the given description) if such
|
|
423
|
+
* reserve does not exist.
|
|
424
|
+
*/
|
|
425
|
+
getExistingReserveByAddress(address: PublicKey, description: string = 'Requested'): KaminoReserve {
|
|
426
|
+
return checkDefined(this.getReserveByAddress(address), `${description} reserve ${address} not found`);
|
|
427
|
+
}
|
|
428
|
+
|
|
423
429
|
getReserveByMint(address: PublicKey): KaminoReserve | undefined {
|
|
424
430
|
for (const reserve of this.reserves.values()) {
|
|
425
431
|
if (reserve.getLiquidityMint().equals(address)) {
|
|
@@ -434,11 +440,7 @@ export class KaminoMarket {
|
|
|
434
440
|
* such reserve does not exist.
|
|
435
441
|
*/
|
|
436
442
|
getExistingReserveByMint(address: PublicKey, description: string = 'Requested'): KaminoReserve {
|
|
437
|
-
|
|
438
|
-
if (!reserve) {
|
|
439
|
-
throw new Error(`${description} reserve with mint ${address} not found in market ${this.getAddress()}`);
|
|
440
|
-
}
|
|
441
|
-
return reserve;
|
|
443
|
+
return checkDefined(this.getReserveByMint(address), `${description} reserve with mint ${address} not found`);
|
|
442
444
|
}
|
|
443
445
|
|
|
444
446
|
getReserveBySymbol(symbol: string) {
|
|
@@ -450,6 +452,14 @@ export class KaminoMarket {
|
|
|
450
452
|
return undefined;
|
|
451
453
|
}
|
|
452
454
|
|
|
455
|
+
/**
|
|
456
|
+
* Returns this market's reserve of the given symbol, or throws an error (including the given description) if
|
|
457
|
+
* such reserve does not exist.
|
|
458
|
+
*/
|
|
459
|
+
getExistingReserveBySymbol(symbol: string, description: string = 'Requested'): KaminoReserve {
|
|
460
|
+
return checkDefined(this.getReserveBySymbol(symbol), `${description} reserve with symbol ${symbol} not found`);
|
|
461
|
+
}
|
|
462
|
+
|
|
453
463
|
getReserveMintBySymbol(symbol: string) {
|
|
454
464
|
return this.getReserveBySymbol(symbol)?.getLiquidityMint();
|
|
455
465
|
}
|
|
@@ -67,7 +67,7 @@ export type ObligationStats = {
|
|
|
67
67
|
* The LTV at which the obligation becomes subject to liquidation, *suitable for UI display*.
|
|
68
68
|
*
|
|
69
69
|
* Technically, this is a ratio:
|
|
70
|
-
* - of a sum of all
|
|
70
|
+
* - of a sum of values of all deposits multiplied by reserves' liquidationLtv (i.e. `borrowLiquidationLimit`)
|
|
71
71
|
* - to a sum of values of all deposits having reserve's liquidationLtv > 0 (i.e. `userTotalLiquidatableDeposit`)
|
|
72
72
|
*
|
|
73
73
|
* Please note that this is different from the smart contract's definition of liquidation LTV (which divides by a sum
|
|
@@ -271,7 +271,7 @@ export class KaminoObligation {
|
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
/**
|
|
274
|
-
* Returns obligation orders (including the null ones, i.e. non-active
|
|
274
|
+
* Returns obligation orders (including the null ones, i.e. non-active positions in the orders' array).
|
|
275
275
|
*/
|
|
276
276
|
getOrders(): Array<KaminoObligationOrder | null> {
|
|
277
277
|
return this.state.orders.map((order) => KaminoObligationOrder.fromState(order));
|