@haven-fi/solauto-sdk 1.0.15 → 1.0.17
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/solautoMarginfiClient.d.ts +1 -1
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +6 -3
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +1 -2
- package/package.json +1 -1
- package/src/clients/solautoMarginfiClient.ts +9 -1
- package/src/transactions/transactionsManager.ts +1 -2
- package/tests/transactions/solautoMarginfi.ts +6 -4
@@ -12,7 +12,7 @@ export interface SolautoMarginfiClientArgs extends SolautoClientArgs {
|
|
12
12
|
marginfiAccountSeedIdx?: bigint;
|
13
13
|
marginfiGroup?: PublicKey;
|
14
14
|
}
|
15
|
-
export declare function
|
15
|
+
export declare function newSolautoMarginfiPositionArgs(positionId: number, signer: Signer | undefined, wallet: WalletAdapter | undefined, supplyMint: PublicKey, debtMint: PublicKey, referredByAuthority?: PublicKey): SolautoMarginfiClientArgs;
|
16
16
|
export declare class SolautoMarginfiClient extends SolautoClient {
|
17
17
|
marginfiProgram: PublicKey;
|
18
18
|
marginfiAccountSeedIdx?: bigint;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,MAAM,EACN,kBAAkB,
|
1
|
+
{"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,MAAM,EACN,kBAAkB,EAOnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,SAAS,EAEV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAK1D,OAAO,EACL,kB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,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA2C9B,OAAO,IAAI,kBAAkB;IAc7B,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAMhE,OAAO,CAAC,6BAA6B;IA8DrC,SAAS,CACP,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IA4CrB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IA8ElE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAiBlE"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.SolautoMarginfiClient = exports.
|
3
|
+
exports.SolautoMarginfiClient = exports.newSolautoMarginfiPositionArgs = void 0;
|
4
4
|
const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
|
5
5
|
const umi_1 = require("@metaplex-foundation/umi");
|
6
6
|
const web3_js_1 = require("@solana/web3.js");
|
@@ -12,18 +12,21 @@ const generalUtils_1 = require("../utils/generalUtils");
|
|
12
12
|
const marginfi_sdk_1 = require("../marginfi-sdk");
|
13
13
|
const marginfiUtils_1 = require("../utils/marginfiUtils");
|
14
14
|
const numberUtils_1 = require("../utils/numberUtils");
|
15
|
-
function
|
15
|
+
function newSolautoMarginfiPositionArgs(positionId, signer, wallet, supplyMint, debtMint, referredByAuthority) {
|
16
16
|
return {
|
17
17
|
positionId,
|
18
18
|
signer,
|
19
19
|
wallet,
|
20
|
+
marginfiAccount: positionId === 0
|
21
|
+
? (0, umi_1.createSignerFromKeypair)((0, umi_1.createUmi)(), (0, umi_web3js_adapters_1.fromWeb3JsKeypair)(web3_js_1.Keypair.generate()))
|
22
|
+
: undefined,
|
20
23
|
marginfiAccountSeedIdx: positionId > 0 ? (0, generalUtils_1.generateRandomU64)() : undefined,
|
21
24
|
supplyMint: supplyMint,
|
22
25
|
debtMint: debtMint,
|
23
26
|
referredByAuthority,
|
24
27
|
};
|
25
28
|
}
|
26
|
-
exports.
|
29
|
+
exports.newSolautoMarginfiPositionArgs = newSolautoMarginfiPositionArgs;
|
27
30
|
class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
28
31
|
async initialize(args) {
|
29
32
|
if (args.marginfiAccount) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;
|
1
|
+
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAwCzD,qBAAa,eAAe;IAKjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CACV;QAAE,EAAE,EAAE,kBAAkB,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CACxE;IACM,IAAI,CAAC;IATd,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;gBAGf,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CACV;QAAE,EAAE,EAAE,kBAAkB,CAAC;QAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CACxE,EACM,IAAI,CAAC,oBAAQ;IAGhB,UAAU;IAIV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AAgFD,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;CAC1B;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EAAE,CAAC;AAEJ,qBAAa,mBAAmB;IAK5B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,YAAY,CAAC;IACrB,OAAO,CAAC,YAAY,CAAC;IARvB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;gBAGzB,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,eAAe,EAAE,EACxB,cAAc,CAAC,6CAA4C,IAAI,aAAA,EAC/D,YAAY,CAAC,qBAAS,EACtB,YAAY,CAAC,qBAAS;YAKlB,uBAAuB;IAsCrC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM;IAgB9D,IAAI;CAuIX"}
|
@@ -16,12 +16,11 @@ class LookupTables {
|
|
16
16
|
this.defaultLuts = [];
|
17
17
|
this.cache = [];
|
18
18
|
this.defaultLuts = [
|
19
|
-
client.authorityLutAddress.toString(),
|
20
19
|
...client.defaultLookupTables(),
|
21
20
|
];
|
22
21
|
}
|
23
22
|
async getLutInputs(additionalAddresses) {
|
24
|
-
const addresses = [...this.defaultLuts, ...additionalAddresses];
|
23
|
+
const addresses = [...this.defaultLuts, this.client.authorityLutAddress.toString(), ...additionalAddresses];
|
25
24
|
const currentCacheAddresses = this.cache.map((x) => x.publicKey.toString());
|
26
25
|
const missingAddresses = addresses.filter((x) => !currentCacheAddresses.includes(x));
|
27
26
|
if (missingAddresses) {
|
package/package.json
CHANGED
@@ -11,6 +11,7 @@ import {
|
|
11
11
|
transactionBuilder,
|
12
12
|
createSignerFromKeypair,
|
13
13
|
AccountMeta,
|
14
|
+
createUmi,
|
14
15
|
} from "@metaplex-foundation/umi";
|
15
16
|
import {
|
16
17
|
Keypair,
|
@@ -64,7 +65,7 @@ export interface SolautoMarginfiClientArgs extends SolautoClientArgs {
|
|
64
65
|
marginfiGroup?: PublicKey;
|
65
66
|
}
|
66
67
|
|
67
|
-
export function
|
68
|
+
export function newSolautoMarginfiPositionArgs(
|
68
69
|
positionId: number,
|
69
70
|
signer: Signer | undefined,
|
70
71
|
wallet: WalletAdapter | undefined,
|
@@ -76,6 +77,13 @@ export function newMarginfiSolautoManagedPositionArgs(
|
|
76
77
|
positionId,
|
77
78
|
signer,
|
78
79
|
wallet,
|
80
|
+
marginfiAccount:
|
81
|
+
positionId === 0
|
82
|
+
? createSignerFromKeypair(
|
83
|
+
createUmi(),
|
84
|
+
fromWeb3JsKeypair(Keypair.generate())
|
85
|
+
)
|
86
|
+
: undefined,
|
79
87
|
marginfiAccountSeedIdx: positionId > 0 ? generateRandomU64() : undefined,
|
80
88
|
supplyMint: supplyMint,
|
81
89
|
debtMint: debtMint,
|
@@ -19,7 +19,6 @@ class LookupTables {
|
|
19
19
|
|
20
20
|
constructor(private client: SolautoClient) {
|
21
21
|
this.defaultLuts = [
|
22
|
-
client.authorityLutAddress!.toString(),
|
23
22
|
...client.defaultLookupTables(),
|
24
23
|
];
|
25
24
|
}
|
@@ -27,7 +26,7 @@ class LookupTables {
|
|
27
26
|
async getLutInputs(
|
28
27
|
additionalAddresses: string[]
|
29
28
|
): Promise<AddressLookupTableInput[]> {
|
30
|
-
const addresses = [...this.defaultLuts, ...additionalAddresses];
|
29
|
+
const addresses = [...this.defaultLuts, this.client.authorityLutAddress!.toString(), ...additionalAddresses];
|
31
30
|
const currentCacheAddresses = this.cache.map((x) => x.publicKey.toString());
|
32
31
|
|
33
32
|
const missingAddresses = addresses.filter(
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { describe, it } from
|
1
|
+
import { describe, it } from "mocha";
|
2
2
|
import { none, some } from "@metaplex-foundation/umi";
|
3
3
|
import { setupTest } from "../shared";
|
4
4
|
import {
|
5
5
|
SolautoMarginfiClient,
|
6
|
-
|
6
|
+
newSolautoMarginfiPositionArgs,
|
7
7
|
} from "../../src/clients/solautoMarginfiClient";
|
8
8
|
import {
|
9
9
|
solautoAction,
|
@@ -17,6 +17,8 @@ import {
|
|
17
17
|
TransactionItem,
|
18
18
|
TransactionsManager,
|
19
19
|
} from "../../src/transactions/transactionsManager";
|
20
|
+
import { PublicKey } from "@solana/web3.js";
|
21
|
+
import { USDC_MINT } from "../../src/constants";
|
20
22
|
|
21
23
|
describe("Solauto Marginfi tests", async () => {
|
22
24
|
const signer = setupTest();
|
@@ -33,12 +35,12 @@ describe("Solauto Marginfi tests", async () => {
|
|
33
35
|
const debtDecimals = 6;
|
34
36
|
|
35
37
|
await client.initialize(
|
36
|
-
//
|
38
|
+
// newSolautoMarginfiPositionArgs(
|
37
39
|
// positionId,
|
38
40
|
// signer,
|
39
41
|
// undefined,
|
40
42
|
// supply,
|
41
|
-
//
|
43
|
+
// new PublicKey(USDC_MINT)
|
42
44
|
// )
|
43
45
|
{
|
44
46
|
signer,
|