@haven-fi/solauto-sdk 1.0.145 → 1.0.146
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/utils/marginfiUtils.d.ts.map +1 -1
- package/dist/utils/marginfiUtils.js +1 -3
- package/dist/utils/solanaUtils.d.ts +0 -1
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +0 -10
- package/package.json +1 -1
- package/src/utils/marginfiUtils.ts +1 -3
- package/src/utils/solanaUtils.ts +0 -10
- package/tests/transactions/solautoMarginfi.ts +2 -2
@@ -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;
|
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;AAE7D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,qBAAqB,CAU3E;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,EACR,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,CAiE3B;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;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,CAkJpC;AA+DD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAyB3B"}
|
@@ -13,7 +13,6 @@ const generalUtils_1 = require("./generalUtils");
|
|
13
13
|
const numberUtils_1 = require("./numberUtils");
|
14
14
|
const marginfiAccounts_1 = require("../constants/marginfiAccounts");
|
15
15
|
const generalAccounts_1 = require("../constants/generalAccounts");
|
16
|
-
const solanaUtils_1 = require("./solanaUtils");
|
17
16
|
function findMarginfiAccounts(bank) {
|
18
17
|
for (const key in marginfiAccounts_1.MARGINFI_ACCOUNTS) {
|
19
18
|
const account = marginfiAccounts_1.MARGINFI_ACCOUNTS[key];
|
@@ -236,8 +235,7 @@ function calcAccruedInterestPaymentPerPeriod(apr, timeDelta, shareValue) {
|
|
236
235
|
return newValue;
|
237
236
|
}
|
238
237
|
async function getUpToDateShareValues(umi, bank) {
|
239
|
-
|
240
|
-
let timeDelta = currentTime - Number(bank.lastUpdate);
|
238
|
+
let timeDelta = (0, generalUtils_1.currentUnixSeconds)() - Number(bank.lastUpdate);
|
241
239
|
const totalAssets = (0, numberUtils_1.bytesToI80F48)(bank.totalAssetShares.value) *
|
242
240
|
(0, numberUtils_1.bytesToI80F48)(bank.assetShareValue.value);
|
243
241
|
const totalLiabilities = (0, numberUtils_1.bytesToI80F48)(bank.totalLiabilityShares.value) *
|
@@ -2,7 +2,6 @@ import { AddressLookupTableInput, Signer, TransactionBuilder, Umi, WrappedInstru
|
|
2
2
|
import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
3
3
|
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
4
4
|
export declare function getSolanaRpcConnection(heliusApiKey: string): [Connection, Umi];
|
5
|
-
export declare function currentUnixSecondsSolana(umi: Umi): Promise<number>;
|
6
5
|
export declare function getWrappedInstruction(signer: Signer, ix: TransactionInstruction): WrappedInstruction;
|
7
6
|
export declare function setComputeUnitLimitUmiIx(signer: Signer, maxComputeUnits: number): WrappedInstruction;
|
8
7
|
export declare function setComputeUnitPriceUmiIx(signer: Signer, lamports: number): WrappedInstruction;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,GAAG,EACH,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAGL,UAAU,EACV,SAAS,EAIT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAYzB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAA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AI,EAAE,SAAS,EACf,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,GACb,kBAAkB,CAKpB;AAED,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,GAAG,EACR,oBAAoB,EAAE,MAAM,EAAE,GAC7B,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAkBpC;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,kBAAkB,EACtB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,CAAC,EAAE,MAAM,sBA4D1B;AAmBD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,kBAAkB,EACtB,eAAe,EAAE,kBAAkB,GAClC,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,kBAAkB,EACtB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,UAAU,CAAC,EAAE,MAAM,EACnB,eAAe,GAAE,kBAA+C,EAChE,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA8DjC"}
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.getSolanaRpcConnection = getSolanaRpcConnection;
|
7
|
-
exports.currentUnixSecondsSolana = currentUnixSecondsSolana;
|
8
7
|
exports.getWrappedInstruction = getWrappedInstruction;
|
9
8
|
exports.setComputeUnitLimitUmiIx = setComputeUnitLimitUmiIx;
|
10
9
|
exports.setComputeUnitPriceUmiIx = setComputeUnitPriceUmiIx;
|
@@ -31,15 +30,6 @@ function getSolanaRpcConnection(heliusApiKey) {
|
|
31
30
|
const umi = (0, umi_bundle_defaults_1.createUmi)(connection);
|
32
31
|
return [connection, umi];
|
33
32
|
}
|
34
|
-
async function currentUnixSecondsSolana(umi) {
|
35
|
-
return await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
|
36
|
-
const blockTime = await umi.rpc.getBlockTime(await umi.rpc.getSlot(), { commitment: "confirmed" });
|
37
|
-
if (blockTime === null) {
|
38
|
-
throw new Error("Unable to retrieve block time");
|
39
|
-
}
|
40
|
-
return Number(blockTime);
|
41
|
-
});
|
42
|
-
}
|
43
33
|
function getWrappedInstruction(signer, ix) {
|
44
34
|
return {
|
45
35
|
instruction: (0, umi_web3js_adapters_1.fromWeb3JsInstruction)(ix),
|
package/package.json
CHANGED
@@ -21,7 +21,6 @@ import { MarginfiAssetAccounts } from "../types/accounts";
|
|
21
21
|
import { PositionState, PositionTokenUsage } from "../generated";
|
22
22
|
import { USD_DECIMALS } from "../constants/generalAccounts";
|
23
23
|
import { LivePositionUpdates } from "./solauto/generalUtils";
|
24
|
-
import { currentUnixSecondsSolana } from "./solanaUtils";
|
25
24
|
|
26
25
|
export function findMarginfiAccounts(bank: PublicKey): MarginfiAssetAccounts {
|
27
26
|
for (const key in MARGINFI_ACCOUNTS) {
|
@@ -447,8 +446,7 @@ export async function getUpToDateShareValues(
|
|
447
446
|
umi: Umi,
|
448
447
|
bank: Bank
|
449
448
|
): Promise<[number, number]> {
|
450
|
-
|
451
|
-
let timeDelta = currentTime - Number(bank.lastUpdate);
|
449
|
+
let timeDelta = currentUnixSeconds() - Number(bank.lastUpdate);
|
452
450
|
|
453
451
|
const totalAssets =
|
454
452
|
bytesToI80F48(bank.totalAssetShares.value) *
|
package/src/utils/solanaUtils.ts
CHANGED
@@ -49,16 +49,6 @@ export function getSolanaRpcConnection(
|
|
49
49
|
return [connection, umi];
|
50
50
|
}
|
51
51
|
|
52
|
-
export async function currentUnixSecondsSolana(umi: Umi): Promise<number> {
|
53
|
-
return await retryWithExponentialBackoff(async () => {
|
54
|
-
const blockTime = await umi.rpc.getBlockTime(await umi.rpc.getSlot(), { commitment: "confirmed" });
|
55
|
-
if (blockTime === null) {
|
56
|
-
throw new Error("Unable to retrieve block time");
|
57
|
-
}
|
58
|
-
return Number(blockTime);
|
59
|
-
});
|
60
|
-
}
|
61
|
-
|
62
52
|
export function getWrappedInstruction(
|
63
53
|
signer: Signer,
|
64
54
|
ix: TransactionInstruction
|
@@ -23,7 +23,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
23
23
|
// const signer = setupTest();
|
24
24
|
const signer = setupTest("solauto-manager");
|
25
25
|
|
26
|
-
const payForTransactions =
|
26
|
+
const payForTransactions = false;
|
27
27
|
const useJitoBundle = false;
|
28
28
|
const positionId = 1;
|
29
29
|
|
@@ -39,7 +39,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
39
39
|
{
|
40
40
|
signer,
|
41
41
|
positionId,
|
42
|
-
authority: new PublicKey("
|
42
|
+
// authority: new PublicKey("")
|
43
43
|
// marginfiAccount: new PublicKey(
|
44
44
|
// "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
|
45
45
|
// ),
|