@kamino-finance/klend-sdk 5.12.8 → 5.13.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.
Files changed (88) hide show
  1. package/dist/classes/action.d.ts +46 -22
  2. package/dist/classes/action.d.ts.map +1 -1
  3. package/dist/classes/action.js +60 -37
  4. package/dist/classes/action.js.map +1 -1
  5. package/dist/classes/fraction.d.ts +2 -0
  6. package/dist/classes/fraction.d.ts.map +1 -1
  7. package/dist/classes/fraction.js +6 -0
  8. package/dist/classes/fraction.js.map +1 -1
  9. package/dist/classes/manager.d.ts.map +1 -1
  10. package/dist/classes/manager.js.map +1 -1
  11. package/dist/classes/market.d.ts +10 -0
  12. package/dist/classes/market.d.ts.map +1 -1
  13. package/dist/classes/market.js +17 -10
  14. package/dist/classes/market.js.map +1 -1
  15. package/dist/classes/obligation.d.ts +2 -2
  16. package/dist/classes/obligation.d.ts.map +1 -1
  17. package/dist/classes/obligation.js +2 -7
  18. package/dist/classes/obligation.js.map +1 -1
  19. package/dist/classes/obligationOrder.d.ts +30 -7
  20. package/dist/classes/obligationOrder.d.ts.map +1 -1
  21. package/dist/classes/obligationOrder.js +47 -12
  22. package/dist/classes/obligationOrder.js.map +1 -1
  23. package/dist/classes/reserve.d.ts.map +1 -1
  24. package/dist/classes/reserve.js +1 -4
  25. package/dist/classes/reserve.js.map +1 -1
  26. package/dist/classes/utils.d.ts +0 -1
  27. package/dist/classes/utils.d.ts.map +1 -1
  28. package/dist/classes/utils.js +0 -7
  29. package/dist/classes/utils.js.map +1 -1
  30. package/dist/classes/vault.d.ts.map +1 -1
  31. package/dist/classes/vault.js +3 -0
  32. package/dist/classes/vault.js.map +1 -1
  33. package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
  34. package/dist/lending_operations/repay_with_collateral_operations.js +2 -2
  35. package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
  36. package/dist/lending_operations/swap_collateral_operations.js +2 -4
  37. package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
  38. package/dist/leverage/operations.d.ts.map +1 -1
  39. package/dist/leverage/operations.js +7 -14
  40. package/dist/leverage/operations.js.map +1 -1
  41. package/dist/lib.d.ts +1 -0
  42. package/dist/lib.d.ts.map +1 -1
  43. package/dist/lib.js +1 -0
  44. package/dist/lib.js.map +1 -1
  45. package/dist/obligation_orders/common.d.ts +62 -0
  46. package/dist/obligation_orders/common.d.ts.map +1 -0
  47. package/dist/obligation_orders/common.js +20 -0
  48. package/dist/obligation_orders/common.js.map +1 -0
  49. package/dist/obligation_orders/index.d.ts +4 -0
  50. package/dist/obligation_orders/index.d.ts.map +1 -0
  51. package/dist/obligation_orders/index.js +20 -0
  52. package/dist/obligation_orders/index.js.map +1 -0
  53. package/dist/obligation_orders/internal.d.ts +6 -0
  54. package/dist/obligation_orders/internal.d.ts.map +1 -0
  55. package/dist/obligation_orders/internal.js +72 -0
  56. package/dist/obligation_orders/internal.js.map +1 -0
  57. package/dist/obligation_orders/ltv_based.d.ts +51 -0
  58. package/dist/obligation_orders/ltv_based.d.ts.map +1 -0
  59. package/dist/obligation_orders/ltv_based.js +107 -0
  60. package/dist/obligation_orders/ltv_based.js.map +1 -0
  61. package/dist/obligation_orders/price_based.d.ts +81 -0
  62. package/dist/obligation_orders/price_based.d.ts.map +1 -0
  63. package/dist/obligation_orders/price_based.js +167 -0
  64. package/dist/obligation_orders/price_based.js.map +1 -0
  65. package/dist/utils/validations.d.ts +5 -0
  66. package/dist/utils/validations.d.ts.map +1 -0
  67. package/dist/utils/validations.js +36 -0
  68. package/dist/utils/validations.js.map +1 -0
  69. package/package.json +1 -1
  70. package/src/classes/action.ts +61 -52
  71. package/src/classes/fraction.ts +7 -0
  72. package/src/classes/manager.ts +1 -4
  73. package/src/classes/market.ts +21 -11
  74. package/src/classes/obligation.ts +4 -9
  75. package/src/classes/obligationOrder.ts +57 -20
  76. package/src/classes/reserve.ts +2 -5
  77. package/src/classes/utils.ts +0 -7
  78. package/src/classes/vault.ts +3 -0
  79. package/src/lending_operations/repay_with_collateral_operations.ts +0 -2
  80. package/src/lending_operations/swap_collateral_operations.ts +2 -4
  81. package/src/leverage/operations.ts +7 -13
  82. package/src/lib.ts +1 -0
  83. package/src/obligation_orders/common.ts +70 -0
  84. package/src/obligation_orders/index.ts +3 -0
  85. package/src/obligation_orders/internal.ts +92 -0
  86. package/src/obligation_orders/ltv_based.ts +143 -0
  87. package/src/obligation_orders/price_based.ts +256 -0
  88. 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.d.ts","sourceRoot":"","sources":["../../src/obligation_orders/price_based.ts"],"names":[],"mappings":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C;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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price_based.js","sourceRoot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O,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"}
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kamino-finance/klend-sdk",
3
- "version": "5.12.8",
3
+ "version": "5.13.1",
4
4
  "description": "Typescript SDK for interacting with the Kamino Lending (klend) protocol",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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 { KaminoObligationOrder } from './obligationOrder';
