@haven-fi/solauto-sdk 1.0.197 → 1.0.198
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/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +8 -9
- package/dist/constants/marginfiAccounts.d.ts +3 -1
- package/dist/constants/marginfiAccounts.d.ts.map +1 -1
- package/dist/constants/marginfiAccounts.js +26 -30
- package/dist/types/accounts.d.ts +0 -1
- package/dist/types/accounts.d.ts.map +1 -1
- package/dist/utils/marginfiUtils.d.ts +2 -2
- package/dist/utils/marginfiUtils.d.ts.map +1 -1
- package/dist/utils/marginfiUtils.js +16 -11
- package/local/updateMarginfiLUT.ts +14 -12
- package/package.json +2 -1
- package/src/clients/solautoMarginfiClient.ts +18 -9
- package/src/constants/marginfiAccounts.ts +28 -31
- package/src/types/accounts.ts +0 -1
- package/src/utils/marginfiUtils.ts +19 -10
- package/tests/unit/accounts.ts +32 -0
- package/tests/unit/lookupTables.ts +17 -15
- package/tests/unit/rebalanceCalculations.ts +2 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAM1D,OAAO,EACL,kBAAkB,EAElB,aAAa,EAEb,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EAKjC,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,eAAe,EAUhB,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAM1D,OAAO,EACL,kBAAkB,EAElB,aAAa,EAEb,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EAKjC,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,eAAe,EAUhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AASnE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,eAAe,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,qBAAa,qBAAsB,SAAQ,aAAa;IACtD,OAAO,CAAC,WAAW,CAAkB;IAE9B,eAAe,EAAG,SAAS,CAAC;IAE5B,sBAAsB,EAAE,MAAM,CAAa;IAC3C,eAAe,EAAG,SAAS,GAAG,MAAM,CAAC;IACrC,iBAAiB,EAAG,SAAS,CAAC;IAC9B,aAAa,EAAG,SAAS,CAAC;IAE1B,sBAAsB,EAAG,qBAAqB,CAAC;IAC/C,oBAAoB,EAAG,qBAAqB,CAAC;IAE7C,iBAAiB,EAAG,SAAS,CAAC;IAC9B,eAAe,EAAG,SAAS,CAAC;IAG5B,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,6BAA6B,EAAG,SAAS,CAAC;IAC1C,2BAA2B,CAAC,EAAE,eAAe,CAAC;IAE/C,UAAU,CAAC,IAAI,EAAE,yBAAyB;IAsE1C,8BAA8B;IA0CpC,eAAe,IAAI,SAAS;IAI5B,mBAAmB,IAAI,MAAM,EAAE;IAI/B,gBAAgB,IAAI,SAAS,EAAE;IAUzB,wBAAwB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IA0BvE,yBAAyB,IAAI,kBAAkB;IAS/C,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA8C9B,OAAO,IAAI,kBAAkB;IAc7B,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAUhE,OAAO,CAAC,6BAA6B;IAmErC,OAAO,CAAC,oCAAoC;IA0D5C,SAAS,CACP,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,GACnC,kBAAkB;IAqErB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAoFlE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CA6ClE"}
|
@@ -39,12 +39,11 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
39
39
|
const marginfiAccountData = await (0, marginfi_sdk_1.safeFetchMarginfiAccount)(this.umi, (0, umi_1.publicKey)(this.marginfiAccountPk), { commitment: "confirmed" });
|
40
40
|
this.marginfiGroup = new web3_js_1.PublicKey(marginfiAccountData
|
41
41
|
? marginfiAccountData.group.toString()
|
42
|
-
: args.marginfiGroup ??
|
43
|
-
marginfiAccounts_1.MARGINFI_ACCOUNTS[this.supplyMint.toString()].marginfiGroup ??
|
44
|
-
marginfiAccounts_1.DEFAULT_MARGINFI_GROUP);
|
42
|
+
: (args.marginfiGroup ?? marginfiAccounts_1.DEFAULT_MARGINFI_GROUP));
|
45
43
|
this.marginfiSupplyAccounts =
|
46
|
-
marginfiAccounts_1.MARGINFI_ACCOUNTS[this.supplyMint.toString()];
|
47
|
-
this.marginfiDebtAccounts =
|
44
|
+
marginfiAccounts_1.MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][this.supplyMint.toString()];
|
45
|
+
this.marginfiDebtAccounts =
|
46
|
+
marginfiAccounts_1.MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][this.debtMint.toString()];
|
48
47
|
// TODO: Don't dynamically pull from bank until Marginfi sorts out their price oracle issues.
|
49
48
|
// const [supplyBank, debtBank] = await safeFetchAllBank(this.umi, [
|
50
49
|
// publicKey(this.marginfiSupplyAccounts.bank),
|
@@ -108,7 +107,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
108
107
|
return [0, 0];
|
109
108
|
}
|
110
109
|
else {
|
111
|
-
const [maxLtv, liqThreshold] = await (0, marginfiUtils_1.getMaxLtvAndLiqThreshold)(this.umi, {
|
110
|
+
const [maxLtv, liqThreshold] = await (0, marginfiUtils_1.getMaxLtvAndLiqThreshold)(this.umi, this.marginfiGroup, {
|
112
111
|
mint: this.supplyMint,
|
113
112
|
}, {
|
114
113
|
mint: this.debtMint,
|
@@ -291,8 +290,8 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
291
290
|
});
|
292
291
|
}
|
293
292
|
rebalance(rebalanceStep, jupQuote, rebalanceType, flashLoan, targetLiqUtilizationRateBps) {
|
294
|
-
const inputIsSupply =
|
295
|
-
const outputIsSupply =
|
293
|
+
const inputIsSupply = new web3_js_1.PublicKey(jupQuote.inputMint).equals(this.supplyMint);
|
294
|
+
const outputIsSupply = new web3_js_1.PublicKey(jupQuote.outputMint).equals(this.supplyMint);
|
296
295
|
const needSupplyAccounts = (inputIsSupply && rebalanceStep === "A") ||
|
297
296
|
(outputIsSupply && rebalanceStep === "B") ||
|
298
297
|
(inputIsSupply && flashLoan !== undefined && rebalanceStep == "B");
|
@@ -434,7 +433,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
434
433
|
if (state) {
|
435
434
|
return state;
|
436
435
|
}
|
437
|
-
const freshState = await (0, marginfiUtils_1.getMarginfiAccountPositionState)(this.umi, this.marginfiAccountPk, !this.selfManaged && this.solautoPositionData === null
|
436
|
+
const freshState = await (0, marginfiUtils_1.getMarginfiAccountPositionState)(this.umi, this.marginfiAccountPk, this.marginfiGroup, !this.selfManaged && this.solautoPositionData === null
|
438
437
|
? this.supplyMint
|
439
438
|
: undefined, !this.selfManaged && this.solautoPositionData === null
|
440
439
|
? this.debtMint
|
@@ -2,7 +2,9 @@ import { MarginfiAssetAccounts } from "../types/accounts";
|
|
2
2
|
export declare const DEFAULT_MARGINFI_GROUP = "4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8";
|
3
3
|
export declare const DEFAULT_PUBKEY: string;
|
4
4
|
export declare const MARGINFI_ACCOUNTS: {
|
5
|
-
[
|
5
|
+
[group: string]: {
|
6
|
+
[token: string]: MarginfiAssetAccounts;
|
7
|
+
};
|
6
8
|
};
|
7
9
|
export declare const MARGINFI_ACCOUNTS_LOOKUP_TABLE = "GAjmWmBPcH5Gxbiykasydj6RsCEaCLyHEvK6kHdFigc6";
|
8
10
|
//# sourceMappingURL=marginfiAccounts.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marginfiAccounts.d.ts","sourceRoot":"","sources":["../../src/constants/marginfiAccounts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,eAAO,MAAM,sBAAsB,iDAAiD,CAAC;AAErF,eAAO,MAAM,cAAc,QAA+B,CAAC;
|
1
|
+
{"version":3,"file":"marginfiAccounts.d.ts","sourceRoot":"","sources":["../../src/constants/marginfiAccounts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,eAAO,MAAM,sBAAsB,iDAAiD,CAAC;AAErF,eAAO,MAAM,cAAc,QAA+B,CAAC;AAE3D,eAAO,MAAM,iBAAiB,EAAE;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,qBAAqB,CAAA;KAAE,CAAA;CA2B5F,CAAC;AAEF,eAAO,MAAM,8BAA8B,iDAAiD,CAAC"}
|
@@ -7,35 +7,31 @@ const web3_js_1 = require("@solana/web3.js");
|
|
7
7
|
exports.DEFAULT_MARGINFI_GROUP = "4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8";
|
8
8
|
exports.DEFAULT_PUBKEY = web3_js_1.PublicKey.default.toString();
|
9
9
|
exports.MARGINFI_ACCOUNTS = {
|
10
|
-
[exports.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
liquidityVault: "4w49W4fNDn778wsBa6TNq9hvebZKU17ymsptrEZ8zrsm",
|
37
|
-
vaultAuthority: "2MBwwAhL3c73Jy7HkWd9ofzh1bU39JBabrZCFQR2tUof",
|
38
|
-
priceOracle: "7dbob1psH1iZBS7qPsm3Kwbf5DzSXK8Jyg31CTgTnxH5",
|
39
|
-
},
|
10
|
+
[exports.DEFAULT_MARGINFI_GROUP.toString()]: {
|
11
|
+
[spl_token_1.NATIVE_MINT.toString()]: {
|
12
|
+
bank: "CCKtUs6Cgwo4aaQUmBPmyoApH2gUDErxNZCAntD6LYGh",
|
13
|
+
liquidityVault: "2eicbpitfJXDwqCuFAmPgDP7t2oUotnAzbGzRKLMgSLe",
|
14
|
+
vaultAuthority: "DD3AeAssFvjqTvRTrRAtpfjkBF8FpVKnFuwnMLN9haXD",
|
15
|
+
priceOracle: "7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE"
|
16
|
+
},
|
17
|
+
[tokenConstants_1.USDC_MINT]: {
|
18
|
+
bank: "2s37akK2eyBbp8DZgCm7RtsaEz8eJP3Nxd4urLHQv7yB",
|
19
|
+
liquidityVault: "7jaiZR5Sk8hdYN9MxTpczTcwbWpb5WEoxSANuUwveuat",
|
20
|
+
vaultAuthority: "3uxNepDbmkDNq6JhRja5Z8QwbTrfmkKP8AKZV5chYDGG",
|
21
|
+
priceOracle: "Dpw1EAVrSB1ibxiDQyTAW6Zip3J4Btk2x4SgApQCeFbX"
|
22
|
+
},
|
23
|
+
[tokenConstants_1.B_SOL]: {
|
24
|
+
bank: "6hS9i46WyTq1KXcoa2Chas2Txh9TJAVr6n1t3tnrE23K",
|
25
|
+
liquidityVault: "2WMipeKDB2CENxbzdmnVrRbsxCA2LY6kCtBe6AAqDP9p",
|
26
|
+
vaultAuthority: "8RcZHucpVHkHWRRdMhJZsxBK9mqKSYnMKGqtF84U8YEo",
|
27
|
+
priceOracle: "5cN76Xm2Dtx9MnrQqBDeZZRsWruTTcw37UruznAdSvvE",
|
28
|
+
},
|
29
|
+
[tokenConstants_1.JUP]: {
|
30
|
+
bank: "Guu5uBc8k1WK1U2ihGosNaCy57LSgCkpWAabtzQqrQf8",
|
31
|
+
liquidityVault: "4w49W4fNDn778wsBa6TNq9hvebZKU17ymsptrEZ8zrsm",
|
32
|
+
vaultAuthority: "2MBwwAhL3c73Jy7HkWd9ofzh1bU39JBabrZCFQR2tUof",
|
33
|
+
priceOracle: "7dbob1psH1iZBS7qPsm3Kwbf5DzSXK8Jyg31CTgTnxH5",
|
34
|
+
}
|
35
|
+
}
|
40
36
|
};
|
41
37
|
exports.MARGINFI_ACCOUNTS_LOOKUP_TABLE = "GAjmWmBPcH5Gxbiykasydj6RsCEaCLyHEvK6kHdFigc6";
|
package/dist/types/accounts.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/types/accounts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/types/accounts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
@@ -5,7 +5,7 @@ import { MarginfiAssetAccounts } from "../types/accounts";
|
|
5
5
|
import { PositionState } from "../generated";
|
6
6
|
import { LivePositionUpdates } from "./solauto/generalUtils";
|
7
7
|
export declare function findMarginfiAccounts(bank: PublicKey): MarginfiAssetAccounts;
|
8
|
-
export declare function getMaxLtvAndLiqThreshold(umi: Umi, supply: {
|
8
|
+
export declare function getMaxLtvAndLiqThreshold(umi: Umi, marginfiGroup: PublicKey, supply: {
|
9
9
|
mint: PublicKey;
|
10
10
|
bank?: Bank | null;
|
11
11
|
}, debt: {
|
@@ -17,6 +17,6 @@ export declare function getAllMarginfiAccountsByAuthority(umi: Umi, authority: P
|
|
17
17
|
supplyMint?: PublicKey;
|
18
18
|
debtMint?: PublicKey;
|
19
19
|
}[]>;
|
20
|
-
export declare function getMarginfiAccountPositionState(umi: Umi, marginfiAccountPk: PublicKey, supplyMint?: PublicKey, debtMint?: PublicKey, livePositionUpdates?: LivePositionUpdates): Promise<PositionState | undefined>;
|
20
|
+
export declare function getMarginfiAccountPositionState(umi: Umi, marginfiAccountPk: PublicKey, marginfiGroup?: PublicKey, supplyMint?: PublicKey, debtMint?: PublicKey, livePositionUpdates?: LivePositionUpdates): Promise<PositionState | undefined>;
|
21
21
|
export declare function getUpToDateShareValues(umi: Umi, bank: Bank): Promise<[number, number]>;
|
22
22
|
//# sourceMappingURL=marginfiUtils.d.ts.map
|
@@ -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;AAczB,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,IAAI,EAAE,SAAS,GAAG,qBAAqB,
|
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;AAczB,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,IAAI,EAAE,SAAS,GAAG,qBAAqB,CAY3E;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,SAAS,EACxB,MAAM,EAAE;IACN,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,EACD,IAAI,EAAE;IACJ,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,EACD,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA+D3B;AAED,wBAAsB,iCAAiC,CACrD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,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,CAwDA;AAgED,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,GAAG,EACR,iBAAiB,EAAE,SAAS,EAC5B,aAAa,CAAC,EAAE,SAAS,EACzB,UAAU,CAAC,EAAE,SAAS,EACtB,QAAQ,CAAC,EAAE,SAAS,EACpB,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAuKpC;AA+DD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAyB3B"}
|
@@ -15,24 +15,26 @@ const marginfiAccounts_1 = require("../constants/marginfiAccounts");
|
|
15
15
|
const generalAccounts_1 = require("../constants/generalAccounts");
|
16
16
|
const constants_1 = require("../constants");
|
17
17
|
function findMarginfiAccounts(bank) {
|
18
|
-
for (const
|
19
|
-
const
|
20
|
-
|
21
|
-
|
18
|
+
for (const group in marginfiAccounts_1.MARGINFI_ACCOUNTS) {
|
19
|
+
for (const key in marginfiAccounts_1.MARGINFI_ACCOUNTS[group]) {
|
20
|
+
const account = marginfiAccounts_1.MARGINFI_ACCOUNTS[group][key];
|
21
|
+
if (account.bank.toString().toLowerCase() === bank.toString().toLowerCase()) {
|
22
|
+
return account;
|
23
|
+
}
|
22
24
|
}
|
23
25
|
}
|
24
26
|
throw new Error(`Marginfi accounts not found by the bank: ${bank}`);
|
25
27
|
}
|
26
|
-
async function getMaxLtvAndLiqThreshold(umi, supply, debt, supplyPrice) {
|
28
|
+
async function getMaxLtvAndLiqThreshold(umi, marginfiGroup, supply, debt, supplyPrice) {
|
27
29
|
if (!supply.bank && supply.mint.equals(web3_js_1.PublicKey.default)) {
|
28
30
|
return [0, 0];
|
29
31
|
}
|
30
32
|
if (!supply.bank || supply.bank === null) {
|
31
|
-
supply.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[supply.mint.toString()].bank), { commitment: "confirmed" });
|
33
|
+
supply.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[marginfiGroup.toString()][supply.mint.toString()].bank), { commitment: "confirmed" });
|
32
34
|
}
|
33
35
|
if ((!debt.bank || debt.bank === null) &&
|
34
36
|
!debt.mint.equals(web3_js_1.PublicKey.default)) {
|
35
|
-
debt.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[debt.mint.toString()].bank), { commitment: "confirmed" });
|
37
|
+
debt.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[marginfiGroup.toString()][debt.mint.toString()].bank), { commitment: "confirmed" });
|
36
38
|
}
|
37
39
|
if (!supplyPrice) {
|
38
40
|
const [price] = await (0, generalUtils_1.fetchTokenPrices)([
|
@@ -136,13 +138,16 @@ async function getTokenUsage(umi, bank, isAsset, shares, amountUsedAdjustment) {
|
|
136
138
|
padding: new Uint8Array([]),
|
137
139
|
};
|
138
140
|
}
|
139
|
-
async function getMarginfiAccountPositionState(umi, marginfiAccountPk, supplyMint, debtMint, livePositionUpdates) {
|
141
|
+
async function getMarginfiAccountPositionState(umi, marginfiAccountPk, marginfiGroup, supplyMint, debtMint, livePositionUpdates) {
|
140
142
|
let marginfiAccount = await (0, marginfi_sdk_1.safeFetchMarginfiAccount)(umi, (0, umi_1.publicKey)(marginfiAccountPk), { commitment: "confirmed" });
|
143
|
+
if (!marginfiGroup && marginfiAccount) {
|
144
|
+
marginfiGroup = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(marginfiAccount.group);
|
145
|
+
}
|
141
146
|
let supplyBank = supplyMint && supplyMint !== web3_js_1.PublicKey.default
|
142
|
-
? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[supplyMint.toString()].bank), { commitment: "confirmed" })
|
147
|
+
? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[marginfiGroup?.toString() ?? ""][supplyMint.toString()].bank), { commitment: "confirmed" })
|
143
148
|
: null;
|
144
149
|
let debtBank = debtMint && debtMint !== web3_js_1.PublicKey.default
|
145
|
-
? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[debtMint.toString()].bank), { commitment: "confirmed" })
|
150
|
+
? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[marginfiGroup?.toString() ?? ""][debtMint.toString()].bank), { commitment: "confirmed" })
|
146
151
|
: null;
|
147
152
|
let supplyUsage = undefined;
|
148
153
|
let debtUsage = undefined;
|
@@ -195,7 +200,7 @@ async function getMarginfiAccountPositionState(umi, marginfiAccountPk, supplyMin
|
|
195
200
|
debtUsage = await getTokenUsage(umi, debtBank, false, 0, livePositionUpdates?.debtAdjustment);
|
196
201
|
}
|
197
202
|
const supplyPrice = (0, generalUtils_1.safeGetPrice)(supplyMint);
|
198
|
-
let [maxLtv, liqThreshold] = await getMaxLtvAndLiqThreshold(umi, {
|
203
|
+
let [maxLtv, liqThreshold] = await getMaxLtvAndLiqThreshold(umi, marginfiGroup ?? new web3_js_1.PublicKey(marginfiAccounts_1.DEFAULT_MARGINFI_GROUP), {
|
199
204
|
mint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(supplyBank.mint),
|
200
205
|
bank: supplyBank,
|
201
206
|
}, {
|
@@ -10,18 +10,20 @@ import { updateLookupTable } from "./shared";
|
|
10
10
|
const LOOKUP_TABLE_ADDRESS = new PublicKey(MARGINFI_ACCOUNTS_LOOKUP_TABLE);
|
11
11
|
|
12
12
|
async function addBanks() {
|
13
|
-
for (const
|
14
|
-
const
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
13
|
+
for (const group in MARGINFI_ACCOUNTS) {
|
14
|
+
for (const key in MARGINFI_ACCOUNTS[group]) {
|
15
|
+
const accounts = MARGINFI_ACCOUNTS[group][key];
|
16
|
+
await updateLookupTable(
|
17
|
+
[
|
18
|
+
key,
|
19
|
+
accounts.bank,
|
20
|
+
accounts.liquidityVault,
|
21
|
+
accounts.vaultAuthority,
|
22
|
+
accounts.priceOracle,
|
23
|
+
],
|
24
|
+
LOOKUP_TABLE_ADDRESS
|
25
|
+
);
|
26
|
+
}
|
25
27
|
}
|
26
28
|
}
|
27
29
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@haven-fi/solauto-sdk",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.198",
|
4
4
|
"main": "dist/index.js",
|
5
5
|
"types": "dist/index.d.ts",
|
6
6
|
"description": "Typescript SDK for the Solauto program on the Solana blockchain",
|
@@ -22,6 +22,7 @@
|
|
22
22
|
"@metaplex-foundation/umi-web3js-adapters": "^0.9.1",
|
23
23
|
"@solana/spl-token": "^0.4.0",
|
24
24
|
"@solana/web3.js": "^1.92.1",
|
25
|
+
"@sqds/multisig": "^2.1.3",
|
25
26
|
"@types/node": "^20.14.8",
|
26
27
|
"bs58": "^5.0.0",
|
27
28
|
"cross-fetch": "^4.0.0",
|
@@ -47,7 +47,6 @@ import {
|
|
47
47
|
safeFetchAllMarginfiAccount,
|
48
48
|
safeFetchMarginfiAccount,
|
49
49
|
} from "../marginfi-sdk";
|
50
|
-
import { JupSwapDetails } from "../utils/jupiterUtils";
|
51
50
|
import { FlashLoanDetails } from "../utils/solauto/rebalanceUtils";
|
52
51
|
import {
|
53
52
|
findMarginfiAccounts,
|
@@ -115,14 +114,17 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
115
114
|
this.marginfiGroup = new PublicKey(
|
116
115
|
marginfiAccountData
|
117
116
|
? marginfiAccountData.group.toString()
|
118
|
-
: args.marginfiGroup ??
|
119
|
-
MARGINFI_ACCOUNTS[this.supplyMint.toString()].marginfiGroup ??
|
120
|
-
DEFAULT_MARGINFI_GROUP
|
117
|
+
: (args.marginfiGroup ?? DEFAULT_MARGINFI_GROUP)
|
121
118
|
);
|
122
119
|
|
123
120
|
this.marginfiSupplyAccounts =
|
124
|
-
MARGINFI_ACCOUNTS[this.
|
125
|
-
|
121
|
+
MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][
|
122
|
+
this.supplyMint.toString()
|
123
|
+
]!;
|
124
|
+
this.marginfiDebtAccounts =
|
125
|
+
MARGINFI_ACCOUNTS[this.marginfiGroup.toString()][
|
126
|
+
this.debtMint.toString()
|
127
|
+
]!;
|
126
128
|
|
127
129
|
// TODO: Don't dynamically pull from bank until Marginfi sorts out their price oracle issues.
|
128
130
|
// const [supplyBank, debtBank] = await safeFetchAllBank(this.umi, [
|
@@ -225,6 +227,7 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
225
227
|
} else {
|
226
228
|
const [maxLtv, liqThreshold] = await getMaxLtvAndLiqThreshold(
|
227
229
|
this.umi,
|
230
|
+
this.marginfiGroup,
|
228
231
|
{
|
229
232
|
mint: this.supplyMint,
|
230
233
|
},
|
@@ -458,8 +461,12 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
458
461
|
flashLoan?: FlashLoanDetails,
|
459
462
|
targetLiqUtilizationRateBps?: number
|
460
463
|
): TransactionBuilder {
|
461
|
-
const inputIsSupply =
|
462
|
-
|
464
|
+
const inputIsSupply = new PublicKey(jupQuote.inputMint).equals(
|
465
|
+
this.supplyMint
|
466
|
+
);
|
467
|
+
const outputIsSupply = new PublicKey(jupQuote.outputMint).equals(
|
468
|
+
this.supplyMint
|
469
|
+
);
|
463
470
|
const needSupplyAccounts =
|
464
471
|
(inputIsSupply && rebalanceStep === "A") ||
|
465
472
|
(outputIsSupply && rebalanceStep === "B") ||
|
@@ -517,7 +524,8 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
517
524
|
: undefined,
|
518
525
|
rebalanceType,
|
519
526
|
targetLiqUtilizationRateBps: targetLiqUtilizationRateBps ?? null,
|
520
|
-
targetInAmountBaseUnit:
|
527
|
+
targetInAmountBaseUnit:
|
528
|
+
rebalanceStep === "A" ? parseInt(jupQuote.inAmount) : null,
|
521
529
|
});
|
522
530
|
}
|
523
531
|
|
@@ -653,6 +661,7 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
653
661
|
const freshState = await getMarginfiAccountPositionState(
|
654
662
|
this.umi,
|
655
663
|
this.marginfiAccountPk,
|
664
|
+
this.marginfiGroup,
|
656
665
|
!this.selfManaged && this.solautoPositionData === null
|
657
666
|
? this.supplyMint
|
658
667
|
: undefined,
|
@@ -6,37 +6,34 @@ import { PublicKey } from "@solana/web3.js";
|
|
6
6
|
export const DEFAULT_MARGINFI_GROUP = "4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8";
|
7
7
|
|
8
8
|
export const DEFAULT_PUBKEY = PublicKey.default.toString();
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
vaultAuthority: "2MBwwAhL3c73Jy7HkWd9ofzh1bU39JBabrZCFQR2tUof",
|
38
|
-
priceOracle: "7dbob1psH1iZBS7qPsm3Kwbf5DzSXK8Jyg31CTgTnxH5",
|
39
|
-
},
|
9
|
+
|
10
|
+
export const MARGINFI_ACCOUNTS: { [group: string]: { [token: string]: MarginfiAssetAccounts } } = {
|
11
|
+
[DEFAULT_MARGINFI_GROUP.toString()]: {
|
12
|
+
[NATIVE_MINT.toString()]: {
|
13
|
+
bank: "CCKtUs6Cgwo4aaQUmBPmyoApH2gUDErxNZCAntD6LYGh",
|
14
|
+
liquidityVault: "2eicbpitfJXDwqCuFAmPgDP7t2oUotnAzbGzRKLMgSLe",
|
15
|
+
vaultAuthority: "DD3AeAssFvjqTvRTrRAtpfjkBF8FpVKnFuwnMLN9haXD",
|
16
|
+
priceOracle: "7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE"
|
17
|
+
},
|
18
|
+
[USDC_MINT]: {
|
19
|
+
bank: "2s37akK2eyBbp8DZgCm7RtsaEz8eJP3Nxd4urLHQv7yB",
|
20
|
+
liquidityVault: "7jaiZR5Sk8hdYN9MxTpczTcwbWpb5WEoxSANuUwveuat",
|
21
|
+
vaultAuthority: "3uxNepDbmkDNq6JhRja5Z8QwbTrfmkKP8AKZV5chYDGG",
|
22
|
+
priceOracle: "Dpw1EAVrSB1ibxiDQyTAW6Zip3J4Btk2x4SgApQCeFbX"
|
23
|
+
},
|
24
|
+
[B_SOL]: {
|
25
|
+
bank: "6hS9i46WyTq1KXcoa2Chas2Txh9TJAVr6n1t3tnrE23K",
|
26
|
+
liquidityVault: "2WMipeKDB2CENxbzdmnVrRbsxCA2LY6kCtBe6AAqDP9p",
|
27
|
+
vaultAuthority: "8RcZHucpVHkHWRRdMhJZsxBK9mqKSYnMKGqtF84U8YEo",
|
28
|
+
priceOracle: "5cN76Xm2Dtx9MnrQqBDeZZRsWruTTcw37UruznAdSvvE",
|
29
|
+
},
|
30
|
+
[JUP]: {
|
31
|
+
bank: "Guu5uBc8k1WK1U2ihGosNaCy57LSgCkpWAabtzQqrQf8",
|
32
|
+
liquidityVault: "4w49W4fNDn778wsBa6TNq9hvebZKU17ymsptrEZ8zrsm",
|
33
|
+
vaultAuthority: "2MBwwAhL3c73Jy7HkWd9ofzh1bU39JBabrZCFQR2tUof",
|
34
|
+
priceOracle: "7dbob1psH1iZBS7qPsm3Kwbf5DzSXK8Jyg31CTgTnxH5",
|
35
|
+
}
|
36
|
+
}
|
40
37
|
};
|
41
38
|
|
42
39
|
export const MARGINFI_ACCOUNTS_LOOKUP_TABLE = "GAjmWmBPcH5Gxbiykasydj6RsCEaCLyHEvK6kHdFigc6";
|
package/src/types/accounts.ts
CHANGED
@@ -28,12 +28,14 @@ import { LivePositionUpdates } from "./solauto/generalUtils";
|
|
28
28
|
import { TOKEN_INFO } from "../constants";
|
29
29
|
|
30
30
|
export function findMarginfiAccounts(bank: PublicKey): MarginfiAssetAccounts {
|
31
|
-
for (const
|
32
|
-
const
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
for (const group in MARGINFI_ACCOUNTS) {
|
32
|
+
for (const key in MARGINFI_ACCOUNTS[group]) {
|
33
|
+
const account = MARGINFI_ACCOUNTS[group][key];
|
34
|
+
if (
|
35
|
+
account.bank.toString().toLowerCase() === bank.toString().toLowerCase()
|
36
|
+
) {
|
37
|
+
return account;
|
38
|
+
}
|
37
39
|
}
|
38
40
|
}
|
39
41
|
throw new Error(`Marginfi accounts not found by the bank: ${bank}`);
|
@@ -41,6 +43,7 @@ export function findMarginfiAccounts(bank: PublicKey): MarginfiAssetAccounts {
|
|
41
43
|
|
42
44
|
export async function getMaxLtvAndLiqThreshold(
|
43
45
|
umi: Umi,
|
46
|
+
marginfiGroup: PublicKey,
|
44
47
|
supply: {
|
45
48
|
mint: PublicKey;
|
46
49
|
bank?: Bank | null;
|
@@ -58,7 +61,7 @@ export async function getMaxLtvAndLiqThreshold(
|
|
58
61
|
if (!supply.bank || supply.bank === null) {
|
59
62
|
supply.bank = await safeFetchBank(
|
60
63
|
umi,
|
61
|
-
publicKey(MARGINFI_ACCOUNTS[supply.mint.toString()].bank),
|
64
|
+
publicKey(MARGINFI_ACCOUNTS[marginfiGroup.toString()][supply.mint.toString()].bank),
|
62
65
|
{ commitment: "confirmed" }
|
63
66
|
);
|
64
67
|
}
|
@@ -69,7 +72,7 @@ export async function getMaxLtvAndLiqThreshold(
|
|
69
72
|
) {
|
70
73
|
debt.bank = await safeFetchBank(
|
71
74
|
umi,
|
72
|
-
publicKey(MARGINFI_ACCOUNTS[debt.mint.toString()].bank),
|
75
|
+
publicKey(MARGINFI_ACCOUNTS[marginfiGroup.toString()][debt.mint.toString()].bank),
|
73
76
|
{ commitment: "confirmed" }
|
74
77
|
);
|
75
78
|
}
|
@@ -244,6 +247,7 @@ async function getTokenUsage(
|
|
244
247
|
export async function getMarginfiAccountPositionState(
|
245
248
|
umi: Umi,
|
246
249
|
marginfiAccountPk: PublicKey,
|
250
|
+
marginfiGroup?: PublicKey,
|
247
251
|
supplyMint?: PublicKey,
|
248
252
|
debtMint?: PublicKey,
|
249
253
|
livePositionUpdates?: LivePositionUpdates
|
@@ -254,11 +258,15 @@ export async function getMarginfiAccountPositionState(
|
|
254
258
|
{ commitment: "confirmed" }
|
255
259
|
);
|
256
260
|
|
261
|
+
if (!marginfiGroup && marginfiAccount) {
|
262
|
+
marginfiGroup = toWeb3JsPublicKey(marginfiAccount.group);
|
263
|
+
}
|
264
|
+
|
257
265
|
let supplyBank: Bank | null =
|
258
266
|
supplyMint && supplyMint !== PublicKey.default
|
259
267
|
? await safeFetchBank(
|
260
268
|
umi,
|
261
|
-
publicKey(MARGINFI_ACCOUNTS[supplyMint.toString()].bank),
|
269
|
+
publicKey(MARGINFI_ACCOUNTS[marginfiGroup?.toString() ?? ""][supplyMint.toString()].bank),
|
262
270
|
{ commitment: "confirmed" }
|
263
271
|
)
|
264
272
|
: null;
|
@@ -266,7 +274,7 @@ export async function getMarginfiAccountPositionState(
|
|
266
274
|
debtMint && debtMint !== PublicKey.default
|
267
275
|
? await safeFetchBank(
|
268
276
|
umi,
|
269
|
-
publicKey(MARGINFI_ACCOUNTS[debtMint.toString()].bank),
|
277
|
+
publicKey(MARGINFI_ACCOUNTS[marginfiGroup?.toString() ?? ""][debtMint.toString()].bank),
|
270
278
|
{ commitment: "confirmed" }
|
271
279
|
)
|
272
280
|
: null;
|
@@ -368,6 +376,7 @@ export async function getMarginfiAccountPositionState(
|
|
368
376
|
const supplyPrice = safeGetPrice(supplyMint!)!;
|
369
377
|
let [maxLtv, liqThreshold] = await getMaxLtvAndLiqThreshold(
|
370
378
|
umi,
|
379
|
+
marginfiGroup ?? new PublicKey(DEFAULT_MARGINFI_GROUP),
|
371
380
|
{
|
372
381
|
mint: toWeb3JsPublicKey(supplyBank.mint),
|
373
382
|
bank: supplyBank,
|
package/tests/unit/accounts.ts
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
import { describe, it } from "mocha";
|
2
|
+
import {
|
3
|
+
ALL_SUPPORTED_TOKENS,
|
4
|
+
TOKEN_INFO,
|
5
|
+
} from "../../src/constants/tokenConstants";
|
6
|
+
import {
|
7
|
+
buildHeliusApiUrl,
|
8
|
+
getSolanaRpcConnection,
|
9
|
+
} from "../../src/utils/solanaUtils";
|
10
|
+
import { publicKey } from "@metaplex-foundation/umi";
|
11
|
+
import { assert } from "chai";
|
12
|
+
|
13
|
+
describe("Assert Solauto fee token accounts are created", async () => {
|
14
|
+
it("all Solauto fee token accounts created", async () => {
|
15
|
+
let [_, umi] = getSolanaRpcConnection(
|
16
|
+
buildHeliusApiUrl(process.env.HELIUS_API_KEY!)
|
17
|
+
);
|
18
|
+
|
19
|
+
const tokenAccounts = await umi.rpc.getAccounts(
|
20
|
+
ALL_SUPPORTED_TOKENS.map((x) => publicKey(x))
|
21
|
+
);
|
22
|
+
for (let i = 0; i < tokenAccounts.length; i++) {
|
23
|
+
if (!tokenAccounts[i].exists) {
|
24
|
+
console.log(
|
25
|
+
"Missing Solauto fees TA for ",
|
26
|
+
TOKEN_INFO[ALL_SUPPORTED_TOKENS[i].toString()].ticker
|
27
|
+
);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
assert(tokenAccounts.filter((x) => !x.exists).length === 0);
|
31
|
+
});
|
32
|
+
});
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { describe, it } from
|
1
|
+
import { describe, it } from "mocha";
|
2
2
|
import { clusterApiUrl, Connection, PublicKey } from "@solana/web3.js";
|
3
3
|
import {
|
4
4
|
DEFAULT_PUBKEY,
|
@@ -20,22 +20,24 @@ describe("Assert lookup tables up-to-date", async () => {
|
|
20
20
|
const existingAccounts =
|
21
21
|
lookupTable.value?.state.addresses.map((x) => x.toString()) ?? [];
|
22
22
|
|
23
|
-
for (const
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
for (const group in MARGINFI_ACCOUNTS) {
|
24
|
+
for (const key in MARGINFI_ACCOUNTS[group]) {
|
25
|
+
if (key === DEFAULT_PUBKEY) {
|
26
|
+
continue;
|
27
|
+
}
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
const tokenAccounts = MARGINFI_ACCOUNTS[key];
|
30
|
+
const addresses = [
|
31
|
+
new PublicKey(key),
|
32
|
+
tokenAccounts.bank,
|
33
|
+
tokenAccounts.liquidityVault,
|
34
|
+
tokenAccounts.vaultAuthority,
|
35
|
+
tokenAccounts.priceOracle,
|
36
|
+
];
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
if (addresses.find((x) => !existingAccounts.includes(x.toString()))) {
|
39
|
+
throw new Error("Marginfi accounts lookup table missing an account");
|
40
|
+
}
|
39
41
|
}
|
40
42
|
}
|
41
43
|
});
|
@@ -10,6 +10,7 @@ import { SolautoClient } from "../../src/clients/solautoClient";
|
|
10
10
|
import {
|
11
11
|
DCASettings,
|
12
12
|
LendingPlatform,
|
13
|
+
PositionType,
|
13
14
|
SolautoRebalanceType,
|
14
15
|
SolautoSettingsParameters,
|
15
16
|
TokenType,
|
@@ -175,11 +176,11 @@ async function getFakePosition(
|
|
175
176
|
rebalanceType: SolautoRebalanceType.Regular,
|
176
177
|
targetLiqUtilizationRateBps: 0,
|
177
178
|
flashLoanAmount: BigInt(0),
|
178
|
-
priceSlippageBps: 0,
|
179
179
|
padding1: [],
|
180
180
|
padding2: [],
|
181
181
|
padding: new Uint8Array([]),
|
182
182
|
},
|
183
|
+
positionType: PositionType.Leverage,
|
183
184
|
padding1: [],
|
184
185
|
padding: [],
|
185
186
|
publicKey: publicKey(PublicKey.default),
|