@kamino-finance/klend-sdk 5.10.6 → 5.10.7
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 +7 -3
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +28 -13
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/market.d.ts +11 -0
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +26 -0
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.d.ts +14 -0
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +25 -0
- package/dist/classes/obligation.js.map +1 -1
- package/dist/lending_operations/index.d.ts +1 -0
- package/dist/lending_operations/index.d.ts.map +1 -1
- package/dist/lending_operations/index.js +1 -0
- package/dist/lending_operations/index.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.d.ts +5 -5
- package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +3 -2
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.d.ts +102 -0
- package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -0
- package/dist/lending_operations/swap_collateral_operations.js +306 -0
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -0
- package/dist/leverage/operations.d.ts +2 -2
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +4 -0
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/types.d.ts +5 -5
- package/dist/leverage/types.d.ts.map +1 -1
- package/dist/leverage/utils.d.ts +5 -5
- package/dist/leverage/utils.d.ts.map +1 -1
- package/dist/leverage/utils.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +2 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/pubkey.d.ts +3 -0
- package/dist/utils/pubkey.d.ts.map +1 -1
- package/dist/utils/pubkey.js +16 -2
- package/dist/utils/pubkey.js.map +1 -1
- package/dist/utils/seeds.d.ts +1 -1
- package/dist/utils/seeds.js +1 -1
- package/package.json +4 -4
- package/src/classes/action.ts +37 -19
- package/src/classes/market.ts +35 -1
- package/src/classes/obligation.ts +75 -0
- package/src/lending_operations/index.ts +1 -0
- package/src/lending_operations/repay_with_collateral_operations.ts +10 -9
- package/src/lending_operations/swap_collateral_operations.ts +586 -0
- package/src/leverage/operations.ts +14 -10
- package/src/leverage/types.ts +6 -6
- package/src/leverage/utils.ts +8 -8
- package/src/utils/constants.ts +2 -0
- package/src/utils/pubkey.ts +19 -2
- package/src/utils/seeds.ts +1 -1
|
@@ -14,10 +14,10 @@ async function getRepayWithCollSwapInputs({ collTokenMint, currentSlot, debtToke
|
|
|
14
14
|
const collReserve = kaminoMarket.getReserveByMint(collTokenMint);
|
|
15
15
|
const debtReserve = kaminoMarket.getReserveByMint(debtTokenMint);
|
|
16
16
|
if (!collReserve) {
|
|
17
|
-
throw new Error(`Collateral reserve with mint ${
|
|
17
|
+
throw new Error(`Collateral reserve with mint ${collTokenMint} not found in market ${kaminoMarket.getAddress()}`);
|
|
18
18
|
}
|
|
19
19
|
if (!debtReserve) {
|
|
20
|
-
throw new Error(`Debt reserve with mint ${
|
|
20
|
+
throw new Error(`Debt reserve with mint ${debtTokenMint} not found in market ${kaminoMarket.getAddress()}`);
|
|
21
21
|
}
|
|
22
22
|
const { repayAmountLamports, flashRepayAmountLamports, repayAmount: finalRepayAmount, } = (0, repay_with_collateral_calcs_1.calcRepayAmountWithSlippage)(kaminoMarket, debtReserve, currentSlot, obligation, repayAmount, referrer);
|
|
23
23
|
const debtPosition = obligation.getBorrowByReserve(debtReserve.address);
|
|
@@ -130,6 +130,7 @@ async function buildRepayWithCollateralIxs(market, debtReserve, collReserve, obl
|
|
|
130
130
|
reserve: debtReserve,
|
|
131
131
|
amountLamports: debtRepayAmountLamports,
|
|
132
132
|
destinationAta: debtTokenAta,
|
|
133
|
+
// TODO(referrals): once we support referrals, we will have to replace the placeholder args below:
|
|
133
134
|
referrerAccount: market.programId,
|
|
134
135
|
referrerTokenState: market.programId,
|
|
135
136
|
programId: market.programId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repay_with_collateral_operations.js","sourceRoot":"","sources":["../../src/lending_operations/repay_with_collateral_operations.ts"],"names":[],"mappings":";;;;;AAyDA,gEAkHC;AAOD,kDA4EC;AA9PD,wCAAyF;AACzF,0CAOqB;AACrB,oCAOkB;AAElB,4DAAiC;AACjC,+EAAuG;AAsChG,KAAK,UAAU,0BAA0B,CAAgB,EAC9D,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,UAAU,EACV,MAAM,EACN,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,uBAAuB,EACvB,YAAY,GACgC;IAI5C,MAAM,WAAW,GAAG,YAAY,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,WAAW,GAAG,YAAY,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACjE,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,gCAAgC,
|
|
1
|
+
{"version":3,"file":"repay_with_collateral_operations.js","sourceRoot":"","sources":["../../src/lending_operations/repay_with_collateral_operations.ts"],"names":[],"mappings":";;;;;AAyDA,gEAkHC;AAOD,kDA4EC;AA9PD,wCAAyF;AACzF,0CAOqB;AACrB,oCAOkB;AAElB,4DAAiC;AACjC,+EAAuG;AAsChG,KAAK,UAAU,0BAA0B,CAAgB,EAC9D,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,UAAU,EACV,MAAM,EACN,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,uBAAuB,EACvB,YAAY,GACgC;IAI5C,MAAM,WAAW,GAAG,YAAY,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACjE,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E,EAChE,WAAW,CAAC,gBAAgB,EAAE,EAC9B,iBAAiB,CAAC,CAAC,CAAC,eAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,QAAQ,EAAE,EAC7D,WAAW,CAAC,gBAAgB,EAAE,EAC9B,UAAU,CAAC,KAAK,CAAC,KAAK,EACtB,WAAW,EACX,UAAU,EACV,CAAC,EACD,KAAK,EACL,qBAAqB,EACrB,SAAS,EACT,QAAQ,EACR,YAAY,CACb,CAAC;IAEF,iDAAiD;IACjD,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;IAC/C,MAAM,gBAAgB,GAAG,IAAA,8BAAsB,EAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAE7D,OAAO;QACL,GAAG,UAAU;QACb,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;QACvC,cAAc;QACd,GAAG,YAAY;QACf,GAAG,sBAAY,CAAC,WAAW,CAAC,sBAAsB,CAAC;QACnD,GAAG,gBAAgB;QACnB,aAAa;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { KaminoMarket, KaminoObligation } from '../classes';
|
|
2
|
+
import { SwapIxsProvider, SwapQuoteProvider } from '../leverage';
|
|
3
|
+
import { ScopeRefresh } from '../utils';
|
|
4
|
+
import { AddressLookupTableAccount, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
5
|
+
import Decimal from 'decimal.js';
|
|
6
|
+
/**
|
|
7
|
+
* Inputs to the `getSwapCollIxns()` operation.
|
|
8
|
+
*/
|
|
9
|
+
export interface SwapCollIxnsInputs<QuoteResponse> {
|
|
10
|
+
/**
|
|
11
|
+
* The amount of source collateral to be swapped-in for the target collateral.
|
|
12
|
+
* This value will be treated exactly (i.e. slippage is not applied here) and thus must not exceed the collateral's
|
|
13
|
+
* total amount.
|
|
14
|
+
*/
|
|
15
|
+
sourceCollSwapAmount: Decimal;
|
|
16
|
+
/**
|
|
17
|
+
* If true, the source collateral will be closed - whatever amount is left after withdrawing `sourceCollSwapAmount`
|
|
18
|
+
* will be transferred to the user.
|
|
19
|
+
*/
|
|
20
|
+
isClosingSourceColl: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The mint of the source collateral token (i.e. the current one).
|
|
23
|
+
*/
|
|
24
|
+
sourceCollTokenMint: PublicKey;
|
|
25
|
+
/**
|
|
26
|
+
* The mint of the target collateral token (i.e. the new one).
|
|
27
|
+
*/
|
|
28
|
+
targetCollTokenMint: PublicKey;
|
|
29
|
+
/**
|
|
30
|
+
* An elevation group ID that the obligation should end up with after the collateral swap - it will be requested by
|
|
31
|
+
* this operation (if different from the obligation's current elevation group).
|
|
32
|
+
*/
|
|
33
|
+
newElevationGroup: number;
|
|
34
|
+
market: KaminoMarket;
|
|
35
|
+
obligation: KaminoObligation;
|
|
36
|
+
referrer: PublicKey;
|
|
37
|
+
currentSlot: number;
|
|
38
|
+
budgetAndPriorityFeeIxns?: TransactionInstruction[];
|
|
39
|
+
scopeRefresh?: ScopeRefresh;
|
|
40
|
+
quoter: SwapQuoteProvider<QuoteResponse>;
|
|
41
|
+
swapper: SwapIxsProvider<QuoteResponse>;
|
|
42
|
+
logger?: (msg: string, ...extra: any[]) => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Outputs from the `getSwapCollIxns()` operation.
|
|
46
|
+
*/
|
|
47
|
+
export interface SwapCollIxnsOutputs<QuoteResponse> {
|
|
48
|
+
/**
|
|
49
|
+
* Instructions for on-chain execution.
|
|
50
|
+
*/
|
|
51
|
+
ixs: TransactionInstruction[];
|
|
52
|
+
/**
|
|
53
|
+
* Required LUTs.
|
|
54
|
+
*/
|
|
55
|
+
lookupTables: AddressLookupTableAccount[];
|
|
56
|
+
/**
|
|
57
|
+
* Informational-only details of the token amounts/fees/rates that were used during construction of `ixs`.
|
|
58
|
+
*/
|
|
59
|
+
simulationDetails: {
|
|
60
|
+
/**
|
|
61
|
+
* Details related to the flash-loan operation needed during collateral swap.
|
|
62
|
+
*/
|
|
63
|
+
flashLoan: {
|
|
64
|
+
/**
|
|
65
|
+
* The amount of flash-borrowed target collateral.
|
|
66
|
+
* It is also *exactly the amount of target collateral that gets added to the obligation*.
|
|
67
|
+
*/
|
|
68
|
+
targetCollFlashBorrowedAmount: Decimal;
|
|
69
|
+
/**
|
|
70
|
+
* The flash-repaid amount.
|
|
71
|
+
* Simply a `targetCollFlashBorrowedAmount` + any flash-loan fees.
|
|
72
|
+
*/
|
|
73
|
+
targetCollFlashRepaidAmount: Decimal;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Details related to the external DEX's swap operation (i.e. `swapper` input) needed during collateral swap.
|
|
77
|
+
*/
|
|
78
|
+
externalSwap: {
|
|
79
|
+
/**
|
|
80
|
+
* The amount swapped-in to an external DEX.
|
|
81
|
+
* It is also *exactly the amount of source collateral that gets removed from the obligation* (i.e. echoed back
|
|
82
|
+
* `sourceCollSwapAmount` input).
|
|
83
|
+
*/
|
|
84
|
+
sourceCollSwapInAmount: Decimal;
|
|
85
|
+
/**
|
|
86
|
+
* The amount swapped-out from an external DEX.
|
|
87
|
+
* Please note that this field will be equal to the `flashBorrow.targetCollFlashRepaidAmount`, but an actual
|
|
88
|
+
* on-chain swap-out is subject to slippage.
|
|
89
|
+
*/
|
|
90
|
+
targetCollSwapOutAmount: Decimal;
|
|
91
|
+
/**
|
|
92
|
+
* The verbatim response coming from the input `quoter`.
|
|
93
|
+
*/
|
|
94
|
+
quoteResponse?: QuoteResponse;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Constructs instructions needed to partially/fully swap the given source collateral for some other collateral type.
|
|
100
|
+
*/
|
|
101
|
+
export declare function getSwapCollIxns<QuoteResponse>(inputs: SwapCollIxnsInputs<QuoteResponse>): Promise<SwapCollIxnsOutputs<QuoteResponse>>;
|
|
102
|
+
//# sourceMappingURL=swap_collateral_operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swap_collateral_operations.d.ts","sourceRoot":"","sources":["../../src/lending_operations/swap_collateral_operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,YAAY,EACZ,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAA4B,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC3F,OAAO,EAML,YAAY,EAIb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,yBAAyB,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,OAAO,MAAM,YAAY,CAAC;AAGjC;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,aAAa;IAC/C;;;;OAIG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,mBAAmB,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,mBAAmB,EAAE,SAAS,CAAC;IAE/B;;OAEG;IACH,mBAAmB,EAAE,SAAS,CAAC;IAE/B;;;OAGG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAI1B,MAAM,EAAE,YAAY,CAAC;IACrB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,wBAAwB,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACpD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,MAAM,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC;IACzC,OAAO,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;IACxC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;CACjD;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,aAAa;IAChD;;OAEG;IACH,GAAG,EAAE,sBAAsB,EAAE,CAAC;IAE9B;;OAEG;IACH,YAAY,EAAE,yBAAyB,EAAE,CAAC;IAE1C;;OAEG;IACH,iBAAiB,EAAE;QACjB;;WAEG;QACH,SAAS,EAAE;YACT;;;eAGG;YACH,6BAA6B,EAAE,OAAO,CAAC;YAEvC;;;eAGG;YACH,2BAA2B,EAAE,OAAO,CAAC;SACtC,CAAC;QAEF;;WAEG;QACH,YAAY,EAAE;YACZ;;;;eAIG;YACH,sBAAsB,EAAE,OAAO,CAAC;YAEhC;;;;eAIG;YACH,uBAAuB,EAAE,OAAO,CAAC;YAEjC;;eAEG;YACH,aAAa,CAAC,EAAE,aAAa,CAAC;SAC/B,CAAC;KACH,CAAC;CACH;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,aAAa,EACjD,MAAM,EAAE,kBAAkB,CAAC,aAAa,CAAC,GACxC,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC,CA8C7C"}
|
|
@@ -0,0 +1,306 @@
|
|
|
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.getSwapCollIxns = getSwapCollIxns;
|
|
7
|
+
const classes_1 = require("../classes");
|
|
8
|
+
const leverage_1 = require("../leverage");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
11
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
12
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
13
|
+
/**
|
|
14
|
+
* Constructs instructions needed to partially/fully swap the given source collateral for some other collateral type.
|
|
15
|
+
*/
|
|
16
|
+
async function getSwapCollIxns(inputs) {
|
|
17
|
+
const [args, context] = extractArgsAndContext(inputs);
|
|
18
|
+
// Conceptually, we need to construct the following ixns:
|
|
19
|
+
// 0. any set-up, like budgeting and ATAs
|
|
20
|
+
// 1. `flash-borrowed target coll = targetCollReserve.flashBorrow()`
|
|
21
|
+
// 2. `targetCollReserve.deposit(flash-borrowed target coll)`
|
|
22
|
+
// 3. `sourceCollReserve.withdraw(requested amount to be coll-swapped)`
|
|
23
|
+
// 4. `externally-swapped target coll = externalDex.swap(withdrawn current coll)`
|
|
24
|
+
// 5. `flashRepay(externally-swapped target coll)`
|
|
25
|
+
// However, there is a cyclic dependency:
|
|
26
|
+
// - To construct 4. (specifically, to query the external swap quote), we need to know all accounts used by Kamino's
|
|
27
|
+
// own ixns.
|
|
28
|
+
// - To construct 1. (i.e. flash-borrow), we need to know the target collateral swap-out from 4.
|
|
29
|
+
// Construct the Klend's own ixns with a fake swap-out (only to learn the klend accounts used):
|
|
30
|
+
const fakeKlendIxns = await getKlendIxns(args, FAKE_TARGET_COLL_SWAP_OUT_AMOUNT, context);
|
|
31
|
+
const klendAccounts = (0, utils_1.uniqueAccounts)(listIxns(fakeKlendIxns));
|
|
32
|
+
// Construct the external swap ixns (and learn the actual swap-out amount):
|
|
33
|
+
const externalSwapIxns = await getExternalSwapIxns(args, klendAccounts, context);
|
|
34
|
+
// We now have the full information needed to simulate the end-state, so let's check that the operation is legal:
|
|
35
|
+
context.logger(`Expected to swap ${args.sourceCollSwapAmount} ${context.sourceCollReserve.symbol} collateral into ${externalSwapIxns.swapOutAmount} ${context.targetCollReserve.symbol} collateral`);
|
|
36
|
+
checkResultingObligationValid(args, externalSwapIxns.swapOutAmount, context);
|
|
37
|
+
// Construct the Klend's own ixns with an actual swap-out amount:
|
|
38
|
+
const klendIxns = await getKlendIxns(args, externalSwapIxns.swapOutAmount, context);
|
|
39
|
+
return {
|
|
40
|
+
ixs: listIxns(klendIxns, externalSwapIxns.ixns),
|
|
41
|
+
lookupTables: externalSwapIxns.luts,
|
|
42
|
+
simulationDetails: {
|
|
43
|
+
flashLoan: {
|
|
44
|
+
targetCollFlashBorrowedAmount: klendIxns.simulationDetails.targetCollFlashBorrowedAmount,
|
|
45
|
+
targetCollFlashRepaidAmount: externalSwapIxns.swapOutAmount,
|
|
46
|
+
},
|
|
47
|
+
externalSwap: {
|
|
48
|
+
sourceCollSwapInAmount: args.sourceCollSwapAmount, // repeated `/inputs.sourceCollSwapAmount`, only for clarity
|
|
49
|
+
targetCollSwapOutAmount: externalSwapIxns.swapOutAmount, // repeated `../flashLoan.targetCollFlashRepaidAmount`, only for clarity
|
|
50
|
+
quoteResponse: externalSwapIxns.simulationDetails.quoteResponse,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function extractArgsAndContext(inputs) {
|
|
56
|
+
if (inputs.sourceCollTokenMint.equals(inputs.targetCollTokenMint)) {
|
|
57
|
+
throw new Error(`Cannot swap from/to the same collateral`);
|
|
58
|
+
}
|
|
59
|
+
if (inputs.sourceCollSwapAmount.lte(0)) {
|
|
60
|
+
throw new Error(`Cannot swap a negative amount`);
|
|
61
|
+
}
|
|
62
|
+
return [
|
|
63
|
+
{
|
|
64
|
+
sourceCollSwapAmount: inputs.sourceCollSwapAmount,
|
|
65
|
+
isClosingSourceColl: inputs.isClosingSourceColl,
|
|
66
|
+
newElevationGroup: inputs.market.getExistingElevationGroup(inputs.newElevationGroup, 'Newly-requested'),
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
budgetAndPriorityFeeIxns: inputs.budgetAndPriorityFeeIxns || (0, utils_1.getComputeBudgetAndPriorityFeeIxns)(utils_1.DEFAULT_MAX_COMPUTE_UNITS),
|
|
70
|
+
sourceCollReserve: inputs.market.getExistingReserveByMint(inputs.sourceCollTokenMint, 'Current collateral'),
|
|
71
|
+
targetCollReserve: inputs.market.getExistingReserveByMint(inputs.targetCollTokenMint, 'Target collateral'),
|
|
72
|
+
logger: console.log,
|
|
73
|
+
market: inputs.market,
|
|
74
|
+
obligation: inputs.obligation,
|
|
75
|
+
quoter: inputs.quoter,
|
|
76
|
+
swapper: inputs.swapper,
|
|
77
|
+
referrer: inputs.referrer,
|
|
78
|
+
scopeRefresh: inputs.scopeRefresh,
|
|
79
|
+
currentSlot: inputs.currentSlot,
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
const FAKE_TARGET_COLL_SWAP_OUT_AMOUNT = new decimal_js_1.default(1); // see the lengthy `getSwapCollIxns()` impl comment
|
|
84
|
+
async function getKlendIxns(args, targetCollSwapOutAmount, context) {
|
|
85
|
+
const { ataCreationIxns, targetCollAta } = getAtaCreationIxns(context);
|
|
86
|
+
const setupIxns = [...context.budgetAndPriorityFeeIxns, ...ataCreationIxns];
|
|
87
|
+
const targetCollFlashBorrowedAmount = calculateTargetCollFlashBorrowedAmount(targetCollSwapOutAmount, context);
|
|
88
|
+
const { targetCollFlashBorrowIxn, targetCollFlashRepayIxn } = getTargetCollFlashLoanIxns(targetCollFlashBorrowedAmount, setupIxns.length, targetCollAta, context);
|
|
89
|
+
const depositTargetCollIxns = await getDepositTargetCollIxns(targetCollFlashBorrowedAmount, context);
|
|
90
|
+
const withdrawSourceCollIxns = await getWithdrawSourceCollIxns(args, depositTargetCollIxns.removesElevationGroup, context);
|
|
91
|
+
const cleanupIxns = getAtaCloseIxns(context);
|
|
92
|
+
return {
|
|
93
|
+
setupIxns,
|
|
94
|
+
targetCollFlashBorrowIxn,
|
|
95
|
+
depositTargetCollIxns: depositTargetCollIxns.ixns,
|
|
96
|
+
withdrawSourceCollIxns,
|
|
97
|
+
targetCollFlashRepayIxn,
|
|
98
|
+
cleanupIxns,
|
|
99
|
+
simulationDetails: {
|
|
100
|
+
targetCollFlashBorrowedAmount,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function calculateTargetCollFlashBorrowedAmount(targetCollFlashRepaidAmount, context) {
|
|
105
|
+
const { protocolFees, referrerFees } = context.targetCollReserve.calculateFees(targetCollFlashRepaidAmount.mul(context.targetCollReserve.getMintFactor()), context.targetCollReserve.getFlashLoanFee(), classes_1.FeeCalculation.Inclusive, // denotes that the amount parameter above means "to be repaid" (not "borrowed")
|
|
106
|
+
context.market.state.referralFeeBps, !context.referrer.equals(web3_js_1.PublicKey.default));
|
|
107
|
+
const targetCollFlashLoanFee = protocolFees.add(referrerFees).div(context.targetCollReserve.getMintFactor());
|
|
108
|
+
return targetCollFlashRepaidAmount.sub(targetCollFlashLoanFee);
|
|
109
|
+
}
|
|
110
|
+
function getAtaCreationIxns(context) {
|
|
111
|
+
const atasAndAtaCreationIxns = (0, utils_1.createAtasIdempotent)(context.obligation.state.owner, [
|
|
112
|
+
{
|
|
113
|
+
mint: context.sourceCollReserve.getLiquidityMint(),
|
|
114
|
+
tokenProgram: context.sourceCollReserve.getLiquidityTokenProgram(),
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
mint: context.targetCollReserve.getLiquidityMint(),
|
|
118
|
+
tokenProgram: context.targetCollReserve.getLiquidityTokenProgram(),
|
|
119
|
+
},
|
|
120
|
+
]);
|
|
121
|
+
return {
|
|
122
|
+
ataCreationIxns: atasAndAtaCreationIxns.map((tuple) => tuple.createAtaIx),
|
|
123
|
+
targetCollAta: atasAndAtaCreationIxns[1].ata,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function getAtaCloseIxns(context) {
|
|
127
|
+
const ataCloseIxns = [];
|
|
128
|
+
if (context.sourceCollReserve.getLiquidityMint().equals(utils_1.WRAPPED_SOL_MINT) ||
|
|
129
|
+
context.targetCollReserve.getLiquidityMint().equals(utils_1.WRAPPED_SOL_MINT)) {
|
|
130
|
+
const owner = context.obligation.state.owner;
|
|
131
|
+
const wsolAta = (0, utils_1.getAssociatedTokenAddress)(utils_1.WRAPPED_SOL_MINT, owner, false);
|
|
132
|
+
ataCloseIxns.push((0, spl_token_1.createCloseAccountInstruction)(wsolAta, owner, owner, [], spl_token_1.TOKEN_PROGRAM_ID));
|
|
133
|
+
}
|
|
134
|
+
return ataCloseIxns;
|
|
135
|
+
}
|
|
136
|
+
function getTargetCollFlashLoanIxns(targetCollAmount, flashBorrowIxnIndex, destinationAta, context) {
|
|
137
|
+
const { flashBorrowIxn: targetCollFlashBorrowIxn, flashRepayIxn: targetCollFlashRepayIxn } = (0, leverage_1.getFlashLoanInstructions)({
|
|
138
|
+
borrowIxnIndex: flashBorrowIxnIndex,
|
|
139
|
+
walletPublicKey: context.obligation.state.owner,
|
|
140
|
+
lendingMarketAuthority: context.market.getLendingMarketAuthority(),
|
|
141
|
+
lendingMarketAddress: context.market.getAddress(),
|
|
142
|
+
reserve: context.targetCollReserve,
|
|
143
|
+
amountLamports: targetCollAmount.mul(context.targetCollReserve.getMintFactor()),
|
|
144
|
+
destinationAta,
|
|
145
|
+
// TODO(referrals): once we support referrals, we will have to replace the placeholder args below:
|
|
146
|
+
referrerAccount: context.market.programId,
|
|
147
|
+
referrerTokenState: context.market.programId,
|
|
148
|
+
programId: context.market.programId,
|
|
149
|
+
});
|
|
150
|
+
return { targetCollFlashBorrowIxn, targetCollFlashRepayIxn };
|
|
151
|
+
}
|
|
152
|
+
async function getDepositTargetCollIxns(targetCollAmount, context) {
|
|
153
|
+
const removesElevationGroup = mustRemoveElevationGroupBeforeDeposit(context);
|
|
154
|
+
const depositCollAction = await classes_1.KaminoAction.buildDepositTxns(context.market, targetCollAmount.mul(context.targetCollReserve.getMintFactor()).toString(), // in lamports
|
|
155
|
+
context.targetCollReserve.getLiquidityMint(), context.obligation.state.owner, context.obligation, 0, // no extra compute budget
|
|
156
|
+
false, // we do not need ATA ixns here (we construct and close them ourselves)
|
|
157
|
+
removesElevationGroup, // we may need to (temporarily) remove the elevation group; the same or a different one will be set on withdraw, if requested
|
|
158
|
+
false, // we are dealing with an existing obligation, no need to create user metadata
|
|
159
|
+
context.referrer, context.currentSlot, context.scopeRefresh, removesElevationGroup ? 0 : undefined // only applicable when removing the group
|
|
160
|
+
);
|
|
161
|
+
return {
|
|
162
|
+
ixns: classes_1.KaminoAction.actionToIxs(depositCollAction),
|
|
163
|
+
removesElevationGroup,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function mustRemoveElevationGroupBeforeDeposit(context) {
|
|
167
|
+
if (context.obligation.deposits.has(context.targetCollReserve.address)) {
|
|
168
|
+
return false; // the target collateral already was a reserve in the obligation, so we do not affect any potential elevation group
|
|
169
|
+
}
|
|
170
|
+
const currentElevationGroupId = context.obligation.state.elevationGroup;
|
|
171
|
+
if (currentElevationGroupId == 0) {
|
|
172
|
+
return false; // simply nothing to remove
|
|
173
|
+
}
|
|
174
|
+
if (!context.targetCollReserve.state.config.elevationGroups.includes(currentElevationGroupId)) {
|
|
175
|
+
return true; // the target collateral reserve is NOT in the obligation's group - must remove the group
|
|
176
|
+
}
|
|
177
|
+
const currentElevationGroup = context.market.getElevationGroup(currentElevationGroupId);
|
|
178
|
+
if (context.obligation.deposits.size >= currentElevationGroup.maxReservesAsCollateral) {
|
|
179
|
+
return true; // the obligation is already at its elevation group's deposits count limit - must remove the group
|
|
180
|
+
}
|
|
181
|
+
return false; // the obligation has some elevation group and the new collateral can be added to it
|
|
182
|
+
}
|
|
183
|
+
async function getWithdrawSourceCollIxns(args, depositRemovedElevationGroup, context) {
|
|
184
|
+
const withdrawnSourceCollLamports = args.isClosingSourceColl
|
|
185
|
+
? utils_1.U64_MAX
|
|
186
|
+
: args.sourceCollSwapAmount.mul(context.sourceCollReserve.getMintFactor()).toString();
|
|
187
|
+
const requestedElevationGroup = elevationGroupIdToRequestAfterWithdraw(args, depositRemovedElevationGroup, context);
|
|
188
|
+
const withdrawCollAction = await classes_1.KaminoAction.buildWithdrawTxns(context.market, withdrawnSourceCollLamports, context.sourceCollReserve.getLiquidityMint(), context.obligation.state.owner, context.obligation, 0, // no extra compute budget
|
|
189
|
+
false, // we do not need ATA ixns here (we construct and close them ourselves)
|
|
190
|
+
requestedElevationGroup !== undefined, // the `elevationGroupIdToRequestAfterWithdraw()` has already decided on this
|
|
191
|
+
false, // we are dealing with an existing obligation, no need to create user metadata
|
|
192
|
+
context.referrer, context.currentSlot, undefined, // we have refreshed scope already, during depositing
|
|
193
|
+
requestedElevationGroup, context.obligation.deposits.has(context.targetCollReserve.address) // if our obligation already had the target coll...
|
|
194
|
+
? undefined // ... then we need no customizations here, but otherwise...
|
|
195
|
+
: {
|
|
196
|
+
addedDepositReserves: [context.targetCollReserve.address], // ... we need to inform our infra that the obligation now has one more reserve that needs refreshing.
|
|
197
|
+
});
|
|
198
|
+
return classes_1.KaminoAction.actionToIxs(withdrawCollAction);
|
|
199
|
+
}
|
|
200
|
+
function elevationGroupIdToRequestAfterWithdraw(args, depositRemovedElevationGroup, context) {
|
|
201
|
+
const obligationInitialElevationGroup = context.obligation.state.elevationGroup;
|
|
202
|
+
const requestedElevationGroupId = args.newElevationGroup?.elevationGroup ?? 0;
|
|
203
|
+
if (requestedElevationGroupId === 0) {
|
|
204
|
+
// the user doesn't want any elevation group, and...
|
|
205
|
+
if (obligationInitialElevationGroup === 0) {
|
|
206
|
+
return undefined; // ... he already didn't have it - fine!
|
|
207
|
+
}
|
|
208
|
+
if (depositRemovedElevationGroup) {
|
|
209
|
+
return undefined; // ... our deposit already forced us to remove it - fine!
|
|
210
|
+
}
|
|
211
|
+
return 0; // ... but he *did have one*, and our deposit didn't need to remove it - so we remove it now, just to satisfy him
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
// the user wants some elevation group, and...
|
|
215
|
+
if (depositRemovedElevationGroup) {
|
|
216
|
+
return requestedElevationGroupId; // ...our deposit forced us to remove it - so we now request the new one, whatever it is
|
|
217
|
+
}
|
|
218
|
+
if (obligationInitialElevationGroup === requestedElevationGroupId) {
|
|
219
|
+
return undefined; // ...and he already had exactly this one - fine!
|
|
220
|
+
}
|
|
221
|
+
return requestedElevationGroupId; // ...and he had some different one - so we request the new one
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async function getExternalSwapIxns(args, klendAccounts, context) {
|
|
225
|
+
const externalSwapInputs = {
|
|
226
|
+
inputAmountLamports: args.sourceCollSwapAmount.mul(context.sourceCollReserve.getMintFactor()),
|
|
227
|
+
inputMint: context.sourceCollReserve.getLiquidityMint(),
|
|
228
|
+
outputMint: context.targetCollReserve.getLiquidityMint(),
|
|
229
|
+
amountDebtAtaBalance: undefined, // only used for kTokens
|
|
230
|
+
};
|
|
231
|
+
const externalSwapQuote = await context.quoter(externalSwapInputs, klendAccounts);
|
|
232
|
+
const swapOutAmount = externalSwapQuote.priceAInB.mul(args.sourceCollSwapAmount);
|
|
233
|
+
const externalSwapIxnsAndLuts = await context.swapper(externalSwapInputs, klendAccounts, externalSwapQuote);
|
|
234
|
+
// Note: we can ignore the returned `preActionIxs` field - we do not request any of them from the swapper.
|
|
235
|
+
return {
|
|
236
|
+
swapOutAmount,
|
|
237
|
+
ixns: externalSwapIxnsAndLuts.swapIxs,
|
|
238
|
+
luts: externalSwapIxnsAndLuts.lookupTables,
|
|
239
|
+
simulationDetails: {
|
|
240
|
+
quoteResponse: externalSwapQuote.quoteResponse,
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function checkResultingObligationValid(args, targetCollAmount, context) {
|
|
245
|
+
// The newly-requested elevation group must have its conditions satisfied:
|
|
246
|
+
if (args.newElevationGroup !== null) {
|
|
247
|
+
// Note: we cannot use the existing `isLoanEligibleForElevationGroup()`, since it operates on a `KaminoObligation`,
|
|
248
|
+
// and our instance is stale (we want to assert on the state *after* potential changes).
|
|
249
|
+
// Let's start with the (simpler) debt reserve - it cannot change during a coll-swap:
|
|
250
|
+
const debtReserveAddresses = [...context.obligation.borrows.keys()];
|
|
251
|
+
if (debtReserveAddresses.length > 1) {
|
|
252
|
+
throw new Error(`The obligation with ${debtReserveAddresses.length} debt reserves cannot request any elevation group`);
|
|
253
|
+
}
|
|
254
|
+
if (debtReserveAddresses.length == 1) {
|
|
255
|
+
const debtReserveAddress = debtReserveAddresses[0];
|
|
256
|
+
if (!args.newElevationGroup.debtReserve.equals(debtReserveAddress)) {
|
|
257
|
+
throw new Error(`The obligation with debt reserve ${debtReserveAddress.toBase58()} cannot request elevation group ${args.newElevationGroup.elevationGroup}`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
// Now the coll reserves: this requires first finding out the resulting set of deposits:
|
|
261
|
+
const collReserveAddresses = new utils_1.PublicKeySet([
|
|
262
|
+
...context.obligation.deposits.keys(),
|
|
263
|
+
context.targetCollReserve.address,
|
|
264
|
+
]);
|
|
265
|
+
if (args.isClosingSourceColl) {
|
|
266
|
+
collReserveAddresses.remove(context.sourceCollReserve.address);
|
|
267
|
+
}
|
|
268
|
+
if (collReserveAddresses.size() > args.newElevationGroup.maxReservesAsCollateral) {
|
|
269
|
+
throw new Error(`The obligation with ${collReserveAddresses.size()} collateral reserves cannot request elevation group ${args.newElevationGroup.elevationGroup}`);
|
|
270
|
+
}
|
|
271
|
+
for (const collReserveAddress of collReserveAddresses.toArray()) {
|
|
272
|
+
if (!args.newElevationGroup.collateralReserves.contains(collReserveAddress)) {
|
|
273
|
+
throw new Error(`The obligation with collateral reserve ${collReserveAddress.toBase58()} cannot request elevation group ${args.newElevationGroup.elevationGroup}`);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// The LTV cannot be exceeded:
|
|
278
|
+
const effectiveWithdrawAmount = args.isClosingSourceColl
|
|
279
|
+
? context.obligation.getDepositAmountByReserve(context.sourceCollReserve)
|
|
280
|
+
: args.sourceCollSwapAmount;
|
|
281
|
+
const resultingStats = context.obligation.getPostSwapCollObligationStats({
|
|
282
|
+
withdrawAmountLamports: effectiveWithdrawAmount.mul(context.sourceCollReserve.getMintFactor()),
|
|
283
|
+
withdrawReserveAddress: context.sourceCollReserve.address,
|
|
284
|
+
depositAmountLamports: targetCollAmount.mul(context.targetCollReserve.getMintFactor()),
|
|
285
|
+
depositReserveAddress: context.targetCollReserve.address,
|
|
286
|
+
market: context.market,
|
|
287
|
+
newElevationGroup: args.newElevationGroup?.elevationGroup ?? 0,
|
|
288
|
+
slot: context.currentSlot,
|
|
289
|
+
});
|
|
290
|
+
const maxLtv = resultingStats.borrowLimit.div(resultingStats.userTotalCollateralDeposit);
|
|
291
|
+
if (resultingStats.loanToValue > maxLtv) {
|
|
292
|
+
throw new Error(`Swapping collateral ${effectiveWithdrawAmount} ${context.sourceCollReserve.symbol} into ${targetCollAmount} ${context.targetCollReserve.symbol} would result in the obligation's LTV ${resultingStats.loanToValue} exceeding its max LTV ${maxLtv}`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
function listIxns(klendIxns, externalSwapIxns) {
|
|
296
|
+
return [
|
|
297
|
+
...klendIxns.setupIxns,
|
|
298
|
+
klendIxns.targetCollFlashBorrowIxn,
|
|
299
|
+
...klendIxns.depositTargetCollIxns,
|
|
300
|
+
...klendIxns.withdrawSourceCollIxns,
|
|
301
|
+
...(externalSwapIxns || []),
|
|
302
|
+
klendIxns.targetCollFlashRepayIxn,
|
|
303
|
+
...klendIxns.cleanupIxns,
|
|
304
|
+
];
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=swap_collateral_operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swap_collateral_operations.js","sourceRoot":"","sources":["../../src/lending_operations/swap_collateral_operations.ts"],"names":[],"mappings":";;;;;AAsIA,0CAgDC;AAtLD,wCAOoB;AACpB,0CAA2F;AAC3F,oCAUkB;AAClB,6CAA+F;AAC/F,4DAAiC;AACjC,iDAAoF;AA6GpF;;GAEG;AACI,KAAK,UAAU,eAAe,CACnC,MAAyC;IAEzC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAEtD,yDAAyD;IACzD,0CAA0C;IAC1C,qEAAqE;IACrE,8DAA8D;IAC9D,wEAAwE;IACxE,kFAAkF;IAClF,mDAAmD;IACnD,yCAAyC;IACzC,qHAAqH;IACrH,eAAe;IACf,iGAAiG;IAEjG,+FAA+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CAAC,iBAAiB,CAAC,OAAO;QACxD,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE,cAAc,IAAI,CAAC;QAC9D,IAAI,EAAE,OAAO,CAAC,WAAW;KAC1B,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,cAAc,CAAC,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,0BAA0B,CAAC,CAAC;IACzF,IAAI,cAAc,CAAC,WAAW,GAAG,MAAM,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,uBAAuB,uBAAuB,IAAI,OAAO,CAAC,iBAAiB,CAAC,MAAM,SAAS,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,CAAC,MAAM,yCAAyC,cAAc,CAAC,WAAW,0BAA0B,MAAM,EAAE,CACrP,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,SAA4B,EAAE,gBAA2C;IACzF,OAAO;QACL,GAAG,SAAS,CAAC,SAAS;QACtB,SAAS,CAAC,wBAAwB;QAClC,GAAG,SAAS,CAAC,qBAAqB;QAClC,GAAG,SAAS,CAAC,sBAAsB;QACnC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC;QAC3B,SAAS,CAAC,uBAAuB;QACjC,GAAG,SAAS,CAAC,WAAW;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
2
|
import { KaminoMarket, KaminoObligation, KaminoReserve } from '../classes';
|
|
3
3
|
import { StrategyWithAddress } from '@kamino-finance/kliquidity-sdk';
|
|
4
|
-
import { AdjustLeverageInitialInputs, AdjustLeverageIxsResponse, AdjustLeverageProps, AdjustLeverageSwapInputsProps, DepositLeverageInitialInputs, DepositWithLeverageProps, DepositWithLeverageSwapInputsProps, DepsoitLeverageIxsResponse, SwapInputs,
|
|
4
|
+
import { AdjustLeverageInitialInputs, AdjustLeverageIxsResponse, AdjustLeverageProps, AdjustLeverageSwapInputsProps, DepositLeverageInitialInputs, DepositWithLeverageProps, DepositWithLeverageSwapInputsProps, DepsoitLeverageIxsResponse, SwapInputs, SwapIxs, WithdrawLeverageCalcsResult, WithdrawLeverageInitialInputs, WithdrawLeverageIxsResponse, WithdrawWithLeverageProps, WithdrawWithLeverageSwapInputsProps } from './types';
|
|
5
5
|
export declare function getDepositWithLeverageSwapInputs<QuoteResponse>({ owner, kaminoMarket, debtTokenMint, collTokenMint, depositAmount, priceDebtToColl, slippagePct, obligation, referrer, currentSlot, targetLeverage, selectedTokenMint, kamino, obligationTypeTagOverride, scopeFeed, budgetAndPriorityFeeIxs, quoteBufferBps, priceAinB, isKtoken, quoter, elevationGroupOverride, }: DepositWithLeverageSwapInputsProps<QuoteResponse>): Promise<{
|
|
6
6
|
swapInputs: SwapInputs;
|
|
7
7
|
initialInputs: DepositLeverageInitialInputs<QuoteResponse>;
|
|
@@ -12,7 +12,7 @@ export declare function getWithdrawWithLeverageSwapInputs<QuoteResponse>({ owner
|
|
|
12
12
|
initialInputs: WithdrawLeverageInitialInputs<QuoteResponse>;
|
|
13
13
|
}>;
|
|
14
14
|
export declare function getWithdrawWithLeverageIxns<QuoteResponse>({ owner, kaminoMarket, debtTokenMint, collTokenMint, obligation, deposited, borrowed, referrer, currentSlot, withdrawAmount, priceCollToDebt, slippagePct, isClosingPosition, selectedTokenMint, budgetAndPriorityFeeIxs, kamino, scopeFeed, quoteBufferBps, isKtoken, quoter, swapper, }: WithdrawWithLeverageProps<QuoteResponse>): Promise<WithdrawLeverageIxsResponse<QuoteResponse>>;
|
|
15
|
-
export declare function buildWithdrawWithLeverageIxns(market: KaminoMarket, debtReserve: KaminoReserve, collReserve: KaminoReserve, owner: PublicKey, obligation: KaminoObligation, referrer: PublicKey, currentSlot: number, isClosingPosition: boolean, depositTokenIsSol: boolean, scopeFeed: string | undefined, calcs: WithdrawLeverageCalcsResult, budgetAndPriorityFeeIxs: TransactionInstruction[] | undefined, swapQuoteIxs:
|
|
15
|
+
export declare function buildWithdrawWithLeverageIxns(market: KaminoMarket, debtReserve: KaminoReserve, collReserve: KaminoReserve, owner: PublicKey, obligation: KaminoObligation, referrer: PublicKey, currentSlot: number, isClosingPosition: boolean, depositTokenIsSol: boolean, scopeFeed: string | undefined, calcs: WithdrawLeverageCalcsResult, budgetAndPriorityFeeIxs: TransactionInstruction[] | undefined, swapQuoteIxs: SwapIxs, strategy: StrategyWithAddress | undefined, collIsKtoken: boolean): Promise<TransactionInstruction[]>;
|
|
16
16
|
export declare function getAdjustLeverageSwapInputs<QuoteResponse>({ owner, kaminoMarket, debtTokenMint, collTokenMint, obligation, depositedLamports, borrowedLamports, referrer, currentSlot, targetLeverage, priceCollToDebt, priceDebtToColl, slippagePct, budgetAndPriorityFeeIxs, kamino, scopeFeed, quoteBufferBps, isKtoken, quoter, }: AdjustLeverageSwapInputsProps<QuoteResponse>): Promise<{
|
|
17
17
|
swapInputs: SwapInputs;
|
|
18
18
|
initialInputs: AdjustLeverageInitialInputs<QuoteResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/leverage/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,SAAS,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEtF,OAAO,EAEL,YAAY,EACZ,gBAAgB,EAChB,aAAa,EAEd,MAAM,YAAY,CAAC;AA8BpB,OAAO,EAAU,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAG7E,OAAO,EAEL,2BAA2B,EAC3B,yBAAyB,EACzB,mBAAmB,EACnB,6BAA6B,EAE7B,4BAA4B,EAC5B,wBAAwB,EACxB,kCAAkC,EAClC,0BAA0B,EAE1B,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/leverage/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,SAAS,EA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E,OAAO,EACrB,QAAQ,EAAE,mBAAmB,GAAG,SAAS,EACzC,YAAY,EAAE,OAAO,GACpB,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAqInC;AAED,wBAAsB,2BAA2B,CAAC,aAAa,EAAE,EAC/D,KAAK,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,eAAe,EACf,eAAe,EACf,WAAW,EACX,uBAAuB,EACvB,MAAM,EACN,SAAS,EACT,cAAc,EACd,QAAQ,EACR,MAAM,GACP,EAAE,6BAA6B,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC;IACxD,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,2BAA2B,CAAC,aAAa,CAAC,CAAC;CAC3D,CAAC,CAmOD;AAED,wBAAsB,qBAAqB,CAAC,aAAa,EAAE,EACzD,KAAK,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,eAAe,EACf,eAAe,EACf,WAAW,EACX,uBAAuB,EACvB,MAAM,EACN,SAAS,EACT,cAAc,EACd,SAAS,EACT,QAAQ,EACR,MAAM,EACN,OAAO,GACR,EAAE,mBAAmB,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,yBAAyB,CAAC,aAAa,CAAC,CAAC,CA6HxF"}
|
|
@@ -250,6 +250,7 @@ async function buildDepositWithLeverageIxns(market, debtReserve, collReserve, ow
|
|
|
250
250
|
reserve: !collIsKtoken ? collReserve : debtReserve,
|
|
251
251
|
amountLamports: (0, classes_2.numberToLamportsDecimal)(!collIsKtoken ? calcs.flashBorrowInCollToken : calcs.flashBorrowInDebtTokenKtokenOnly, !collIsKtoken ? collReserve.stats.decimals : debtReserve.stats.decimals),
|
|
252
252
|
destinationAta: !collIsKtoken ? collTokenAta : debtTokenAta,
|
|
253
|
+
// TODO(referrals): once we support referrals, we will have to replace the placeholder args below:
|
|
253
254
|
referrerAccount: market.programId,
|
|
254
255
|
referrerTokenState: market.programId,
|
|
255
256
|
programId: market.programId,
|
|
@@ -476,6 +477,7 @@ async function buildWithdrawWithLeverageIxns(market, debtReserve, collReserve, o
|
|
|
476
477
|
reserve: debtReserve,
|
|
477
478
|
amountLamports: (0, classes_2.numberToLamportsDecimal)(calcs.repayAmount, debtReserve.stats.decimals),
|
|
478
479
|
destinationAta: debtTokenAta,
|
|
480
|
+
// TODO(referrals): once we support referrals, we will have to replace the placeholder args below:
|
|
479
481
|
referrerAccount: market.programId,
|
|
480
482
|
referrerTokenState: market.programId,
|
|
481
483
|
programId: market.programId,
|
|
@@ -766,6 +768,7 @@ async function buildIncreaseLeverageIxns(owner, kaminoMarket, collTokenMint, deb
|
|
|
766
768
|
reserve: !collIsKtoken ? collReserve : debtReserve,
|
|
767
769
|
amountLamports: (0, classes_2.numberToLamportsDecimal)(!collIsKtoken ? calcs.adjustDepositPosition : calcs.amountToFlashBorrowDebt, !collIsKtoken ? collReserve.stats.decimals : debtReserve.stats.decimals),
|
|
768
770
|
destinationAta: !collIsKtoken ? collTokenAta : debtTokenAta,
|
|
771
|
+
// TODO(referrals): once we support referrals, we will have to replace the placeholder args below:
|
|
769
772
|
referrerAccount: kaminoMarket.programId,
|
|
770
773
|
referrerTokenState: kaminoMarket.programId,
|
|
771
774
|
programId: kaminoMarket.programId,
|
|
@@ -882,6 +885,7 @@ async function buildDecreaseLeverageIxns(owner, kaminoMarket, collTokenMint, deb
|
|
|
882
885
|
reserve: debtReserve,
|
|
883
886
|
amountLamports: (0, classes_2.numberToLamportsDecimal)(decimal_js_1.default.abs(calcs.adjustBorrowPosition), debtReserve.stats.decimals),
|
|
884
887
|
destinationAta: debtTokenAta,
|
|
888
|
+
// TODO(referrals): once we support referrals, we will have to replace the placeholder args below:
|
|
885
889
|
referrerAccount: kaminoMarket.programId,
|
|
886
890
|
referrerTokenState: kaminoMarket.programId,
|
|
887
891
|
programId: kaminoMarket.programId,
|