@haven-fi/solauto-sdk 1.0.29 → 1.0.31
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/types/solauto.d.ts +3 -6
- package/dist/types/solauto.d.ts.map +1 -1
- package/dist/utils/generalUtils.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/solauto.ts +3 -7
- package/src/utils/generalUtils.ts +1 -1
- package/src/utils/solauto/generalUtils.ts +8 -16
- package/tests/unit/rebalanceCalculations.ts +1 -0
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"}
|
@@ -50,7 +50,7 @@ async function getTokenPrices(mints) {
|
|
50
50
|
console.log("Accessing price cache");
|
51
51
|
return mints.map((mint) => solautoConstants_1.PRICES[mint.toString()].price);
|
52
52
|
}
|
53
|
-
console.log(
|
53
|
+
console.log(`Fetching prices for ${mints.join(", ")}`);
|
54
54
|
const priceFeedIds = mints.map((mint) => pythConstants_1.PYTH_PRICE_FEED_IDS[mint.toString()]);
|
55
55
|
const getReq = async () => await fetch(`https://hermes.pyth.network/v2/updates/price/latest?${priceFeedIds.map((x) => `ids%5B%5D=${x}`).join("&")}`);
|
56
56
|
let resp = await getReq();
|
@@ -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,iB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B;AAED,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,sBAAsB,EAAE,CAAC,CA6BnC;AA4DD,KAAK,kBAAkB,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,gCAAgC,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAE/C,qBAAa,mBAAmB;IACvB,gBAAgB,EAAE,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/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
|
}
|
@@ -58,7 +58,7 @@ export async function getTokenPrices(mints: PublicKey[]): Promise<number[]> {
|
|
58
58
|
return mints.map((mint) => PRICES[mint.toString()].price);
|
59
59
|
}
|
60
60
|
|
61
|
-
console.log(
|
61
|
+
console.log(`Fetching prices for ${mints.join(", ")}`);
|
62
62
|
const priceFeedIds = mints.map(
|
63
63
|
(mint) => PYTH_PRICE_FEED_IDS[mint.toString()]
|
64
64
|
);
|
@@ -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
|
@@ -261,6 +261,7 @@ describe("Rebalance tests", async () => {
|
|
261
261
|
let supplyPrice: number, debtPrice: number;
|
262
262
|
|
263
263
|
before(async () => {
|
264
|
+
console.log("Fetching prices for test");
|
264
265
|
[supplyPrice, debtPrice] = await getTokenPrices([
|
265
266
|
NATIVE_MINT,
|
266
267
|
new PublicKey(USDC_MINT),
|