@haven-fi/solauto-sdk 1.0.145 → 1.0.147
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/referralStateManager.d.ts +1 -1
- package/dist/clients/referralStateManager.js +2 -2
- package/dist/clients/solautoClient.d.ts +1 -1
- package/dist/clients/solautoClient.js +3 -3
- package/dist/clients/txHandler.d.ts +2 -2
- package/dist/clients/txHandler.d.ts.map +1 -1
- package/dist/clients/txHandler.js +3 -3
- package/dist/utils/marginfiUtils.d.ts.map +1 -1
- package/dist/utils/marginfiUtils.js +9 -5
- package/dist/utils/solanaUtils.d.ts +2 -2
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +6 -12
- package/dist/utils/solauto/generalUtils.d.ts.map +1 -1
- package/local/createSolautoManagerAccount.ts +2 -1
- package/local/shared.ts +2 -2
- package/package.json +1 -1
- package/src/clients/referralStateManager.ts +2 -2
- package/src/clients/solautoClient.ts +3 -3
- package/src/clients/txHandler.ts +10 -9
- package/src/utils/marginfiUtils.ts +44 -29
- package/src/utils/solanaUtils.ts +8 -17
- package/src/utils/solauto/generalUtils.ts +0 -1
- package/tests/transactions/solautoMarginfi.ts +4 -3
|
@@ -15,7 +15,7 @@ export declare class ReferralStateManager extends TxHandler {
|
|
|
15
15
|
referralAuthority: PublicKey;
|
|
16
16
|
referralState: PublicKey;
|
|
17
17
|
referralStateData: ReferralState | null;
|
|
18
|
-
constructor(
|
|
18
|
+
constructor(heliusApiUrl: string, localTest?: boolean | undefined);
|
|
19
19
|
initialize(args: ReferralStateManagerArgs): Promise<void>;
|
|
20
20
|
defaultLookupTables(): string[];
|
|
21
21
|
updateReferralStatesIx(destFeesMint?: PublicKey, referredBy?: PublicKey, lookupTable?: PublicKey): TransactionBuilder;
|
|
@@ -9,8 +9,8 @@ const generated_1 = require("../generated");
|
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
10
|
const txHandler_1 = require("./txHandler");
|
|
11
11
|
class ReferralStateManager extends txHandler_1.TxHandler {
|
|
12
|
-
constructor(
|
|
13
|
-
super(
|
|
12
|
+
constructor(heliusApiUrl, localTest) {
|
|
13
|
+
super(heliusApiUrl, localTest);
|
|
14
14
|
this.localTest = localTest;
|
|
15
15
|
this.umi = this.umi.use({
|
|
16
16
|
install(umi) {
|
|
@@ -41,7 +41,7 @@ export declare abstract class SolautoClient extends TxHandler {
|
|
|
41
41
|
solautoFeesSupplyTa: PublicKey;
|
|
42
42
|
authorityLutAddress?: PublicKey;
|
|
43
43
|
livePositionUpdates: LivePositionUpdates;
|
|
44
|
-
constructor(
|
|
44
|
+
constructor(heliusApiUrl: string, localTest?: boolean | undefined);
|
|
45
45
|
initialize(args: SolautoClientArgs, lendingPlatform: LendingPlatform): Promise<void>;
|
|
46
46
|
resetLiveTxUpdates(success?: boolean): Promise<void>;
|
|
47
47
|
abstract protocolAccount(): PublicKey;
|
|
@@ -16,8 +16,8 @@ const generalUtils_2 = require("../utils/solauto/generalUtils");
|
|
|
16
16
|
const referralStateManager_1 = require("./referralStateManager");
|
|
17
17
|
const txHandler_1 = require("./txHandler");
|
|
18
18
|
class SolautoClient extends txHandler_1.TxHandler {
|
|
19
|
-
constructor(
|
|
20
|
-
super(
|
|
19
|
+
constructor(heliusApiUrl, localTest) {
|
|
20
|
+
super(heliusApiUrl, localTest);
|
|
21
21
|
this.localTest = localTest;
|
|
22
22
|
this.livePositionUpdates = new generalUtils_2.LivePositionUpdates();
|
|
23
23
|
this.umi = this.umi.use({
|
|
@@ -55,7 +55,7 @@ class SolautoClient extends txHandler_1.TxHandler {
|
|
|
55
55
|
: web3_js_1.PublicKey.default);
|
|
56
56
|
this.positionDebtTa = (0, accountUtils_1.getTokenAccount)(this.solautoPosition, this.debtMint);
|
|
57
57
|
this.signerDebtTa = (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.debtMint);
|
|
58
|
-
this.referralStateManager = new referralStateManager_1.ReferralStateManager(this.
|
|
58
|
+
this.referralStateManager = new referralStateManager_1.ReferralStateManager(this.heliusApiUrl);
|
|
59
59
|
await this.referralStateManager.initialize({
|
|
60
60
|
referralAuthority: this.authority,
|
|
61
61
|
signer: args.signer,
|
|
@@ -2,10 +2,10 @@ import { Umi } from "@metaplex-foundation/umi";
|
|
|
2
2
|
import { Connection } from "@solana/web3.js";
|
|
3
3
|
export declare abstract class TxHandler {
|
|
4
4
|
localTest?: boolean | undefined;
|
|
5
|
-
|
|
5
|
+
heliusApiUrl: string;
|
|
6
6
|
umi: Umi;
|
|
7
7
|
connection: Connection;
|
|
8
|
-
constructor(
|
|
8
|
+
constructor(heliusApiUrl: string, localTest?: boolean | undefined);
|
|
9
9
|
log(...args: any[]): void;
|
|
10
10
|
abstract defaultLookupTables(): string[];
|
|
11
11
|
abstract resetLiveTxUpdates(success?: boolean): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../src/clients/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../src/clients/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,8BAAsB,SAAS;IAOpB,SAAS,CAAC,EAAE,OAAO;IANrB,YAAY,EAAG,MAAM,CAAC;IACtB,GAAG,EAAG,GAAG,CAAC;IACV,UAAU,EAAG,UAAU,CAAC;gBAG7B,YAAY,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,OAAO,YAAA;IAQ5B,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAMzB,QAAQ,CAAC,mBAAmB,IAAI,MAAM,EAAE;IAExC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC9D"}
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TxHandler = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
class TxHandler {
|
|
6
|
-
constructor(
|
|
6
|
+
constructor(heliusApiUrl, localTest) {
|
|
7
7
|
this.localTest = localTest;
|
|
8
|
-
this.
|
|
9
|
-
const [connection, umi] = (0, utils_1.getSolanaRpcConnection)(this.
|
|
8
|
+
this.heliusApiUrl = heliusApiUrl;
|
|
9
|
+
const [connection, umi] = (0, utils_1.getSolanaRpcConnection)(this.heliusApiUrl);
|
|
10
10
|
this.connection = connection;
|
|
11
11
|
this.umi = umi;
|
|
12
12
|
}
|
|
@@ -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;
|
|
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;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,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,UAAU,CAAC,EAAE,SAAS,EACtB,QAAQ,CAAC,EAAE,SAAS,EACpB,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAsJpC;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];
|
|
@@ -82,6 +81,8 @@ async function getAllMarginfiAccountsByAuthority(umi, authority, compatibleWithS
|
|
|
82
81
|
state: await getMarginfiAccountPositionState(umi, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.publicKey)),
|
|
83
82
|
})));
|
|
84
83
|
return positionStates
|
|
84
|
+
.sort((a, b) => (0, numberUtils_1.fromBaseUnit)(b.state?.netWorth.baseAmountUsdValue ?? BigInt(0), generalAccounts_1.USD_DECIMALS) -
|
|
85
|
+
(0, numberUtils_1.fromBaseUnit)(a.state?.netWorth.baseAmountUsdValue ?? BigInt(0), generalAccounts_1.USD_DECIMALS))
|
|
85
86
|
.filter((x) => x.state !== undefined)
|
|
86
87
|
.map((x) => ({
|
|
87
88
|
marginfiAccount: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.publicKey),
|
|
@@ -154,7 +155,9 @@ async function getMarginfiAccountPositionState(umi, marginfiAccountPk, supplyMin
|
|
|
154
155
|
}
|
|
155
156
|
if (supplyBalances.length > 0) {
|
|
156
157
|
if (supplyBank === null) {
|
|
157
|
-
supplyBank = await (0, marginfi_sdk_1.safeFetchBank)(umi, supplyBalances[0].bankPk, {
|
|
158
|
+
supplyBank = await (0, marginfi_sdk_1.safeFetchBank)(umi, supplyBalances[0].bankPk, {
|
|
159
|
+
commitment: "confirmed",
|
|
160
|
+
});
|
|
158
161
|
}
|
|
159
162
|
if (!supplyMint) {
|
|
160
163
|
supplyMint = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(supplyBank.mint);
|
|
@@ -163,7 +166,9 @@ async function getMarginfiAccountPositionState(umi, marginfiAccountPk, supplyMin
|
|
|
163
166
|
}
|
|
164
167
|
if (debtBalances.length > 0) {
|
|
165
168
|
if (debtBank === null) {
|
|
166
|
-
debtBank = await (0, marginfi_sdk_1.safeFetchBank)(umi, debtBalances[0].bankPk, {
|
|
169
|
+
debtBank = await (0, marginfi_sdk_1.safeFetchBank)(umi, debtBalances[0].bankPk, {
|
|
170
|
+
commitment: "confirmed",
|
|
171
|
+
});
|
|
167
172
|
}
|
|
168
173
|
if (!debtMint) {
|
|
169
174
|
debtMint = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(debtBank.mint);
|
|
@@ -236,8 +241,7 @@ function calcAccruedInterestPaymentPerPeriod(apr, timeDelta, shareValue) {
|
|
|
236
241
|
return newValue;
|
|
237
242
|
}
|
|
238
243
|
async function getUpToDateShareValues(umi, bank) {
|
|
239
|
-
|
|
240
|
-
let timeDelta = currentTime - Number(bank.lastUpdate);
|
|
244
|
+
let timeDelta = (0, generalUtils_1.currentUnixSeconds)() - Number(bank.lastUpdate);
|
|
241
245
|
const totalAssets = (0, numberUtils_1.bytesToI80F48)(bank.totalAssetShares.value) *
|
|
242
246
|
(0, numberUtils_1.bytesToI80F48)(bank.assetShareValue.value);
|
|
243
247
|
const totalLiabilities = (0, numberUtils_1.bytesToI80F48)(bank.totalLiabilityShares.value) *
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AddressLookupTableInput, Signer, TransactionBuilder, Umi, WrappedInstruction } from "@metaplex-foundation/umi";
|
|
2
2
|
import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
3
3
|
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
4
|
+
export declare function buildHeliusApiUrl(heliusApiKey: string): string;
|
|
5
|
+
export declare function getSolanaRpcConnection(heliusApiUrl: string): [Connection, Umi];
|
|
6
6
|
export declare function getWrappedInstruction(signer: Signer, ix: TransactionInstruction): WrappedInstruction;
|
|
7
7
|
export declare function setComputeUnitLimitUmiIx(signer: Signer, maxComputeUnits: number): WrappedInstruction;
|
|
8
8
|
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,EAAE,MAAM,UAAU,CAAC;AAElE,wBAAgB,
|
|
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,EAAE,MAAM,UAAU,CAAC;AAElE,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,UAErD;AAED,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,GACnB,CAAC,UAAU,EAAE,GAAG,CAAC,CAInB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,sBAAsB,GACzB,kBAAkB,CAMpB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,GACtB,kBAAkB,CAOpB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,kBAAkB,CAOpB;AAED,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,GACd,kBAAkB,CAUpB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,SAAS,EACtB,QAAQ,EAAE,MAAM,GACf,kBAAkB,CASpB;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,SAAS,EACvB,SAAS,EAAE,SAAS,GACnB,kBAAkB,CAKpB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,EACjB,IAAI,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"}
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildHeliusApiUrl = buildHeliusApiUrl;
|
|
6
7
|
exports.getSolanaRpcConnection = getSolanaRpcConnection;
|
|
7
|
-
exports.currentUnixSecondsSolana = currentUnixSecondsSolana;
|
|
8
8
|
exports.getWrappedInstruction = getWrappedInstruction;
|
|
9
9
|
exports.setComputeUnitLimitUmiIx = setComputeUnitLimitUmiIx;
|
|
10
10
|
exports.setComputeUnitPriceUmiIx = setComputeUnitPriceUmiIx;
|
|
@@ -26,20 +26,14 @@ const accountUtils_1 = require("./accountUtils");
|
|
|
26
26
|
const generalUtils_1 = require("./generalUtils");
|
|
27
27
|
const marginfi_sdk_1 = require("../marginfi-sdk");
|
|
28
28
|
const types_1 = require("../types");
|
|
29
|
-
function
|
|
30
|
-
|
|
29
|
+
function buildHeliusApiUrl(heliusApiKey) {
|
|
30
|
+
return `https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`;
|
|
31
|
+
}
|
|
32
|
+
function getSolanaRpcConnection(heliusApiUrl) {
|
|
33
|
+
const connection = new web3_js_1.Connection(heliusApiUrl, "confirmed");
|
|
31
34
|
const umi = (0, umi_bundle_defaults_1.createUmi)(connection);
|
|
32
35
|
return [connection, umi];
|
|
33
36
|
}
|
|
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
37
|
function getWrappedInstruction(signer, ix) {
|
|
44
38
|
return {
|
|
45
39
|
instruction: (0, umi_web3js_adapters_1.fromWeb3JsInstruction)(ix),
|
|
@@ -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,EAA+B,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAElB,aAAa,EAEb,yBAAyB,EACzB,gCAAgC,EAChC,SAAS,
|
|
1
|
+
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/generalUtils.ts"],"names":[],"mappings":"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"}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
transactionBuilder,
|
|
6
6
|
} from "@metaplex-foundation/umi";
|
|
7
7
|
import {
|
|
8
|
+
buildHeliusApiUrl,
|
|
8
9
|
getSolanaRpcConnection,
|
|
9
10
|
sendSingleOptimizedTransaction,
|
|
10
11
|
} from "../src/utils/solanaUtils";
|
|
@@ -14,7 +15,7 @@ import { getSecretKey } from "./shared";
|
|
|
14
15
|
import { updateSolautoLut } from "./updateSolautoLUT";
|
|
15
16
|
|
|
16
17
|
async function create() {
|
|
17
|
-
let [connection, umi] = getSolanaRpcConnection(process.env.HELIUS_API_KEY!);
|
|
18
|
+
let [connection, umi] = getSolanaRpcConnection(buildHeliusApiUrl(process.env.HELIUS_API_KEY!));
|
|
18
19
|
|
|
19
20
|
const secretKey = getSecretKey("solauto-manager");
|
|
20
21
|
const signerKeypair = umi.eddsa.createKeypairFromSecretKey(secretKey);
|
package/local/shared.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
VersionedTransaction,
|
|
9
9
|
PublicKey,
|
|
10
10
|
} from "@solana/web3.js";
|
|
11
|
-
import { getSolanaRpcConnection } from "../src/utils/solanaUtils";
|
|
11
|
+
import { buildHeliusApiUrl, getSolanaRpcConnection } from "../src/utils/solanaUtils";
|
|
12
12
|
|
|
13
13
|
function loadSecretKey(keypairPath: string) {
|
|
14
14
|
const secretKey = JSON.parse(fs.readFileSync(keypairPath, "utf8"));
|
|
@@ -22,7 +22,7 @@ export function getSecretKey(keypairFilename: string = "id"): Uint8Array {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const keypair = Keypair.fromSecretKey(getSecretKey());
|
|
25
|
-
const [connection, _] = getSolanaRpcConnection(process.env.HELIUS_API_KEY ?? "");
|
|
25
|
+
const [connection, _] = getSolanaRpcConnection(buildHeliusApiUrl(process.env.HELIUS_API_KEY ?? ""));
|
|
26
26
|
|
|
27
27
|
async function createAndSendV0Tx(txInstructions: TransactionInstruction[]) {
|
|
28
28
|
let latestBlockhash = await connection.getLatestBlockhash("finalized");
|
package/package.json
CHANGED
|
@@ -21,8 +21,8 @@ export class ReferralStateManager extends TxHandler {
|
|
|
21
21
|
public referralState!: PublicKey;
|
|
22
22
|
public referralStateData!: ReferralState | null;
|
|
23
23
|
|
|
24
|
-
constructor(
|
|
25
|
-
super(
|
|
24
|
+
constructor(heliusApiUrl: string, public localTest?: boolean) {
|
|
25
|
+
super(heliusApiUrl, localTest)
|
|
26
26
|
this.umi = this.umi.use({
|
|
27
27
|
install(umi) {
|
|
28
28
|
umi.programs.add(createSolautoProgram(), false);
|
|
@@ -100,10 +100,10 @@ export abstract class SolautoClient extends TxHandler {
|
|
|
100
100
|
public livePositionUpdates: LivePositionUpdates = new LivePositionUpdates();
|
|
101
101
|
|
|
102
102
|
constructor(
|
|
103
|
-
|
|
103
|
+
heliusApiUrl: string,
|
|
104
104
|
public localTest?: boolean
|
|
105
105
|
) {
|
|
106
|
-
super(
|
|
106
|
+
super(heliusApiUrl, localTest);
|
|
107
107
|
|
|
108
108
|
this.umi = this.umi.use({
|
|
109
109
|
install(umi) {
|
|
@@ -164,7 +164,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
|
164
164
|
this.debtMint
|
|
165
165
|
);
|
|
166
166
|
|
|
167
|
-
this.referralStateManager = new ReferralStateManager(this.
|
|
167
|
+
this.referralStateManager = new ReferralStateManager(this.heliusApiUrl);
|
|
168
168
|
await this.referralStateManager.initialize({
|
|
169
169
|
referralAuthority: this.authority,
|
|
170
170
|
signer: args.signer,
|
package/src/clients/txHandler.ts
CHANGED
|
@@ -2,18 +2,19 @@ import { Umi } from "@metaplex-foundation/umi";
|
|
|
2
2
|
import { Connection } from "@solana/web3.js";
|
|
3
3
|
import { getSolanaRpcConnection } from "../utils";
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
export abstract class TxHandler {
|
|
7
|
-
public
|
|
6
|
+
public heliusApiUrl!: string;
|
|
8
7
|
public umi!: Umi;
|
|
9
8
|
public connection!: Connection;
|
|
10
9
|
|
|
11
|
-
constructor(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
constructor(
|
|
11
|
+
heliusApiUrl: string,
|
|
12
|
+
public localTest?: boolean
|
|
13
|
+
) {
|
|
14
|
+
this.heliusApiUrl = heliusApiUrl;
|
|
15
|
+
const [connection, umi] = getSolanaRpcConnection(this.heliusApiUrl);
|
|
16
|
+
this.connection = connection;
|
|
17
|
+
this.umi = umi;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
log(...args: any[]): void {
|
|
@@ -25,4 +26,4 @@ export abstract class TxHandler {
|
|
|
25
26
|
abstract defaultLookupTables(): string[];
|
|
26
27
|
|
|
27
28
|
abstract resetLiveTxUpdates(success?: boolean): Promise<void>;
|
|
28
|
-
}
|
|
29
|
+
}
|
|
@@ -8,7 +8,11 @@ import {
|
|
|
8
8
|
safeFetchBank,
|
|
9
9
|
safeFetchMarginfiAccount,
|
|
10
10
|
} from "../marginfi-sdk";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
currentUnixSeconds,
|
|
13
|
+
fetchTokenPrices,
|
|
14
|
+
safeGetPrice,
|
|
15
|
+
} from "./generalUtils";
|
|
12
16
|
import {
|
|
13
17
|
bytesToI80F48,
|
|
14
18
|
fromBaseUnit,
|
|
@@ -21,7 +25,6 @@ import { MarginfiAssetAccounts } from "../types/accounts";
|
|
|
21
25
|
import { PositionState, PositionTokenUsage } from "../generated";
|
|
22
26
|
import { USD_DECIMALS } from "../constants/generalAccounts";
|
|
23
27
|
import { LivePositionUpdates } from "./solauto/generalUtils";
|
|
24
|
-
import { currentUnixSecondsSolana } from "./solanaUtils";
|
|
25
28
|
|
|
26
29
|
export function findMarginfiAccounts(bank: PublicKey): MarginfiAssetAccounts {
|
|
27
30
|
for (const key in MARGINFI_ACCOUNTS) {
|
|
@@ -65,9 +68,7 @@ export async function getMaxLtvAndLiqThreshold(
|
|
|
65
68
|
) {
|
|
66
69
|
debt.bank = await safeFetchBank(
|
|
67
70
|
umi,
|
|
68
|
-
publicKey(
|
|
69
|
-
MARGINFI_ACCOUNTS[debt.mint.toString()].bank
|
|
70
|
-
),
|
|
71
|
+
publicKey(MARGINFI_ACCOUNTS[debt.mint.toString()].bank),
|
|
71
72
|
{ commitment: "confirmed" }
|
|
72
73
|
);
|
|
73
74
|
}
|
|
@@ -95,7 +96,7 @@ export async function getMaxLtvAndLiqThreshold(
|
|
|
95
96
|
BigInt(
|
|
96
97
|
Math.round(
|
|
97
98
|
bytesToI80F48(supply.bank!.totalAssetShares.value) *
|
|
98
|
-
|
|
99
|
+
bytesToI80F48(supply.bank!.assetShareValue.value)
|
|
99
100
|
)
|
|
100
101
|
),
|
|
101
102
|
supply.bank!.mintDecimals
|
|
@@ -153,6 +154,17 @@ export async function getAllMarginfiAccountsByAuthority(
|
|
|
153
154
|
}))
|
|
154
155
|
);
|
|
155
156
|
return positionStates
|
|
157
|
+
.sort(
|
|
158
|
+
(a, b) =>
|
|
159
|
+
fromBaseUnit(
|
|
160
|
+
b.state?.netWorth.baseAmountUsdValue ?? BigInt(0),
|
|
161
|
+
USD_DECIMALS
|
|
162
|
+
) -
|
|
163
|
+
fromBaseUnit(
|
|
164
|
+
a.state?.netWorth.baseAmountUsdValue ?? BigInt(0),
|
|
165
|
+
USD_DECIMALS
|
|
166
|
+
)
|
|
167
|
+
)
|
|
156
168
|
.filter((x) => x.state !== undefined)
|
|
157
169
|
.map((x) => ({
|
|
158
170
|
marginfiAccount: toWeb3JsPublicKey(x.publicKey),
|
|
@@ -191,7 +203,7 @@ async function getTokenUsage(
|
|
|
191
203
|
amountCanBeUsed = isAsset
|
|
192
204
|
? Number(bank.config.depositLimit) - totalDeposited
|
|
193
205
|
: totalDeposited -
|
|
194
|
-
|
|
206
|
+
bytesToI80F48(bank.totalLiabilityShares.value) * liabilityShareValue;
|
|
195
207
|
}
|
|
196
208
|
|
|
197
209
|
return {
|
|
@@ -201,22 +213,22 @@ async function getTokenUsage(
|
|
|
201
213
|
baseUnit: BigInt(Math.round(amountUsed)),
|
|
202
214
|
baseAmountUsdValue: bank
|
|
203
215
|
? toBaseUnit(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
216
|
+
fromBaseUnit(BigInt(Math.round(amountUsed)), bank.mintDecimals) *
|
|
217
|
+
marketPrice,
|
|
218
|
+
USD_DECIMALS
|
|
219
|
+
)
|
|
208
220
|
: BigInt(0),
|
|
209
221
|
},
|
|
210
222
|
amountCanBeUsed: {
|
|
211
223
|
baseUnit: BigInt(Math.round(amountCanBeUsed)),
|
|
212
224
|
baseAmountUsdValue: bank
|
|
213
225
|
? toBaseUnit(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
226
|
+
fromBaseUnit(
|
|
227
|
+
BigInt(Math.round(amountCanBeUsed)),
|
|
228
|
+
bank.mintDecimals
|
|
229
|
+
) * marketPrice,
|
|
230
|
+
USD_DECIMALS
|
|
231
|
+
)
|
|
220
232
|
: BigInt(0),
|
|
221
233
|
},
|
|
222
234
|
baseAmountMarketPriceUsd: toBaseUnit(marketPrice, USD_DECIMALS),
|
|
@@ -244,18 +256,18 @@ export async function getMarginfiAccountPositionState(
|
|
|
244
256
|
let supplyBank: Bank | null =
|
|
245
257
|
supplyMint && supplyMint !== PublicKey.default
|
|
246
258
|
? await safeFetchBank(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
259
|
+
umi,
|
|
260
|
+
publicKey(MARGINFI_ACCOUNTS[supplyMint.toString()].bank),
|
|
261
|
+
{ commitment: "confirmed" }
|
|
262
|
+
)
|
|
251
263
|
: null;
|
|
252
264
|
let debtBank: Bank | null =
|
|
253
265
|
debtMint && debtMint !== PublicKey.default
|
|
254
266
|
? await safeFetchBank(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
267
|
+
umi,
|
|
268
|
+
publicKey(MARGINFI_ACCOUNTS[debtMint.toString()].bank),
|
|
269
|
+
{ commitment: "confirmed" }
|
|
270
|
+
)
|
|
259
271
|
: null;
|
|
260
272
|
|
|
261
273
|
let supplyUsage: PositionTokenUsage | undefined = undefined;
|
|
@@ -281,7 +293,9 @@ export async function getMarginfiAccountPositionState(
|
|
|
281
293
|
|
|
282
294
|
if (supplyBalances.length > 0) {
|
|
283
295
|
if (supplyBank === null) {
|
|
284
|
-
supplyBank = await safeFetchBank(umi, supplyBalances[0].bankPk, {
|
|
296
|
+
supplyBank = await safeFetchBank(umi, supplyBalances[0].bankPk, {
|
|
297
|
+
commitment: "confirmed",
|
|
298
|
+
});
|
|
285
299
|
}
|
|
286
300
|
if (!supplyMint) {
|
|
287
301
|
supplyMint = toWeb3JsPublicKey(supplyBank!.mint);
|
|
@@ -297,7 +311,9 @@ export async function getMarginfiAccountPositionState(
|
|
|
297
311
|
|
|
298
312
|
if (debtBalances.length > 0) {
|
|
299
313
|
if (debtBank === null) {
|
|
300
|
-
debtBank = await safeFetchBank(umi, debtBalances[0].bankPk, {
|
|
314
|
+
debtBank = await safeFetchBank(umi, debtBalances[0].bankPk, {
|
|
315
|
+
commitment: "confirmed",
|
|
316
|
+
});
|
|
301
317
|
}
|
|
302
318
|
if (!debtMint) {
|
|
303
319
|
debtMint = toWeb3JsPublicKey(debtBank!.mint);
|
|
@@ -447,8 +463,7 @@ export async function getUpToDateShareValues(
|
|
|
447
463
|
umi: Umi,
|
|
448
464
|
bank: Bank
|
|
449
465
|
): Promise<[number, number]> {
|
|
450
|
-
|
|
451
|
-
let timeDelta = currentTime - Number(bank.lastUpdate);
|
|
466
|
+
let timeDelta = currentUnixSeconds() - Number(bank.lastUpdate);
|
|
452
467
|
|
|
453
468
|
const totalAssets =
|
|
454
469
|
bytesToI80F48(bank.totalAssetShares.value) *
|
package/src/utils/solanaUtils.ts
CHANGED
|
@@ -38,27 +38,18 @@ import {
|
|
|
38
38
|
} from "../marginfi-sdk";
|
|
39
39
|
import { PriorityFeeSetting, TransactionRunType } from "../types";
|
|
40
40
|
|
|
41
|
+
export function buildHeliusApiUrl(heliusApiKey: string) {
|
|
42
|
+
return `https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
41
45
|
export function getSolanaRpcConnection(
|
|
42
|
-
|
|
46
|
+
heliusApiUrl: string
|
|
43
47
|
): [Connection, Umi] {
|
|
44
|
-
const connection = new Connection(
|
|
45
|
-
`https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`,
|
|
46
|
-
"confirmed"
|
|
47
|
-
);
|
|
48
|
+
const connection = new Connection(heliusApiUrl, "confirmed");
|
|
48
49
|
const umi = createUmi(connection);
|
|
49
50
|
return [connection, umi];
|
|
50
51
|
}
|
|
51
52
|
|
|
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
53
|
export function getWrappedInstruction(
|
|
63
54
|
signer: Signer,
|
|
64
55
|
ix: TransactionInstruction
|
|
@@ -316,7 +307,7 @@ export async function sendSingleOptimizedTransaction(
|
|
|
316
307
|
),
|
|
317
308
|
3
|
|
318
309
|
);
|
|
319
|
-
|
|
310
|
+
|
|
320
311
|
const computeUnitLimit = Math.round(
|
|
321
312
|
simulationResult.value.unitsConsumed! * 1.1
|
|
322
313
|
);
|
|
@@ -338,7 +329,7 @@ export async function sendSingleOptimizedTransaction(
|
|
|
338
329
|
confirm: { commitment: "confirmed" },
|
|
339
330
|
});
|
|
340
331
|
const txSig = bs58.encode(result.signature);
|
|
341
|
-
console.log(`Transaction signature: ${txSig}`)
|
|
332
|
+
console.log(`Transaction signature: ${txSig}`);
|
|
342
333
|
console.log(`https://solscan.io/tx/${txSig}`);
|
|
343
334
|
if (result.result.value.err !== null) {
|
|
344
335
|
throw new Error(result.result.value.err.toString());
|
|
@@ -18,18 +18,19 @@ import {
|
|
|
18
18
|
} from "../../src/transactions/transactionsManager";
|
|
19
19
|
import { PublicKey } from "@solana/web3.js";
|
|
20
20
|
import { USDC_MINT } from "../../src/constants";
|
|
21
|
+
import { buildHeliusApiUrl } from "../../src/utils";
|
|
21
22
|
|
|
22
23
|
describe("Solauto Marginfi tests", async () => {
|
|
23
24
|
// const signer = setupTest();
|
|
24
25
|
const signer = setupTest("solauto-manager");
|
|
25
26
|
|
|
26
|
-
const payForTransactions =
|
|
27
|
+
const payForTransactions = false;
|
|
27
28
|
const useJitoBundle = false;
|
|
28
29
|
const positionId = 1;
|
|
29
30
|
|
|
30
31
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
|
31
32
|
|
|
32
|
-
const client = new SolautoMarginfiClient(process.env.HELIUS_API_KEY
|
|
33
|
+
const client = new SolautoMarginfiClient(buildHeliusApiUrl(process.env.HELIUS_API_KEY!), true);
|
|
33
34
|
|
|
34
35
|
const supply = NATIVE_MINT;
|
|
35
36
|
const supplyDecimals = 9;
|
|
@@ -39,7 +40,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
|
39
40
|
{
|
|
40
41
|
signer,
|
|
41
42
|
positionId,
|
|
42
|
-
authority: new PublicKey("
|
|
43
|
+
authority: new PublicKey("AprYCPiVeKMCgjQ2ZufwChMzvQ5kFjJo2ekTLSkXsQDm")
|
|
43
44
|
// marginfiAccount: new PublicKey(
|
|
44
45
|
// "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
|
|
45
46
|
// ),
|