@haven-fi/solauto-sdk 1.0.605 → 1.0.606
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/services/flashLoans/flProviderAggregator.d.ts +1 -1
- package/dist/services/flashLoans/flProviderAggregator.d.ts.map +1 -1
- package/dist/services/flashLoans/flProviderAggregator.js +10 -7
- package/dist/services/flashLoans/flProviderBase.d.ts +2 -1
- package/dist/services/flashLoans/flProviderBase.d.ts.map +1 -1
- package/dist/services/flashLoans/flProviderBase.js +2 -1
- package/dist/services/rebalance/rebalanceTxBuilder.d.ts.map +1 -1
- package/dist/services/rebalance/rebalanceTxBuilder.js +1 -1
- package/dist/services/solauto/solautoClient.d.ts.map +1 -1
- package/dist/services/solauto/solautoClient.js +1 -1
- package/local/txSandbox.ts +10 -8
- package/package.json +1 -1
- package/src/services/flashLoans/flProviderAggregator.ts +10 -5
- package/src/services/flashLoans/flProviderBase.ts +1 -0
- package/src/services/rebalance/rebalanceTxBuilder.ts +1 -1
- package/src/services/solauto/solautoClient.ts +1 -0
@@ -5,7 +5,7 @@ import { Signer, TransactionBuilder, Umi } from "@metaplex-foundation/umi";
|
|
5
5
|
import { TokenType } from "../../generated";
|
6
6
|
export declare class FlProviderAggregator extends FlProviderBase {
|
7
7
|
private marginfiFlProvider;
|
8
|
-
constructor(umi: Umi, signer: Signer, supplyMint: PublicKey, debtMint: PublicKey);
|
8
|
+
constructor(umi: Umi, signer: Signer, authority: PublicKey, supplyMint: PublicKey, debtMint: PublicKey);
|
9
9
|
initialize(): Promise<void>;
|
10
10
|
flAccountPrereqIxs(): Promise<TransactionBuilder>;
|
11
11
|
otherSigners(): Signer[];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"flProviderAggregator.d.ts","sourceRoot":"","sources":["../../../src/services/flashLoans/flProviderAggregator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,E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+3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FlProviderAggregator = void 0;
|
4
4
|
const flProviderBase_1 = require("./flProviderBase");
|
5
5
|
const marginfiFlProvider_1 = require("./marginfiFlProvider");
|
6
|
+
const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
|
6
7
|
class FlProviderAggregator extends flProviderBase_1.FlProviderBase {
|
7
|
-
constructor(umi, signer, supplyMint, debtMint) {
|
8
|
-
super(umi, signer, supplyMint, debtMint);
|
9
|
-
this.marginfiFlProvider = new marginfiFlProvider_1.MarginfiFlProvider(umi, signer, supplyMint, debtMint);
|
8
|
+
constructor(umi, signer, authority, supplyMint, debtMint) {
|
9
|
+
super(umi, signer, authority, supplyMint, debtMint);
|
10
|
+
this.marginfiFlProvider = new marginfiFlProvider_1.MarginfiFlProvider(umi, signer, authority, supplyMint, debtMint);
|
10
11
|
}
|
11
12
|
async initialize() {
|
12
13
|
// TODO: PF
|
@@ -21,10 +22,12 @@ class FlProviderAggregator extends flProviderBase_1.FlProviderBase {
|
|
21
22
|
return [...this.flSigners, ...this.marginfiFlProvider.otherSigners()];
|
22
23
|
}
|
23
24
|
lutAccountsToAdd() {
|
24
|
-
return
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
return (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey).equals(this.authority)
|
26
|
+
? [
|
27
|
+
...super.lutAccountsToAdd(),
|
28
|
+
...this.marginfiFlProvider.lutAccountsToAdd(),
|
29
|
+
]
|
30
|
+
: [];
|
28
31
|
}
|
29
32
|
flProvider(source) {
|
30
33
|
// TODO: PF
|
@@ -5,10 +5,11 @@ import { FlashLoanDetails } from "../../types";
|
|
5
5
|
export declare abstract class FlProviderBase {
|
6
6
|
protected umi: Umi;
|
7
7
|
protected signer: Signer;
|
8
|
+
protected authority: PublicKey;
|
8
9
|
protected supplyMint: PublicKey;
|
9
10
|
protected debtMint: PublicKey;
|
10
11
|
protected flSigners: Signer[];
|
11
|
-
constructor(umi: Umi, signer: Signer, supplyMint: PublicKey, debtMint: PublicKey);
|
12
|
+
constructor(umi: Umi, signer: Signer, authority: PublicKey, supplyMint: PublicKey, debtMint: PublicKey);
|
12
13
|
abstract initialize(): Promise<void>;
|
13
14
|
lutAccountsToAdd(): PublicKey[];
|
14
15
|
otherSigners(): Signer[];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"flProviderBase.d.ts","sourceRoot":"","sources":["../../../src/services/flashLoans/flProviderBase.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAEN,kBAAkB,EAClB,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQ5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,8BAAsB,cAAc;IAIhC,SAAS,CAAC,GAAG,EAAE,GAAG;IAClB,SAAS,CAAC,MAAM,EAAE,MAAM;IACxB,SAAS,CAAC,UAAU,EAAE,SAAS;IAC/B,SAAS,CAAC,QAAQ,EAAE,SAAS;
|
1
|
+
{"version":3,"file":"flProviderBase.d.ts","sourceRoot":"","sources":["../../../src/services/flashLoans/flProviderBase.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAEN,kBAAkB,EAClB,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQ5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,8BAAsB,cAAc;IAIhC,SAAS,CAAC,GAAG,EAAE,GAAG;IAClB,SAAS,CAAC,MAAM,EAAE,MAAM;IACxB,SAAS,CAAC,SAAS,EAAE,SAAS;IAC9B,SAAS,CAAC,UAAU,EAAE,SAAS;IAC/B,SAAS,CAAC,QAAQ,EAAE,SAAS;IAP/B,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,CAAM;gBAGvB,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,SAAS,EACrB,QAAQ,EAAE,SAAS;IAG/B,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAEpC,gBAAgB,IAAI,SAAS,EAAE;IAI/B,YAAY,IAAI,MAAM,EAAE;IAIxB,IAAI,CAAC,MAAM,EAAE,SAAS;IAItB,QAAQ,CAAC,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM;IACtD,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM;IAShD,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM;IACvE,QAAQ,CAAC,WAAW,CAClB,SAAS,EAAE,gBAAgB,EAC3B,gBAAgB,EAAE,SAAS,GAC1B,kBAAkB;IACrB,QAAQ,CAAC,UAAU,CAAC,SAAS,EAAE,gBAAgB,GAAG,kBAAkB;IAEpE,SAAS,CAAC,iBAAiB,CACzB,SAAS,EAAE,gBAAgB,EAC3B,gBAAgB,EAAE,SAAS,GAC1B,kBAAkB;CAyBtB"}
|
@@ -6,9 +6,10 @@ const utils_1 = require("../../utils");
|
|
6
6
|
const generated_1 = require("../../generated");
|
7
7
|
const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
|
8
8
|
class FlProviderBase {
|
9
|
-
constructor(umi, signer, supplyMint, debtMint) {
|
9
|
+
constructor(umi, signer, authority, supplyMint, debtMint) {
|
10
10
|
this.umi = umi;
|
11
11
|
this.signer = signer;
|
12
|
+
this.authority = authority;
|
12
13
|
this.supplyMint = supplyMint;
|
13
14
|
this.debtMint = debtMint;
|
14
15
|
this.flSigners = [];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rebalanceTxBuilder.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/rebalanceTxBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAGL,qBAAqB,EACtB,MAAM,aAAa,CAAC;AA2BrB,qBAAa,kBAAkB;IAO3B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,2BAA2B,CAAC;IAPtC,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,aAAa,CAAwB;IAC7C,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,cAAc,CAAC,CAAwB;gBAGrC,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,YAAA;
|
1
|
+
{"version":3,"file":"rebalanceTxBuilder.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/rebalanceTxBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAGL,qBAAqB,EACtB,MAAM,aAAa,CAAC;AA2BrB,qBAAa,kBAAkB;IAO3B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,2BAA2B,CAAC;IAPtC,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,aAAa,CAAwB;IAC7C,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,cAAc,CAAC,CAAwB;gBAGrC,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,YAAA;IAG9C,OAAO,CAAC,0BAA0B;IAQlC,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,oBAAoB;YAyCd,qBAAqB;IAyCnC,OAAO,CAAC,mBAAmB;IAwB3B,OAAO,CAAC,gBAAgB;YAgCV,mBAAmB;YAoBnB,sBAAsB;YAyBtB,mBAAmB;IAkEpB,gBAAgB,CAC3B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;CAW9C"}
|
@@ -14,7 +14,7 @@ class RebalanceTxBuilder {
|
|
14
14
|
this.client = client;
|
15
15
|
this.targetLiqUtilizationRateBps = targetLiqUtilizationRateBps;
|
16
16
|
}
|
17
|
-
|
17
|
+
shouldProceedWithRebalance() {
|
18
18
|
return (this.client.pos.supplyUsd() > 0 &&
|
19
19
|
(this.targetLiqUtilizationRateBps !== undefined ||
|
20
20
|
this.client.pos.eligibleForRebalance()));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../../src/services/solauto/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAEL,SAAS,EAGV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,gCAAgC,EAEhC,sBAAsB,EAGvB,MAAM,iBAAiB,CAAC;AAWzB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,8BAAsB,aAAc,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Ac,IAAI,OAAO,CAAC;QAC9B,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IA8CF,cAAc,CACZ,QAAQ,CAAC,EAAE,gCAAgC,EAC3C,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IA0BrB,gBAAgB,CAAC,IAAI,EAAE,sBAAsB,GAAG,kBAAkB;IAsDlE,QAAQ,CAAC,eAAe,IAAI,kBAAkB;IAE9C,WAAW,IAAI,kBAAkB;IAgCjC,QAAQ,CAAC,SAAS,IAAI,kBAAkB;IAExC,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAsFlE,QAAQ,CAAC,WAAW,CAClB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,gBAAgB,GACrB,kBAAkB;CACtB"}
|
@@ -46,7 +46,7 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
|
|
46
46
|
!(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.referralStateData.lookupTable).equals(web3_js_1.PublicKey.default)
|
47
47
|
? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.referralStateData.lookupTable)
|
48
48
|
: undefined;
|
49
|
-
this.flProvider = new flProviderAggregator_1.FlProviderAggregator(this.umi, this.signer, this.pos.supplyMint(), this.pos.debtMint());
|
49
|
+
this.flProvider = new flProviderAggregator_1.FlProviderAggregator(this.umi, this.signer, this.authority, this.pos.supplyMint(), this.pos.debtMint());
|
50
50
|
await this.flProvider.initialize();
|
51
51
|
this.otherSigners.push(...this.flProvider.otherSigners());
|
52
52
|
this.log("Position state: ", this.pos.state());
|
package/local/txSandbox.ts
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
import { Keypair } from "@solana/web3.js";
|
1
|
+
import { Keypair, PublicKey } from "@solana/web3.js";
|
2
2
|
import {
|
3
3
|
buildIronforgeApiUrl,
|
4
4
|
consoleLog,
|
5
5
|
getClient,
|
6
6
|
getSolanaRpcConnection,
|
7
7
|
LendingPlatform,
|
8
|
+
PriorityFeeSetting,
|
9
|
+
RebalanceTxBuilder,
|
8
10
|
SOLAUTO_PROD_PROGRAM,
|
9
11
|
SOLAUTO_TEST_PROGRAM,
|
10
12
|
TransactionItem,
|
@@ -14,7 +16,7 @@ import { getSecretKey } from "./shared";
|
|
14
16
|
import { createSignerFromKeypair } from "@metaplex-foundation/umi";
|
15
17
|
import { fromWeb3JsKeypair } from "@metaplex-foundation/umi-web3js-adapters";
|
16
18
|
|
17
|
-
const payForTransaction =
|
19
|
+
const payForTransaction = true;
|
18
20
|
const testProgram = true;
|
19
21
|
|
20
22
|
export async function main() {
|
@@ -25,7 +27,7 @@ export async function main() {
|
|
25
27
|
|
26
28
|
const signer = createSignerFromKeypair(
|
27
29
|
umi,
|
28
|
-
fromWeb3JsKeypair(Keypair.fromSecretKey(getSecretKey()))
|
30
|
+
fromWeb3JsKeypair(Keypair.fromSecretKey(getSecretKey("solauto-manager")))
|
29
31
|
);
|
30
32
|
|
31
33
|
const client = getClient(LendingPlatform.Marginfi, {
|
@@ -37,16 +39,16 @@ export async function main() {
|
|
37
39
|
|
38
40
|
await client.initialize({
|
39
41
|
positionId: 1,
|
42
|
+
authority: new PublicKey("5UqsR2PGzbP8pGPbXEeXx86Gjz2N2UFBAuFZUSVydAEe"),
|
40
43
|
});
|
41
44
|
|
42
45
|
const transactionItems: TransactionItem[] = [];
|
43
46
|
|
44
47
|
transactionItems.push(
|
45
48
|
new TransactionItem(
|
46
|
-
async () =>
|
47
|
-
|
48
|
-
|
49
|
-
"close position"
|
49
|
+
async (attemptNum) =>
|
50
|
+
await new RebalanceTxBuilder(client).buildRebalanceTx(attemptNum),
|
51
|
+
"rebalance"
|
50
52
|
)
|
51
53
|
);
|
52
54
|
|
@@ -54,7 +56,7 @@ export async function main() {
|
|
54
56
|
client,
|
55
57
|
undefined,
|
56
58
|
payForTransaction ? "normal" : "only-simulate",
|
57
|
-
|
59
|
+
PriorityFeeSetting.Min,
|
58
60
|
true,
|
59
61
|
undefined,
|
60
62
|
{ totalRetries: 5 }
|
package/package.json
CHANGED
@@ -4,6 +4,7 @@ import { FlashLoanDetails, FlashLoanRequirements } from "../../types";
|
|
4
4
|
import { Signer, TransactionBuilder, Umi } from "@metaplex-foundation/umi";
|
5
5
|
import { TokenType } from "../../generated";
|
6
6
|
import { MarginfiFlProvider } from "./marginfiFlProvider";
|
7
|
+
import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
7
8
|
|
8
9
|
export class FlProviderAggregator extends FlProviderBase {
|
9
10
|
private marginfiFlProvider!: MarginfiFlProvider;
|
@@ -11,13 +12,15 @@ export class FlProviderAggregator extends FlProviderBase {
|
|
11
12
|
constructor(
|
12
13
|
umi: Umi,
|
13
14
|
signer: Signer,
|
15
|
+
authority: PublicKey,
|
14
16
|
supplyMint: PublicKey,
|
15
17
|
debtMint: PublicKey
|
16
18
|
) {
|
17
|
-
super(umi, signer, supplyMint, debtMint);
|
19
|
+
super(umi, signer, authority, supplyMint, debtMint);
|
18
20
|
this.marginfiFlProvider = new MarginfiFlProvider(
|
19
21
|
umi,
|
20
22
|
signer,
|
23
|
+
authority,
|
21
24
|
supplyMint,
|
22
25
|
debtMint
|
23
26
|
);
|
@@ -39,10 +42,12 @@ export class FlProviderAggregator extends FlProviderBase {
|
|
39
42
|
}
|
40
43
|
|
41
44
|
lutAccountsToAdd(): PublicKey[] {
|
42
|
-
return
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
return toWeb3JsPublicKey(this.signer.publicKey).equals(this.authority)
|
46
|
+
? [
|
47
|
+
...super.lutAccountsToAdd(),
|
48
|
+
...this.marginfiFlProvider.lutAccountsToAdd(),
|
49
|
+
]
|
50
|
+
: [];
|
46
51
|
}
|
47
52
|
|
48
53
|
private flProvider(source: TokenType): FlProviderBase {
|
@@ -41,7 +41,7 @@ export class RebalanceTxBuilder {
|
|
41
41
|
private targetLiqUtilizationRateBps?: number
|
42
42
|
) {}
|
43
43
|
|
44
|
-
private
|
44
|
+
private shouldProceedWithRebalance() {
|
45
45
|
return (
|
46
46
|
this.client.pos.supplyUsd() > 0 &&
|
47
47
|
(this.targetLiqUtilizationRateBps !== undefined ||
|