81
+ import { ObligationOrderAtIndex } from './obligationOrder';
82
82
 
83
83
  export type ActionType =
84
84
  | 'deposit'
@@ -390,8 +390,10 @@ export class KaminoAction {
390
390
  extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
391
391
  includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas,
392
392
  requestElevationGroup: boolean = false, // to be requested *before* the deposit
393
- includeUserMetadata: boolean = true, // if true it includes user metadata
394
- createLookupTable: boolean = true,
393
+ initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
394
+ skipInitialization: false,
395
+ skipLutCreation: false,
396
+ },
395
397
  referrer: PublicKey = PublicKey.default,
396
398
  currentSlot: number = 0,
397
399
  overrideElevationGroupRequest: number | undefined = undefined // if set, when an elevationgroup request is made, it will use this value
@@ -416,11 +418,10 @@ export class KaminoAction {
416
418
  'deposit',
417
419
  includeAtaIxns,
418
420
  requestElevationGroup,
419
- includeUserMetadata,
420
421
  addInitObligationForFarm,
421
422
  useV2Ixs,
422
423
  scopeRefreshConfig,
423
- createLookupTable,
424
+ initUserMetadata,
424
425
  undefined,
425
426
  overrideElevationGroupRequest
426
427
  );
@@ -457,8 +458,10 @@ export class KaminoAction {
457
458
  extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
458
459
  includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas,
459
460
  requestElevationGroup: boolean = false,
460
- includeUserMetadata: boolean = true, // if true it includes user metadata
461
- createLookupTable: boolean = true,
461
+ initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
462
+ skipInitialization: false,
463
+ skipLutCreation: false,
464
+ },
462
465
  referrer: PublicKey = PublicKey.default,
463
466
  currentSlot: number = 0,
464
467
  overrideElevationGroupRequest: number | undefined = undefined // if set, when an elevationgroup request is made, it will use this value
