@haven-fi/solauto-sdk 1.0.650 → 1.0.652
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/solautoPosition/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAK/C,OAAO,EAEL,aAAa,EAGb,yBAAyB,EACzB,gCAAgC,EACjC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,cAAc,EAQf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/solautoPosition/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAK/C,OAAO,EAEL,aAAa,EAGb,yBAAyB,EACzB,gCAAgC,EACjC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,cAAc,EAQf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAI5E,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,gCAAgC,GACzC,yBAAyB,CAQ3B;AAED,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,SAAS,EAAE,GACtB,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA4B9B;AAED,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,UAAU,CAAC,EAAE,kBAAkB,EAC/B,cAAc,CAAC,EAAE,cAAc,GAC9B,OAAO,CAAC,iBAAiB,CAAC,CAsC5B;AAED,UAAU,UAAU;IAClB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GACtB,aAAa,CAgEf"}
|
@@ -4,7 +4,6 @@ exports.createSolautoSettings = createSolautoSettings;
|
|
4
4
|
exports.getPositionExBulk = getPositionExBulk;
|
5
5
|
exports.getOrCreatePositionEx = getOrCreatePositionEx;
|
6
6
|
exports.createFakePositionState = createFakePositionState;
|
7
|
-
const web3_js_1 = require("@solana/web3.js");
|
8
7
|
const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
|
9
8
|
const generated_1 = require("../generated");
|
10
9
|
const utils_1 = require("../utils");
|
@@ -37,9 +36,12 @@ async function getPositionExBulk(umi, publicKeys) {
|
|
37
36
|
}
|
38
37
|
async function getOrCreatePositionEx(umi, publicKey, customArgs, contextUpdates) {
|
39
38
|
const data = await (0, generated_1.safeFetchSolautoPosition)(umi, (0, umi_web3js_adapters_1.fromWeb3JsPublicKey)(publicKey));
|
39
|
+
if (!data && (!customArgs?.supplyMint || !customArgs.debtMint)) {
|
40
|
+
throw new Error("Must provide a supply & debt mint if creating a new position");
|
41
|
+
}
|
40
42
|
const placeholderState = createFakePositionState({
|
41
|
-
mint: customArgs
|
42
|
-
}, { mint: customArgs
|
43
|
+
mint: customArgs.supplyMint,
|
44
|
+
}, { mint: customArgs.debtMint }, 0, 0);
|
43
45
|
const lendingPlatform = data
|
44
46
|
? data.position.lendingPlatform
|
45
47
|
: customArgs.lendingPlatform;
|
package/local/txSandbox.ts
CHANGED
@@ -13,8 +13,10 @@ import {
|
|
13
13
|
SOLAUTO_PROD_PROGRAM,
|
14
14
|
SOLAUTO_TEST_PROGRAM,
|
15
15
|
TransactionsManager,
|
16
|
+
USDC,
|
16
17
|
} from "../src";
|
17
18
|
import { getSecretKey } from "./shared";
|
19
|
+
import { NATIVE_MINT } from "@solana/spl-token";
|
18
20
|
|
19
21
|
const payForTransaction = false;
|
20
22
|
const testProgram = true;
|
@@ -29,7 +31,7 @@ export async function main() {
|
|
29
31
|
|
30
32
|
const signer = createSignerFromKeypair(
|
31
33
|
umi,
|
32
|
-
fromWeb3JsKeypair(Keypair.fromSecretKey(getSecretKey(
|
34
|
+
fromWeb3JsKeypair(Keypair.fromSecretKey(getSecretKey()))
|
33
35
|
);
|
34
36
|
|
35
37
|
const client = getClient(LendingPlatform.Marginfi, {
|
@@ -41,24 +43,25 @@ export async function main() {
|
|
41
43
|
});
|
42
44
|
|
43
45
|
await client.initialize({
|
44
|
-
positionId:
|
45
|
-
|
46
|
+
positionId: 5,
|
47
|
+
supplyMint: NATIVE_MINT,
|
48
|
+
debtMint: new PublicKey(USDC)
|
46
49
|
});
|
47
50
|
|
48
|
-
const transactionItems = [rebalance(client)];
|
51
|
+
// const transactionItems = [rebalance(client)];
|
49
52
|
|
50
|
-
const txManager = new TransactionsManager(
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
);
|
59
|
-
const statuses = await txManager.clientSend(transactionItems);
|
53
|
+
// const txManager = new TransactionsManager(
|
54
|
+
// client,
|
55
|
+
// undefined,
|
56
|
+
// payForTransaction ? "normal" : "only-simulate",
|
57
|
+
// PriorityFeeSetting.Min,
|
58
|
+
// true,
|
59
|
+
// undefined,
|
60
|
+
// { totalRetries: 5 }
|
61
|
+
// );
|
62
|
+
// const statuses = await txManager.clientSend(transactionItems);
|
60
63
|
|
61
|
-
consoleLog(statuses);
|
64
|
+
// consoleLog(statuses);
|
62
65
|
}
|
63
66
|
|
64
67
|
main();
|
package/package.json
CHANGED
@@ -24,6 +24,7 @@ import {
|
|
24
24
|
} from "../utils";
|
25
25
|
import { PositionCustomArgs, SolautoPositionEx } from "./solautoPositionEx";
|
26
26
|
import { MarginfiSolautoPositionEx } from "./marginfiSolautoPositionEx";
|
27
|
+
import { assert } from "console";
|
27
28
|
|
28
29
|
export function createSolautoSettings(
|
29
30
|
settings: SolautoSettingsParametersInpArgs
|
@@ -81,11 +82,17 @@ export async function getOrCreatePositionEx(
|
|
81
82
|
fromWeb3JsPublicKey(publicKey)
|
82
83
|
);
|
83
84
|
|
85
|
+
if (!data && (!customArgs?.supplyMint || !customArgs.debtMint)) {
|
86
|
+
throw new Error(
|
87
|
+
"Must provide a supply & debt mint if creating a new position"
|
88
|
+
);
|
89
|
+
}
|
90
|
+
|
84
91
|
const placeholderState = createFakePositionState(
|
85
92
|
{
|
86
|
-
mint: customArgs
|
93
|
+
mint: customArgs!.supplyMint!,
|
87
94
|
},
|
88
|
-
{ mint: customArgs
|
95
|
+
{ mint: customArgs!.debtMint! },
|
89
96
|
0,
|
90
97
|
0
|
91
98
|
);
|