@haven-fi/solauto-sdk 1.0.63 → 1.0.65
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/utils/marginfiUtils.d.ts +2 -2
- package/dist/utils/marginfiUtils.d.ts.map +1 -1
- package/dist/utils/marginfiUtils.js +3 -3
- package/dist/utils/solauto/generalUtils.d.ts +2 -3
- package/dist/utils/solauto/generalUtils.d.ts.map +1 -1
- package/dist/utils/solauto/generalUtils.js +11 -9
- package/package.json +1 -1
- package/src/utils/marginfiUtils.ts +5 -5
- package/src/utils/solauto/generalUtils.ts +20 -16
- package/tests/unit/rebalanceCalculations.ts +3 -7
@@ -10,10 +10,10 @@ export declare function findMarginfiAccounts({ mint, bank, }: {
|
|
10
10
|
}): MarginfiAssetAccounts;
|
11
11
|
export declare function getMaxLtvAndLiqThreshold(umi: Umi, supply: {
|
12
12
|
mint: PublicKey;
|
13
|
-
bank
|
13
|
+
bank?: Bank | null;
|
14
14
|
}, debt: {
|
15
15
|
mint: PublicKey;
|
16
|
-
bank
|
16
|
+
bank?: Bank | null;
|
17
17
|
}, supplyPrice?: number): Promise<[number, number]>;
|
18
18
|
export declare function getAllMarginfiAccountsByAuthority(umi: Umi, authority: PublicKey, compatibleWithSolauto?: boolean): Promise<{
|
19
19
|
marginfiAccount: PublicKey;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marginfiUtils.d.ts","sourceRoot":"","sources":["../../src/utils/marginfiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EACL,IAAI,EAKL,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,wBAAgB,oBAAoB,CAAC,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AAS,EACpB,qBAAqB,CAAC,EAAE,OAAO,GAC9B,OAAO,CACR;IAAE,eAAe,EAAE,SAAS,CAAC;IAAC,UAAU,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,EAAE,CAC/E,CA6CA;AAgED,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,GAAG,EACR,iBAAiB,EAAE,SAAS,EAC5B,UAAU,CAAC,EAAE,SAAS,EACtB,QAAQ,CAAC,EAAE,SAAS,EACpB,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA+IpC;AA+DD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA0B3B"}
|
@@ -28,12 +28,12 @@ function findMarginfiAccounts({ mint, bank, }) {
|
|
28
28
|
throw new Error(`Marginfi accounts not found by the mint: ${mint}`);
|
29
29
|
}
|
30
30
|
async function getMaxLtvAndLiqThreshold(umi, supply, debt, supplyPrice) {
|
31
|
-
if (!supply.bank) {
|
31
|
+
if (!supply.bank || supply.bank === null) {
|
32
32
|
supply.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(findMarginfiAccounts({
|
33
33
|
mint: supply.mint.toString(),
|
34
34
|
}).bank));
|
35
35
|
}
|
36
|
-
if (!debt.bank && !debt.mint.equals(web3_js_1.PublicKey.default)) {
|
36
|
+
if ((!debt.bank || debt.bank === null) && !debt.mint.equals(web3_js_1.PublicKey.default)) {
|
37
37
|
debt.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(findMarginfiAccounts({
|
38
38
|
mint: debt.mint.toString(),
|
39
39
|
}).bank));
|
@@ -44,7 +44,7 @@ async function getMaxLtvAndLiqThreshold(umi, supply, debt, supplyPrice) {
|
|
44
44
|
]);
|
45
45
|
supplyPrice = price;
|
46
46
|
}
|
47
|
-
if (debt.bank === null) {
|
47
|
+
if (!debt.bank || debt.bank === null) {
|
48
48
|
return [0, 0];
|
49
49
|
}
|
50
50
|
let maxLtv = (0, numberUtils_1.bytesToI80F48)(supply.bank.config.assetWeightInit.value) /
|
@@ -19,10 +19,9 @@ export declare function getReferralsByUser(umi: Umi, user: PublicKey): Promise<P
|
|
19
19
|
export declare function getAllPositionsByAuthority(umi: Umi, user: PublicKey): Promise<SolautoPositionDetails[]>;
|
20
20
|
export declare function positionStateWithLatestPrices(state: PositionState, supplyPrice?: number, debtPrice?: number): Promise<PositionState>;
|
21
21
|
interface AssetProps {
|
22
|
-
amountUsedBaseUnit: bigint;
|
23
|
-
decimals: number;
|
24
|
-
price: number;
|
25
22
|
mint: PublicKey;
|
23
|
+
price: number;
|
24
|
+
amountUsed: number;
|
26
25
|
}
|
27
26
|
export declare function createFakePositionState(supply: AssetProps, debt: AssetProps, maxLtvBps: number, liqThresholdBps: number): PositionState;
|
28
27
|
type PositionAdjustment = {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAA+B,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,OAAO,EAEP,aAAa,EAEb,yBAAyB,EACzB,gCAAgC,EAIjC,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAA+B,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,kB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C,MAAM,EAAE,kBAAkB;IAyD9B,KAAK;IAQL,UAAU,IAAI,OAAO;CAQtB"}
|
@@ -248,22 +248,24 @@ async function positionStateWithLatestPrices(state, supplyPrice, debtPrice) {
|
|
248
248
|
};
|
249
249
|
}
|
250
250
|
function createFakePositionState(supply, debt, maxLtvBps, liqThresholdBps) {
|
251
|
-
const
|
252
|
-
const
|
251
|
+
const supplyDecimals = constants_1.TOKEN_DECIMALS[supply.mint.toString()];
|
252
|
+
const debtDecimals = constants_1.TOKEN_DECIMALS[debt.mint.toString()];
|
253
|
+
const supplyUsd = supply.amountUsed * supply.price;
|
254
|
+
const debtUsd = debt.amountUsed * debt.price;
|
253
255
|
return {
|
254
256
|
liqUtilizationRateBps: (0, numberUtils_1.getLiqUtilzationRateBps)(supplyUsd, debtUsd, liqThresholdBps),
|
255
257
|
supply: {
|
256
258
|
amountUsed: {
|
257
|
-
baseUnit: supply.
|
259
|
+
baseUnit: (0, numberUtils_1.toBaseUnit)(supply.amountUsed, supplyDecimals),
|
258
260
|
baseAmountUsdValue: (0, numberUtils_1.toBaseUnit)(supplyUsd, constants_1.USD_DECIMALS),
|
259
261
|
},
|
260
262
|
amountCanBeUsed: {
|
261
|
-
baseUnit: (0, numberUtils_1.toBaseUnit)(1000000,
|
263
|
+
baseUnit: (0, numberUtils_1.toBaseUnit)(1000000, supplyDecimals),
|
262
264
|
baseAmountUsdValue: BigInt(Math.round(1000000 * supply.price)),
|
263
265
|
},
|
264
266
|
baseAmountMarketPriceUsd: (0, numberUtils_1.toBaseUnit)(supply.price, constants_1.USD_DECIMALS),
|
265
267
|
borrowFeeBps: 0,
|
266
|
-
decimals:
|
268
|
+
decimals: supplyDecimals,
|
267
269
|
flashLoanFeeBps: 0,
|
268
270
|
mint: (0, umi_1.publicKey)(supply.mint),
|
269
271
|
padding1: [],
|
@@ -272,16 +274,16 @@ function createFakePositionState(supply, debt, maxLtvBps, liqThresholdBps) {
|
|
272
274
|
},
|
273
275
|
debt: {
|
274
276
|
amountUsed: {
|
275
|
-
baseUnit: debt.
|
277
|
+
baseUnit: (0, numberUtils_1.toBaseUnit)(debt.amountUsed, debtDecimals),
|
276
278
|
baseAmountUsdValue: (0, numberUtils_1.toBaseUnit)(debtUsd, constants_1.USD_DECIMALS),
|
277
279
|
},
|
278
280
|
amountCanBeUsed: {
|
279
|
-
baseUnit: (0, numberUtils_1.toBaseUnit)(1000000,
|
281
|
+
baseUnit: (0, numberUtils_1.toBaseUnit)(1000000, debtDecimals),
|
280
282
|
baseAmountUsdValue: BigInt(Math.round(1000000 * debt.price)),
|
281
283
|
},
|
282
284
|
baseAmountMarketPriceUsd: (0, numberUtils_1.toBaseUnit)(debt.price, constants_1.USD_DECIMALS),
|
283
285
|
borrowFeeBps: 0,
|
284
|
-
decimals:
|
286
|
+
decimals: debtDecimals,
|
285
287
|
flashLoanFeeBps: 0,
|
286
288
|
mint: (0, umi_1.publicKey)(debt.mint),
|
287
289
|
padding1: [],
|
@@ -289,7 +291,7 @@ function createFakePositionState(supply, debt, maxLtvBps, liqThresholdBps) {
|
|
289
291
|
padding: new Uint8Array([]),
|
290
292
|
},
|
291
293
|
netWorth: {
|
292
|
-
baseUnit: (0, numberUtils_1.toBaseUnit)((supplyUsd - debtUsd) / supply.price,
|
294
|
+
baseUnit: (0, numberUtils_1.toBaseUnit)((supplyUsd - debtUsd) / supply.price, supplyDecimals),
|
293
295
|
baseAmountUsdValue: (0, numberUtils_1.toBaseUnit)(supplyUsd - debtUsd, constants_1.USD_DECIMALS),
|
294
296
|
},
|
295
297
|
maxLtvBps,
|
package/package.json
CHANGED
@@ -46,15 +46,15 @@ export async function getMaxLtvAndLiqThreshold(
|
|
46
46
|
umi: Umi,
|
47
47
|
supply: {
|
48
48
|
mint: PublicKey;
|
49
|
-
bank
|
49
|
+
bank?: Bank | null;
|
50
50
|
},
|
51
51
|
debt: {
|
52
52
|
mint: PublicKey;
|
53
|
-
bank
|
53
|
+
bank?: Bank | null;
|
54
54
|
},
|
55
55
|
supplyPrice?: number
|
56
56
|
): Promise<[number, number]> {
|
57
|
-
if (!supply.bank) {
|
57
|
+
if (!supply.bank || supply.bank === null) {
|
58
58
|
supply.bank = await safeFetchBank(
|
59
59
|
umi,
|
60
60
|
publicKey(
|
@@ -65,7 +65,7 @@ export async function getMaxLtvAndLiqThreshold(
|
|
65
65
|
);
|
66
66
|
}
|
67
67
|
|
68
|
-
if (!debt.bank && !debt.mint.equals(PublicKey.default)) {
|
68
|
+
if ((!debt.bank || debt.bank === null) && !debt.mint.equals(PublicKey.default)) {
|
69
69
|
debt.bank = await safeFetchBank(
|
70
70
|
umi,
|
71
71
|
publicKey(
|
@@ -83,7 +83,7 @@ export async function getMaxLtvAndLiqThreshold(
|
|
83
83
|
supplyPrice = price;
|
84
84
|
}
|
85
85
|
|
86
|
-
if (debt.bank === null) {
|
86
|
+
if (!debt.bank || debt.bank === null) {
|
87
87
|
return [0, 0];
|
88
88
|
}
|
89
89
|
|
@@ -22,7 +22,11 @@ import {
|
|
22
22
|
} from "../numberUtils";
|
23
23
|
import { getReferralState } from "../accountUtils";
|
24
24
|
import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
25
|
-
import {
|
25
|
+
import {
|
26
|
+
ALL_SUPPORTED_TOKENS,
|
27
|
+
TOKEN_DECIMALS,
|
28
|
+
USD_DECIMALS,
|
29
|
+
} from "../../constants";
|
26
30
|
import {
|
27
31
|
getAllMarginfiAccountsByAuthority,
|
28
32
|
getMarginfiAccountPositionState,
|
@@ -329,7 +333,7 @@ export async function getAllPositionsByAuthority(
|
|
329
333
|
export async function positionStateWithLatestPrices(
|
330
334
|
state: PositionState,
|
331
335
|
supplyPrice?: number,
|
332
|
-
debtPrice?: number
|
336
|
+
debtPrice?: number
|
333
337
|
): Promise<PositionState> {
|
334
338
|
if (!supplyPrice || !debtPrice) {
|
335
339
|
[supplyPrice, debtPrice] = await getTokenPrices([
|
@@ -376,10 +380,9 @@ export async function positionStateWithLatestPrices(
|
|
376
380
|
}
|
377
381
|
|
378
382
|
interface AssetProps {
|
379
|
-
amountUsedBaseUnit: bigint;
|
380
|
-
decimals: number;
|
381
|
-
price: number;
|
382
383
|
mint: PublicKey;
|
384
|
+
price: number;
|
385
|
+
amountUsed: number;
|
383
386
|
}
|
384
387
|
|
385
388
|
export function createFakePositionState(
|
@@ -388,10 +391,11 @@ export function createFakePositionState(
|
|
388
391
|
maxLtvBps: number,
|
389
392
|
liqThresholdBps: number
|
390
393
|
): PositionState {
|
391
|
-
const
|
392
|
-
|
393
|
-
|
394
|
-
|
394
|
+
const supplyDecimals = TOKEN_DECIMALS[supply.mint.toString()];
|
395
|
+
const debtDecimals = TOKEN_DECIMALS[debt.mint.toString()];
|
396
|
+
|
397
|
+
const supplyUsd = supply.amountUsed * supply.price;
|
398
|
+
const debtUsd = debt.amountUsed * debt.price;
|
395
399
|
|
396
400
|
return {
|
397
401
|
liqUtilizationRateBps: getLiqUtilzationRateBps(
|
@@ -401,16 +405,16 @@ export function createFakePositionState(
|
|
401
405
|
),
|
402
406
|
supply: {
|
403
407
|
amountUsed: {
|
404
|
-
baseUnit: supply.
|
408
|
+
baseUnit: toBaseUnit(supply.amountUsed, supplyDecimals),
|
405
409
|
baseAmountUsdValue: toBaseUnit(supplyUsd, USD_DECIMALS),
|
406
410
|
},
|
407
411
|
amountCanBeUsed: {
|
408
|
-
baseUnit: toBaseUnit(1000000,
|
412
|
+
baseUnit: toBaseUnit(1000000, supplyDecimals),
|
409
413
|
baseAmountUsdValue: BigInt(Math.round(1000000 * supply.price)),
|
410
414
|
},
|
411
415
|
baseAmountMarketPriceUsd: toBaseUnit(supply.price, USD_DECIMALS),
|
412
416
|
borrowFeeBps: 0,
|
413
|
-
decimals:
|
417
|
+
decimals: supplyDecimals,
|
414
418
|
flashLoanFeeBps: 0,
|
415
419
|
mint: publicKey(supply.mint),
|
416
420
|
padding1: [],
|
@@ -419,16 +423,16 @@ export function createFakePositionState(
|
|
419
423
|
},
|
420
424
|
debt: {
|
421
425
|
amountUsed: {
|
422
|
-
baseUnit: debt.
|
426
|
+
baseUnit: toBaseUnit(debt.amountUsed, debtDecimals),
|
423
427
|
baseAmountUsdValue: toBaseUnit(debtUsd, USD_DECIMALS),
|
424
428
|
},
|
425
429
|
amountCanBeUsed: {
|
426
|
-
baseUnit: toBaseUnit(1000000,
|
430
|
+
baseUnit: toBaseUnit(1000000, debtDecimals),
|
427
431
|
baseAmountUsdValue: BigInt(Math.round(1000000 * debt.price)),
|
428
432
|
},
|
429
433
|
baseAmountMarketPriceUsd: toBaseUnit(debt.price, USD_DECIMALS),
|
430
434
|
borrowFeeBps: 0,
|
431
|
-
decimals:
|
435
|
+
decimals: debtDecimals,
|
432
436
|
flashLoanFeeBps: 0,
|
433
437
|
mint: publicKey(debt.mint),
|
434
438
|
padding1: [],
|
@@ -438,7 +442,7 @@ export function createFakePositionState(
|
|
438
442
|
netWorth: {
|
439
443
|
baseUnit: toBaseUnit(
|
440
444
|
(supplyUsd - debtUsd) / supply.price,
|
441
|
-
|
445
|
+
supplyDecimals
|
442
446
|
),
|
443
447
|
baseAmountUsdValue: toBaseUnit(supplyUsd - debtUsd, USD_DECIMALS),
|
444
448
|
},
|
@@ -120,20 +120,16 @@ async function getFakePosition(
|
|
120
120
|
client.solautoPositionState = await positionStateWithLatestPrices(
|
121
121
|
createFakePositionState(
|
122
122
|
{
|
123
|
-
|
124
|
-
decimals: 9,
|
123
|
+
amountUsed: supplyUsd / supplyPrice,
|
125
124
|
price: PRICES[NATIVE_MINT.toString()].price,
|
126
125
|
mint: NATIVE_MINT,
|
127
126
|
},
|
128
127
|
{
|
129
|
-
|
128
|
+
amountUsed:
|
130
129
|
(supplyUsd *
|
131
130
|
fromBps(liqThresholdBps) *
|
132
131
|
fromBps(fakeLiqUtilizationRateBps)) /
|
133
|
-
|
134
|
-
6
|
135
|
-
),
|
136
|
-
decimals: 6,
|
132
|
+
debtPrice,
|
137
133
|
price: 1,
|
138
134
|
mint: new PublicKey(USDC_MINT),
|
139
135
|
},
|