@@ -494,11 +497,10 @@ export class KaminoAction {
494
497
  'borrow',
495
498
  includeAtaIxns,
496
499
  requestElevationGroup,
497
- includeUserMetadata,
498
500
  addInitObligationForFarm,
499
501
  useV2Ixs,
500
502
  scopeRefreshConfig,
501
- createLookupTable,
503
+ initUserMetadata,
502
504
  undefined,
503
505
  overrideElevationGroupRequest
504
506
  );
@@ -547,9 +549,8 @@ export class KaminoAction {
547
549
  requestElevationGroup,
548
550
  false,
549
551
  addInitObligationForFarm,
550
- false,
551
552
  scopeRefreshConfig,
552
- false
553
+ { skipInitialization: true, skipLutCreation: true }
553
554
  );
554
555
  axn.addDepositReserveLiquidityIx();
555
556
  axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
@@ -591,9 +592,8 @@ export class KaminoAction {
591
592
  requestElevationGroup,
592
593
  false,
593
594
  addInitObligationForFarm,
594
- false,
595
595
  scopeRefreshConfig,
596
- false
596
+ { skipInitialization: true, skipLutCreation: true }
597
597
  );
598
598
  axn.addRedeemReserveCollateralIx();
599
599
  axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
@@ -611,8 +611,10 @@ export class KaminoAction {
611
611
  extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
612
612
  includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas
613
613
  requestElevationGroup: boolean = false,
614
- includeUserMetadata: boolean = true, // if true it includes user metadata
615
- createLookupTable: boolean = true,
614
+ initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
615
+ skipInitialization: false,
616
+ skipLutCreation: false,
617
+ },
616
618
  referrer: PublicKey = PublicKey.default,
617
619
  currentSlot: number = 0
