@haven-fi/solauto-sdk 1.0.28 → 1.0.30
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/solauto.d.ts +3 -6
- package/dist/types/solauto.d.ts.map +1 -1
- package/dist/utils/marginfiUtils.d.ts.map +1 -1
- package/dist/utils/marginfiUtils.js +1 -1
- package/dist/utils/solauto/generalUtils.d.ts.map +1 -1
- package/dist/utils/solauto/generalUtils.js +0 -2
- package/package.json +1 -1
- package/src/types/index.ts +1 -0
- package/src/types/solauto.ts +3 -7
- package/src/utils/marginfiUtils.ts +1 -3
- package/src/utils/solauto/generalUtils.ts +8 -16
package/dist/types/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
package/dist/types/index.js
CHANGED
package/dist/types/solauto.d.ts
CHANGED
@@ -2,12 +2,9 @@ import { PublicKey } from "@solana/web3.js";
|
|
2
2
|
import { LendingPlatform } from "../generated";
|
3
3
|
export interface SolautoPositionDetails {
|
4
4
|
positionId: number;
|
5
|
-
selfManaged: boolean;
|
6
5
|
lendingPlatform: LendingPlatform;
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
supplyMint: PublicKey;
|
11
|
-
debtMint: PublicKey;
|
6
|
+
protocolAccount?: PublicKey;
|
7
|
+
supplyMint?: PublicKey;
|
8
|
+
debtMint?: PublicKey;
|
12
9
|
}
|
13
10
|
//# sourceMappingURL=solauto.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solauto.d.ts","sourceRoot":"","sources":["../../src/types/solauto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,sBAAsB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,
|
1
|
+
{"version":3,"file":"solauto.d.ts","sourceRoot":"","sources":["../../src/types/solauto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,sBAAsB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB"}
|
@@ -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,
|
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,wBAAwB,CAAC,EACvC,IAAI,EACJ,IAAI,GACL,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,qBAAqB,CAWxB;AAED,wBAAsB,wBAAwB,CAC5C,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,IAAI,EACd,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAkC3B;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,CA6CA;AAoDD,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,CA4IpC;AA+DD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA0B3B"}
|
@@ -25,7 +25,7 @@ function findMarginfiBankAccounts({ mint, bank, }) {
|
|
25
25
|
}
|
26
26
|
exports.findMarginfiBankAccounts = findMarginfiBankAccounts;
|
27
27
|
async function getMaxLtvAndLiqThreshold(supplyBank, debtBank, supplyPrice) {
|
28
|
-
if (!
|
28
|
+
if (!supplyPrice) {
|
29
29
|
const [price] = await (0, generalUtils_1.getTokenPrices)([(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(supplyBank.mint)]);
|
30
30
|
supplyPrice = price;
|
31
31
|
}
|
@@ -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,EAAoB,GAAG,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,eAAe,EACf,aAAa,EAEb,yBAAyB,EACzB,gCAAgC,EAIjC,MAAM,iBAAiB,CAAC;AAczB,OAAO,
|
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,EAAoB,GAAG,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,eAAe,EACf,aAAa,EAEb,yBAAyB,EACzB,gCAAgC,EAIjC,MAAM,iBAAiB,CAAC;AAczB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAgB7D,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,kBAAkB,GAC7B,MAAM,CAKR;AAED,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,kBAAkB,GAC7B,OAAO,CAET;AAED,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,kBAAkB,EAC9B,oBAAoB,EAAE,MAAM,UAY7B;AAED,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,yBAAyB,EACnC,kBAAkB,EAAE,MAAM,GACzB,yBAAyB,CAgB3B;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,OAAO,GACf;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EA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,MAAM,CAAa;IACrC,cAAc,EAAE,MAAM,CAAa;IACnC,uBAAuB,EAAE,MAAM,CAAa;IAC5C,QAAQ,EAAE,yBAAyB,GAAG,SAAS,CAAa;IAC5D,SAAS,EAAE,WAAW,GAAG,SAAS,CAAa;IAEtD,GAAG,CAAC,MAAM,EAAE,kBAAkB;IAyD9B,KAAK;IAQL,UAAU,IAAI,OAAO;CAQtB"}
|
@@ -186,12 +186,10 @@ async function getAllPositionsByAuthority(umi, user) {
|
|
186
186
|
allPositions.push(...solautoManagedPositions.map((x) => ({
|
187
187
|
positionId: x.positionId,
|
188
188
|
lendingPlatform: x.lendingPlatform,
|
189
|
-
selfManaged: false,
|
190
189
|
})));
|
191
190
|
const marginfiPositions = await (0, marginfiUtils_1.getAllMarginfiAccountsByAuthority)(umi, user, true);
|
192
191
|
allPositions.push(...marginfiPositions.map((x) => ({
|
193
192
|
positionId: 0,
|
194
|
-
selfManaged: true,
|
195
193
|
lendingPlatform: generated_1.LendingPlatform.Marginfi,
|
196
194
|
protocolAccount: x.marginfiAccount,
|
197
195
|
supplyMint: x.supplyMint,
|
package/package.json
CHANGED
package/src/types/index.ts
CHANGED
package/src/types/solauto.ts
CHANGED
@@ -3,12 +3,8 @@ import { LendingPlatform } from "../generated";
|
|
3
3
|
|
4
4
|
export interface SolautoPositionDetails {
|
5
5
|
positionId: number;
|
6
|
-
selfManaged: boolean;
|
7
6
|
lendingPlatform: LendingPlatform;
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
protocolAccount: PublicKey;
|
12
|
-
supplyMint: PublicKey;
|
13
|
-
debtMint: PublicKey;
|
7
|
+
protocolAccount?: PublicKey;
|
8
|
+
supplyMint?: PublicKey;
|
9
|
+
debtMint?: PublicKey;
|
14
10
|
}
|
@@ -5,8 +5,6 @@ import {
|
|
5
5
|
Bank,
|
6
6
|
getMarginfiAccountSize,
|
7
7
|
MARGINFI_PROGRAM_ID,
|
8
|
-
MarginfiAccount,
|
9
|
-
safeFetchAllMarginfiAccount,
|
10
8
|
safeFetchBank,
|
11
9
|
safeFetchMarginfiAccount,
|
12
10
|
} from "../marginfi-sdk";
|
@@ -49,7 +47,7 @@ export async function getMaxLtvAndLiqThreshold(
|
|
49
47
|
debtBank: Bank,
|
50
48
|
supplyPrice?: number
|
51
49
|
): Promise<[number, number]> {
|
52
|
-
if (!
|
50
|
+
if (!supplyPrice) {
|
53
51
|
const [price] = await getTokenPrices([toWeb3JsPublicKey(supplyBank.mint)]);
|
54
52
|
supplyPrice = price;
|
55
53
|
}
|
@@ -27,10 +27,7 @@ import {
|
|
27
27
|
getAllMarginfiAccountsByAuthority,
|
28
28
|
getMarginfiAccountPositionState,
|
29
29
|
} from "../marginfiUtils";
|
30
|
-
import {
|
31
|
-
SelfManagedPositionDetails,
|
32
|
-
SolautoPositionDetails,
|
33
|
-
} from "../../types/solauto";
|
30
|
+
import { SolautoPositionDetails } from "../../types/solauto";
|
34
31
|
|
35
32
|
function newPeriodsPassed(
|
36
33
|
automation: AutomationSettings,
|
@@ -293,7 +290,6 @@ export async function getAllPositionsByAuthority(
|
|
293
290
|
...solautoManagedPositions.map((x) => ({
|
294
291
|
positionId: x.positionId,
|
295
292
|
lendingPlatform: x.lendingPlatform,
|
296
|
-
selfManaged: false,
|
297
293
|
}))
|
298
294
|
);
|
299
295
|
|
@@ -303,17 +299,13 @@ export async function getAllPositionsByAuthority(
|
|
303
299
|
true
|
304
300
|
);
|
305
301
|
allPositions.push(
|
306
|
-
...marginfiPositions.map(
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
supplyMint: x.supplyMint,
|
314
|
-
debtMint: x.debtMint,
|
315
|
-
}) as SelfManagedPositionDetails
|
316
|
-
)
|
302
|
+
...marginfiPositions.map((x) => ({
|
303
|
+
positionId: 0,
|
304
|
+
lendingPlatform: LendingPlatform.Marginfi,
|
305
|
+
protocolAccount: x.marginfiAccount,
|
306
|
+
supplyMint: x.supplyMint,
|
307
|
+
debtMint: x.debtMint,
|
308
|
+
}))
|
317
309
|
);
|
318
310
|
|
319
311
|
// TODO support other platforms
|