@haven-fi/solauto-sdk 1.0.473 → 1.0.475
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/marginfi-sdk/types/oracleSetup.d.ts +2 -1
- package/dist/marginfi-sdk/types/oracleSetup.d.ts.map +1 -1
- package/dist/marginfi-sdk/types/oracleSetup.js +1 -0
- package/dist/transactions/transactionUtils.js +5 -5
- package/dist/utils/marginfiUtils.d.ts.map +1 -1
- package/dist/utils/marginfiUtils.js +3 -1
- package/local/logPositions.ts +25 -13
- package/package.json +1 -1
- package/src/marginfi-sdk/types/oracleSetup.ts +1 -0
- package/src/transactions/transactionUtils.ts +6 -6
- package/src/utils/marginfiUtils.ts +4 -1
@@ -11,7 +11,8 @@ export declare enum OracleSetup {
|
|
11
11
|
PythLegacy = 1,
|
12
12
|
SwitchboardLegacy = 2,
|
13
13
|
PythPushOracle = 3,
|
14
|
-
SwitchboardPull = 4
|
14
|
+
SwitchboardPull = 4,
|
15
|
+
StakedWithPythPush = 5
|
15
16
|
}
|
16
17
|
export type OracleSetupArgs = OracleSetup;
|
17
18
|
export declare function getOracleSetupSerializer(): Serializer<OracleSetupArgs, OracleSetup>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"oracleSetup.d.ts","sourceRoot":"","sources":["../../../src/marginfi-sdk/types/oracleSetup.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAc,MAAM,sCAAsC,CAAC;AAE9E,oBAAY,WAAW;IACrB,IAAI,IAAA;IACJ,UAAU,IAAA;IACV,iBAAiB,IAAA;IACjB,cAAc,IAAA;IACd,eAAe,IAAA;
|
1
|
+
{"version":3,"file":"oracleSetup.d.ts","sourceRoot":"","sources":["../../../src/marginfi-sdk/types/oracleSetup.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAc,MAAM,sCAAsC,CAAC;AAE9E,oBAAY,WAAW;IACrB,IAAI,IAAA;IACJ,UAAU,IAAA;IACV,iBAAiB,IAAA;IACjB,cAAc,IAAA;IACd,eAAe,IAAA;IACf,kBAAkB,IAAA;CACnB;AAED,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC;AAE1C,wBAAgB,wBAAwB,IAAI,UAAU,CACpD,eAAe,EACf,WAAW,CACZ,CAIA"}
|
@@ -17,6 +17,7 @@ var OracleSetup;
|
|
17
17
|
OracleSetup[OracleSetup["SwitchboardLegacy"] = 2] = "SwitchboardLegacy";
|
18
18
|
OracleSetup[OracleSetup["PythPushOracle"] = 3] = "PythPushOracle";
|
19
19
|
OracleSetup[OracleSetup["SwitchboardPull"] = 4] = "SwitchboardPull";
|
20
|
+
OracleSetup[OracleSetup["StakedWithPythPush"] = 5] = "StakedWithPythPush";
|
20
21
|
})(OracleSetup || (exports.OracleSetup = OracleSetup = {}));
|
21
22
|
function getOracleSetupSerializer() {
|
22
23
|
return (0, serializers_1.scalarEnum)(OracleSetup, {
|
@@ -487,7 +487,7 @@ function getErrorInfo(umi, txs, error, simulationSuccessful) {
|
|
487
487
|
(0, generalUtils_1.consoleLog)("Error instruction program:", errIx?.programId.toString());
|
488
488
|
const solautoError = (0, generated_1.getSolautoErrorFromCode)(errCode ?? -1, (0, generated_1.createSolautoProgram)());
|
489
489
|
const marginfiError = (0, marginfi_sdk_1.getMarginfiErrorFromCode)(errCode ?? -1, (0, marginfi_sdk_1.createMarginfiProgram)());
|
490
|
-
if (errCode &&
|
490
|
+
if (errCode !== undefined &&
|
491
491
|
errIx?.programId.toString() ===
|
492
492
|
umi.programs.get("solauto").publicKey.toString()) {
|
493
493
|
programError = solautoError ?? marginfiError;
|
@@ -497,11 +497,11 @@ function getErrorInfo(umi, txs, error, simulationSuccessful) {
|
|
497
497
|
canBeIgnored = true;
|
498
498
|
}
|
499
499
|
}
|
500
|
-
else if (errCode && errIx?.programId === marginfi_sdk_1.MARGINFI_PROGRAM_ID) {
|
500
|
+
else if (errCode !== undefined && errIx?.programId === marginfi_sdk_1.MARGINFI_PROGRAM_ID) {
|
501
501
|
programName = "Marginfi";
|
502
502
|
programError = marginfiError;
|
503
503
|
}
|
504
|
-
else if (errCode && errIx?.programId === jupiter_sdk_1.JUPITER_PROGRAM_ID) {
|
504
|
+
else if (errCode !== undefined && errIx?.programId === jupiter_sdk_1.JUPITER_PROGRAM_ID) {
|
505
505
|
programName = "Jupiter";
|
506
506
|
programError = (0, jupiter_sdk_1.getJupiterErrorFromCode)(errCode, (0, jupiter_sdk_1.createJupiterProgram)());
|
507
507
|
}
|
@@ -518,8 +518,8 @@ function getErrorInfo(umi, txs, error, simulationSuccessful) {
|
|
518
518
|
(0, generalUtils_1.consoleLog)(e);
|
519
519
|
}
|
520
520
|
const errData = {
|
521
|
-
errorName
|
522
|
-
errorInfo
|
521
|
+
errorName,
|
522
|
+
errorInfo,
|
523
523
|
canBeIgnored,
|
524
524
|
};
|
525
525
|
(0, generalUtils_1.consoleLog)(errData);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marginfiUtils.d.ts","sourceRoot":"","sources":["../../src/utils/marginfiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EACL,IAAI,EAGJ,eAAe,
|
1
|
+
{"version":3,"file":"marginfiUtils.d.ts","sourceRoot":"","sources":["../../src/utils/marginfiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EACL,IAAI,EAGJ,eAAe,EAIhB,MAAM,iBAAiB,CAAC;AAazB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;AAEjE,OAAO,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AAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;CAAE,CAAC;AAEhE,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,GAAG,EACR,eAAe,EAAE;IAAE,EAAE,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,eAAe,CAAA;CAAE,EAC1D,aAAa,CAAC,EAAE,SAAS,EACzB,MAAM,CAAC,EAAE,aAAa,EACtB,IAAI,CAAC,EAAE,aAAa,EACpB,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,OAAO,CACN;IAAE,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,aAAa,CAAA;CAAE,GACxE,SAAS,CACZ,CAgMA;AA+DD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,oBAU7C;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBnE;AAED,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,WASpE"}
|
@@ -237,7 +237,9 @@ async function getMarginfiAccountPositionState(umi, protocolAccount, marginfiGro
|
|
237
237
|
if (supplyMint === undefined ||
|
238
238
|
debtMint === undefined ||
|
239
239
|
(!supplyMint.isStableCoin && !debtMint.isStableCoin) ||
|
240
|
-
(supplyMint.isStableCoin && debtMint.isStableCoin)
|
240
|
+
(supplyMint.isStableCoin && debtMint.isStableCoin) ||
|
241
|
+
supplyBank.config.oracleSetup === marginfi_sdk_1.OracleSetup.StakedWithPythPush ||
|
242
|
+
debtBank.config.oracleSetup === marginfi_sdk_1.OracleSetup.StakedWithPythPush) {
|
241
243
|
return undefined;
|
242
244
|
}
|
243
245
|
if (!debtUsage) {
|
package/local/logPositions.ts
CHANGED
@@ -15,12 +15,14 @@ import {
|
|
15
15
|
SOLAUTO_PROD_PROGRAM,
|
16
16
|
TOKEN_INFO,
|
17
17
|
USD_DECIMALS,
|
18
|
+
WBTC,
|
19
|
+
WETH,
|
18
20
|
} from "../src";
|
19
21
|
import { PublicKey } from "@solana/web3.js";
|
20
|
-
import { NATIVE_MINT } from "@solana/spl-token";
|
21
22
|
import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
22
23
|
import path from "path";
|
23
24
|
import { config } from "dotenv";
|
25
|
+
import { NATIVE_MINT } from "@solana/spl-token";
|
24
26
|
|
25
27
|
config({ path: path.join(__dirname, ".env") });
|
26
28
|
|
@@ -36,7 +38,13 @@ export function tokenInfo(mint?: PublicKey) {
|
|
36
38
|
return TOKEN_INFO[mint ? mint.toString() : PublicKey.default.toString()];
|
37
39
|
}
|
38
40
|
|
39
|
-
type StrategyType = "Long" | "Short";
|
41
|
+
type StrategyType = "Long" | "Ratio" | "Short";
|
42
|
+
|
43
|
+
const MAJORS_PRIO = {
|
44
|
+
[WBTC.toString()]: 0,
|
45
|
+
[WETH.toString()]: 1,
|
46
|
+
[NATIVE_MINT.toString()]: 2,
|
47
|
+
};
|
40
48
|
|
41
49
|
function solautoStrategyName(supplyMint?: PublicKey, debtMint?: PublicKey) {
|
42
50
|
const supplyInfo = tokenInfo(supplyMint);
|
@@ -47,11 +55,18 @@ function solautoStrategyName(supplyMint?: PublicKey, debtMint?: PublicKey) {
|
|
47
55
|
);
|
48
56
|
|
49
57
|
if (strat === "Long") {
|
50
|
-
return
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
58
|
+
return `${supplyInfo.ticker} Long`;
|
59
|
+
} else if (strat === "Ratio") {
|
60
|
+
if (
|
61
|
+
(supplyInfo.isLST && debtMint?.equals(NATIVE_MINT)) ||
|
62
|
+
(supplyMint &&
|
63
|
+
debtMint &&
|
64
|
+
MAJORS_PRIO[supplyMint!.toString()] > MAJORS_PRIO[debtMint!.toString()])
|
65
|
+
) {
|
66
|
+
return `${supplyInfo.ticker}/${debtInfo.ticker} Long`;
|
67
|
+
} else {
|
68
|
+
return `${debtInfo.ticker}/${supplyInfo.ticker} Short`;
|
69
|
+
}
|
55
70
|
} else {
|
56
71
|
return `${debtInfo.ticker} Short`;
|
57
72
|
}
|
@@ -64,15 +79,12 @@ function strategyType(
|
|
64
79
|
const supplyInfo = tokenInfo(supplyMint);
|
65
80
|
const debtInfo = tokenInfo(debtMint);
|
66
81
|
|
67
|
-
if (supplyInfo.
|
68
|
-
|
69
|
-
throw new Error("Not yet supported");
|
82
|
+
if (!supplyInfo.isStableCoin && !debtInfo.isStableCoin) {
|
83
|
+
return "Ratio";
|
70
84
|
} else if (debtInfo.isStableCoin) {
|
71
85
|
return "Long";
|
72
|
-
} else if (supplyInfo.isStableCoin) {
|
73
|
-
return "Short";
|
74
86
|
} else {
|
75
|
-
return "
|
87
|
+
return "Short";
|
76
88
|
}
|
77
89
|
}
|
78
90
|
|
package/package.json
CHANGED
@@ -903,7 +903,7 @@ export function getErrorInfo(
|
|
903
903
|
);
|
904
904
|
|
905
905
|
if (
|
906
|
-
errCode &&
|
906
|
+
errCode !== undefined &&
|
907
907
|
errIx?.programId.toString() ===
|
908
908
|
umi.programs.get("solauto").publicKey.toString()
|
909
909
|
) {
|
@@ -915,10 +915,10 @@ export function getErrorInfo(
|
|
915
915
|
) {
|
916
916
|
canBeIgnored = true;
|
917
917
|
}
|
918
|
-
} else if (errCode && errIx?.programId === MARGINFI_PROGRAM_ID) {
|
918
|
+
} else if (errCode !== undefined && errIx?.programId === MARGINFI_PROGRAM_ID) {
|
919
919
|
programName = "Marginfi";
|
920
920
|
programError = marginfiError;
|
921
|
-
} else if (errCode && errIx?.programId === JUPITER_PROGRAM_ID) {
|
921
|
+
} else if (errCode !== undefined && errIx?.programId === JUPITER_PROGRAM_ID) {
|
922
922
|
programName = "Jupiter";
|
923
923
|
programError = getJupiterErrorFromCode(errCode, createJupiterProgram());
|
924
924
|
}
|
@@ -935,11 +935,11 @@ export function getErrorInfo(
|
|
935
935
|
}
|
936
936
|
|
937
937
|
const errData = {
|
938
|
-
errorName
|
939
|
-
errorInfo
|
938
|
+
errorName,
|
939
|
+
errorInfo,
|
940
940
|
canBeIgnored,
|
941
941
|
};
|
942
|
-
|
943
942
|
consoleLog(errData);
|
943
|
+
|
944
944
|
return errData;
|
945
945
|
}
|
@@ -6,6 +6,7 @@ import {
|
|
6
6
|
getMarginfiAccountSize,
|
7
7
|
MARGINFI_PROGRAM_ID,
|
8
8
|
MarginfiAccount,
|
9
|
+
OracleSetup,
|
9
10
|
safeFetchBank,
|
10
11
|
safeFetchMarginfiAccount,
|
11
12
|
} from "../marginfi-sdk";
|
@@ -435,7 +436,9 @@ export async function getMarginfiAccountPositionState(
|
|
435
436
|
supplyMint === undefined ||
|
436
437
|
debtMint === undefined ||
|
437
438
|
(!supplyMint.isStableCoin && !debtMint.isStableCoin) ||
|
438
|
-
(supplyMint.isStableCoin && debtMint.isStableCoin)
|
439
|
+
(supplyMint.isStableCoin && debtMint.isStableCoin) ||
|
440
|
+
supplyBank.config.oracleSetup === OracleSetup.StakedWithPythPush ||
|
441
|
+
debtBank.config.oracleSetup === OracleSetup.StakedWithPythPush
|
439
442
|
) {
|
440
443
|
return undefined;
|
441
444
|
}
|