618
620
  ) {
@@ -636,11 +638,10 @@ export class KaminoAction {
636
638
  'depositCollateral',
637
639
  includeAtaIxns,
638
640
  requestElevationGroup,
639
- includeUserMetadata,
640
641
  addInitObligationForFarm,
641
642
  useV2Ixs,
642
643
  scopeRefreshConfig,
643
- createLookupTable
644
+ initUserMetadata
644
645
  );
645
646
  if (useV2Ixs) {
646
647
  axn.addDepositObligationCollateralIxV2();
@@ -664,8 +665,10 @@ export class KaminoAction {
664
665
  extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
665
666
  includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas,
666
667
  requestElevationGroup: boolean = false,
667
- includeUserMetadata: boolean = true, // if true it includes user metadata,
668
- createLookupTable: boolean = true,
668
+ initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
669
+ skipInitialization: false,
670
+ skipLutCreation: false,
671
+ },
669
672
  referrer: PublicKey = PublicKey.default,
670
673
  currentSlot: number = 0
671
674
  ) {
@@ -705,11 +708,10 @@ export class KaminoAction {
705
708
  'deposit',
706
709
  includeAtaIxns,
707
710
  requestElevationGroup,
708
- includeUserMetadata,
709
711
  addInitObligationForFarmForDeposit,
710
712
  useV2Ixs,
711
713
  undefined,
712
- createLookupTable,
714
+ initUserMetadata,
713
715
  twoTokenAction
714
716
  );
715
717
 
@@ -756,8 +758,10 @@ export class KaminoAction {
756
758
  extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
757
759
  includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas,
758
760
  requestElevationGroup: boolean = false,
759
- includeUserMetadata: boolean = true, // if true it includes user metadata,
760
- createLookupTable: boolean = true,
761
+ initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
762
+ skipInitialization: false,
763
+ skipLutCreation: false,
764
+ },
761
765
  referrer: PublicKey = PublicKey.default
762
766
  ) {
763
767
  const axn = await KaminoAction.initializeMultiTokenAction(
@@ -783,11 +787,10 @@ export class KaminoAction {
783
787
  'depositAndWithdraw',
784
788
  includeAtaIxns,
785
789
  requestElevationGroup,
786
- includeUserMetadata,
787
790
  addInitObligationForFarm,
788
791
  true,
789
792
  scopeRefreshConfig,
790
- createLookupTable,
793
+ initUserMetadata,
791
794
  twoTokenAction
792
795
  );
793
796
  const withdrawCollateralAmount = axn.getWithdrawCollateralAmount(axn.outflowReserve!, axn.outflowAmount!);
@@ -809,8 +812,10 @@ export class KaminoAction {
809
812
  extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
810
813
  includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas,
811
814
  requestElevationGroup: boolean = false,
812
- includeUserMetadata: boolean = true, // if true it includes user metadata,
813
- createLookupTable: boolean = true,
815
+ initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
816
+ skipInitialization: false,
817
+ skipLutCreation: false,
818
+ },
814
819
  referrer: PublicKey = PublicKey.default
815
820
  ) {
816
821
  const axn = await KaminoAction.initializeMultiTokenAction(
@@ -836,11 +841,10 @@ export class KaminoAction {
836
841
  'repayAndWithdrawV2',
837
842
  includeAtaIxns,
838
843
  requestElevationGroup,
839
- includeUserMetadata,
840
844
  addInitObligationForFarm,
841
845
  true,
842
846
  scopeRefreshConfig,
843
- createLookupTable,
847
+ initUserMetadata,
844
848
  twoTokenAction
845
849
  );
846
850
  const withdrawCollateralAmount = axn.getWithdrawCollateralAmount(axn.outflowReserve!, axn.outflowAmount!);
@@ -863,8 +867,10 @@ export class KaminoAction {
863
867
  extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
864
868
  includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas,
865
869
  requestElevationGroup: boolean = false,
866
- includeUserMetadata: boolean = true, // if true it includes user metadata,
867
- createLookupTable: boolean = true,
870
+ initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
871
+ skipInitialization: false,
872
+ skipLutCreation: false,
873
+ },
868
874
  referrer: PublicKey = PublicKey.default
869
875
  ) {
870
876
  const axn = await KaminoAction.initializeMultiTokenAction(
@@ -891,11 +897,10 @@ export class KaminoAction {
891
897
  'repay',
892
898
  includeAtaIxns,
893
899
  requestElevationGroup,
894
- includeUserMetadata,
895
900
  addInitObligationForFarmForRepay,
896
901
  useV2Ixs,
897
902
  undefined,
898
- createLookupTable,
903
+ initUserMetadata,
899
904
  twoTokenAction
900
905
  );
901
906
 
@@ -941,8 +946,10 @@ export class KaminoAction {
941
946
  extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
942
947
  includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas,
943
948
  requestElevationGroup: boolean = false, // to be requested *after* the withdraw
944
- includeUserMetadata: boolean = true, // if true it includes user metadata
945
- createLookupTable: boolean = true,
949
+ initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
950
+ skipInitialization: false,
951
+ skipLutCreation: false,
952
+ },
946
953
  referrer: PublicKey = PublicKey.default,
947
954
  currentSlot: number = 0,
948
955
  overrideElevationGroupRequest?: number,
@@ -974,11 +981,10 @@ export class KaminoAction {
974
981
  'withdraw',
975
982
  includeAtaIxns,
976
983
  requestElevationGroup,
977
- includeUserMetadata,
978
984
  addInitObligationForFarm,
979
985
  useV2Ixs,
980
986
  scopeRefreshConfig,
981
- createLookupTable,
987
+ initUserMetadata,
982
988
  false,
983
989
  overrideElevationGroupRequest
984
990
  );
@@ -1023,8 +1029,10 @@ export class KaminoAction {
1023
1029
  extraComputeBudget: number = 1_000_000,
1024
1030
  includeAtaIxns: boolean = true,
1025
1031
  requestElevationGroup: boolean = false,
1026
- includeUserMetadata: boolean = true,
1027
- createLookupTable: boolean = true,
1032
+ initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
1033
+ skipInitialization: false,
1034
+ skipLutCreation: false,
1035
+ },
1028
1036
  referrer: PublicKey = PublicKey.default
1029
1037
  ) {
1030
1038
  const axn = await KaminoAction.initialize(
@@ -1048,11 +1056,10 @@ export class KaminoAction {
1048
1056
  'repay',
1049
1057
  includeAtaIxns,
1050
1058
  requestElevationGroup,
1051
- includeUserMetadata,
1052
1059
  addInitObligationForFarm,
1053
1060
  useV2Ixs,
1054
1061
  scopeRefreshConfig,
1055
- createLookupTable
1062
+ initUserMetadata
1056
1063
  );
1057
1064
  if (useV2Ixs) {
1058
1065
  await axn.addRepayIxV2();
@@ -1078,8 +1085,10 @@ export class KaminoAction {
1078
1085
  extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
1079
1086
  includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas, and creates all other token atas if they don't exist
1080
1087
  requestElevationGroup: boolean = false,
1081
- includeUserMetadata: boolean = true, // if true it includes user metadata
1082
- createLookupTable: boolean = true,
1088
+ initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
1089
+ skipInitialization: false,
1090
+ skipLutCreation: false,
1091
+ },
1083
1092
  referrer: PublicKey = PublicKey.default,
1084
1093
  maxAllowedLtvOverridePercent: number = 0,
1085
1094
  currentSlot: number = 0
@@ -1107,11 +1116,10 @@ export class KaminoAction {
1107
1116
  'liquidate',
1108
1117
  includeAtaIxns,
1109
1118
  requestElevationGroup,
1110
- includeUserMetadata,
1111
1119
  addInitObligationForFarm,
1112
1120
  useV2Ixs,
1113
1121
  scopeRefreshConfig,
1114
- createLookupTable
1122
+ initUserMetadata
1115
1123
  );
1116
1124
  if (useV2Ixs) {
1117
1125
  await axn.addLiquidateIxV2(maxAllowedLtvOverridePercent);
@@ -1165,11 +1173,13 @@ export class KaminoAction {
1165
1173
  static buildSetObligationOrderIxn(
1166
1174
  kaminoMarket: KaminoMarket,
1167
1175
  obligation: KaminoObligation,
1168
- index: number,
1169
- order: KaminoObligationOrder | null
1176
+ orderAtIndex: ObligationOrderAtIndex
1170
1177
  ): TransactionInstruction {
1171
1178
  return setObligationOrder(
1172
- { index, order: order !== null ? order.toState() : KaminoObligationOrder.NULL_STATE },
1179
+ {
1180
+ index: orderAtIndex.index,
1181
+ order: orderAtIndex.orderState(),
1182
+ },
1173
1183
  {
1174
1184
  lendingMarket: kaminoMarket.getAddress(),
1175
1185
  obligation: obligation.obligationAddress,
@@ -2674,19 +2684,18 @@ export class KaminoAction {
2674
2684
  action: ActionType,
2675
2685
  includeAtaIxns: boolean,
2676
2686
  requestElevationGroup: boolean,
2677
- includeUserMetadata: boolean,
2678
2687
  addInitObligationForFarm: boolean,
2679
2688
  useV2Ixs: boolean,
2680
2689
  scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
2681
- createLookupTable: boolean,
2690
+ initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean },
2682
2691
  twoTokenAction: boolean = false,
2683
2692
  overrideElevationGroupRequest?: number
2684
2693
  ) {
2685
2694
  if (!['mint', 'redeem'].includes(action)) {
2686
2695
  const [, ownerUserMetadata] = await this.kaminoMarket.getUserMetadata(this.owner);
2687
- if (!ownerUserMetadata && includeUserMetadata) {
2696
+ if (!ownerUserMetadata && !initUserMetadata.skipInitialization) {
2688
2697
  let lookupTable: PublicKey = PublicKey.default;
2689
- if (createLookupTable) {
2698
+ if (!initUserMetadata.skipLutCreation) {
2690
2699
  const [createLutIx, lookupTableAddress] = await createLookupTableIx(
2691
2700
  this.kaminoMarket.getConnection(),
2692
2701
  this.owner