@haven-fi/solauto-sdk 1.0.212 → 1.0.214
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/referralStateManager.d.ts +1 -2
- package/dist/clients/referralStateManager.d.ts.map +1 -1
- package/dist/clients/referralStateManager.js +16 -15
- package/dist/clients/solautoClient.d.ts.map +1 -1
- package/dist/clients/solautoClient.js +1 -0
- package/dist/clients/txHandler.d.ts +1 -0
- package/dist/clients/txHandler.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +2 -2
- package/package.json +1 -1
- package/src/clients/referralStateManager.ts +16 -17
- package/src/clients/solautoClient.ts +2 -1
- package/src/clients/solautoMarginfiClient.ts +1 -1
- package/src/clients/txHandler.ts +1 -0
- package/src/transactions/transactionUtils.ts +2 -3
- package/tests/transactions/solautoMarginfi.ts +7 -6
- package/tests/unit/rebalanceCalculations.ts +1 -1
@@ -16,12 +16,11 @@ export declare class ReferralStateManager extends TxHandler {
|
|
16
16
|
referralAuthority: PublicKey;
|
17
17
|
referralState: PublicKey;
|
18
18
|
referralStateData: ReferralState | null;
|
19
|
-
referredByState?: PublicKey;
|
20
19
|
constructor(heliusApiUrl: string, localTest?: boolean | undefined);
|
21
20
|
initialize(args: ReferralStateManagerArgs): Promise<void>;
|
22
21
|
defaultLookupTables(): string[];
|
23
22
|
setReferredBy(referredBy?: PublicKey): void;
|
24
|
-
updateReferralStatesIx(destFeesMint?: PublicKey,
|
23
|
+
updateReferralStatesIx(destFeesMint?: PublicKey, lookupTable?: PublicKey): TransactionBuilder;
|
25
24
|
claimReferralFeesIx(destFeesMint?: PublicKey): TransactionBuilder;
|
26
25
|
resetLiveTxUpdates(success?: boolean): Promise<void>;
|
27
26
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"referralStateManager.d.ts","sourceRoot":"","sources":["../../src/clients/referralStateManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5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,CAAC,EAAE,SAAS,GACtB,kBAAkB;IAerB,mBAAmB,CAAC,YAAY,CAAC,EAAE,SAAS,GAAG,kBAAkB;IA8B3D,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC3D"}
|
@@ -9,6 +9,7 @@ const umi_signer_wallet_adapters_1 = require("@metaplex-foundation/umi-signer-wa
|
|
9
9
|
const generated_1 = require("../generated");
|
10
10
|
const utils_1 = require("../utils");
|
11
11
|
const txHandler_1 = require("./txHandler");
|
12
|
+
const constants_1 = require("../constants");
|
12
13
|
class ReferralStateManager extends txHandler_1.TxHandler {
|
13
14
|
constructor(heliusApiUrl, localTest) {
|
14
15
|
super(heliusApiUrl, localTest);
|
@@ -34,37 +35,37 @@ class ReferralStateManager extends txHandler_1.TxHandler {
|
|
34
35
|
defaultLookupTables() {
|
35
36
|
return this.referralStateData?.lookupTable &&
|
36
37
|
!(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.referralStateData.lookupTable).equals(web3_js_1.PublicKey.default)
|
37
|
-
? [this.referralStateData?.lookupTable.toString()]
|
38
|
-
: [];
|
38
|
+
? [constants_1.SOLAUTO_LUT, this.referralStateData?.lookupTable.toString()]
|
39
|
+
: [constants_1.SOLAUTO_LUT];
|
39
40
|
}
|
40
41
|
setReferredBy(referredBy) {
|
41
42
|
const authorityReferralStateData = this.referralStateData;
|
42
43
|
const hasReferredBy = authorityReferralStateData &&
|
43
44
|
authorityReferralStateData.referredByState !==
|
44
45
|
(0, umi_1.publicKey)(web3_js_1.PublicKey.default);
|
45
|
-
const
|
46
|
+
const finalReferredBy = !hasReferredBy &&
|
46
47
|
referredBy &&
|
47
48
|
!referredBy.equals((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey))
|
48
49
|
? referredBy
|
49
50
|
: undefined;
|
50
|
-
this.
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
this.referredBy = finalReferredBy;
|
52
|
+
this.referredByState = finalReferredBy
|
53
|
+
? (0, utils_1.getReferralState)(finalReferredBy)
|
54
|
+
: authorityReferralStateData
|
55
|
+
? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(authorityReferralStateData.referredByState)
|
54
56
|
: undefined;
|
55
|
-
this.referredBy = referredByAuthority;
|
56
57
|
}
|
57
|
-
updateReferralStatesIx(destFeesMint,
|
58
|
+
updateReferralStatesIx(destFeesMint, lookupTable) {
|
58
59
|
return (0, generated_1.updateReferralStates)(this.umi, {
|
59
60
|
signer: this.signer,
|
60
61
|
signerReferralState: (0, umi_1.publicKey)(this.referralState),
|
61
62
|
referralFeesDestMint: destFeesMint ? (0, umi_1.publicKey)(destFeesMint) : null,
|
62
|
-
referredByState:
|
63
|
-
? (0, umi_1.publicKey)(
|
64
|
-
:
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
referredByState: this.referredByState
|
64
|
+
? (0, umi_1.publicKey)(this.referredByState)
|
65
|
+
: undefined,
|
66
|
+
referredByAuthority: this.referredBy
|
67
|
+
? (0, umi_1.publicKey)(this.referredBy)
|
68
|
+
: undefined,
|
68
69
|
addressLookupTable: lookupTable ? (0, umi_1.publicKey)(lookupTable) : null,
|
69
70
|
});
|
70
71
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAA6B,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACL,MAAM,EACN,kBAAkB,EAOnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAEhC,sBAAsB,EAMvB,MAAM,cAAc,CAAC;AAWt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I,OAAO,CAChC;QAAE,WAAW,EAAE,kBAAkB,CAAC;QAAC,iBAAiB,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAC5E;IAyDD,uBAAuB,IAAI,yBAAyB,GAAG,SAAS;IAOhE,wBAAwB,IAAI,WAAW,GAAG,SAAS;IAO7C,wBAAwB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAOvE,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IA0BrB,gBAAgB,CAAC,IAAI,EAAE,sBAAsB,GAAG,kBAAkB;IAwDlE,eAAe,IAAI,kBAAkB;IAYrC,WAAW,IAAI,kBAAkB;IAgCjC,QAAQ,CAAC,OAAO,IAAI,kBAAkB;IAEtC,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAuFhE,QAAQ,CAAC,WAAW,CAClB,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IAErB,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAE3E,QAAQ,CAAC,SAAS,CAChB,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,GACnC,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAalE"}
|
@@ -65,6 +65,7 @@ class SolautoClient extends txHandler_1.TxHandler {
|
|
65
65
|
signer: args.signer,
|
66
66
|
wallet: args.wallet,
|
67
67
|
});
|
68
|
+
console.log(this.referralStateManager.referredBy?.toString());
|
68
69
|
if (this.referralStateManager.referredByState !== undefined) {
|
69
70
|
this.referredBySupplyTa = (0, accountUtils_1.getTokenAccount)(this.referralStateManager.referredByState, this.supplyMint);
|
70
71
|
}
|
@@ -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,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGxD,8BAAsB,SAAS;IACtB,MAAM,EAAG,MAAM,CAAC;IAChB,GAAG,EAAG,GAAG,CAAC;IACV,UAAU,EAAG,UAAU,CAAC;IAExB,UAAU,CAAC,EAAE,SAAS,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,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGxD,8BAAsB,SAAS;IACtB,MAAM,EAAG,MAAM,CAAC;IAChB,GAAG,EAAG,GAAG,CAAC;IACV,UAAU,EAAG,UAAU,CAAC;IAExB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,eAAe,CAAC,EAAE,SAAS,CAAC;gBAGjC,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,OAAO;IAYrB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAIzB,QAAQ,CAAC,mBAAmB,IAAI,MAAM,EAAE;IAExC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAE7D,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,SAAS,GAAG,IAAI;CACrD"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,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,SAAS,CAAC,CAsC5C;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG;;;;EAwC9D"}
|
@@ -52,13 +52,13 @@ function getWSolUsage(client, solautoActions, initiatingDcaIn, cancellingDcaIn)
|
|
52
52
|
async function transactionChoresBefore(client, accountsGettingCreated, solautoActions, initiatingDcaIn) {
|
53
53
|
let chores = (0, umi_1.transactionBuilder)();
|
54
54
|
if (client.referralStateManager.referralStateData === null ||
|
55
|
-
(client.referralStateManager.
|
55
|
+
(client.referralStateManager.referredBy !== undefined &&
|
56
56
|
client.referralStateManager.referralStateData?.referredByState ===
|
57
57
|
(0, umi_1.publicKey)(web3_js_1.PublicKey.default)) ||
|
58
58
|
(client.authorityLutAddress !== undefined &&
|
59
59
|
client.referralStateManager.referralStateData.lookupTable ==
|
60
60
|
(0, umi_1.publicKey)(web3_js_1.PublicKey.default))) {
|
61
|
-
chores = chores.add(client.referralStateManager.updateReferralStatesIx(undefined, client.
|
61
|
+
chores = chores.add(client.referralStateManager.updateReferralStatesIx(undefined, client.authorityLutAddress));
|
62
62
|
}
|
63
63
|
if (client.selfManaged) {
|
64
64
|
if (client.solautoPositionData === null) {
|
package/package.json
CHANGED
@@ -21,6 +21,7 @@ import {
|
|
21
21
|
} from "../generated";
|
22
22
|
import { getReferralState, getTokenAccount } from "../utils";
|
23
23
|
import { TxHandler } from "./txHandler";
|
24
|
+
import { SOLAUTO_LUT } from "../constants";
|
24
25
|
|
25
26
|
interface ReferralStateManagerArgs {
|
26
27
|
signer?: Signer;
|
@@ -37,8 +38,6 @@ export class ReferralStateManager extends TxHandler {
|
|
37
38
|
public referralState!: PublicKey;
|
38
39
|
public referralStateData!: ReferralState | null;
|
39
40
|
|
40
|
-
public referredByState?: PublicKey;
|
41
|
-
|
42
41
|
constructor(
|
43
42
|
heliusApiUrl: string,
|
44
43
|
public localTest?: boolean
|
@@ -79,8 +78,8 @@ export class ReferralStateManager extends TxHandler {
|
|
79
78
|
!toWeb3JsPublicKey(this.referralStateData!.lookupTable).equals(
|
80
79
|
PublicKey.default
|
81
80
|
)
|
82
|
-
? [this.referralStateData?.lookupTable.toString()]
|
83
|
-
: [];
|
81
|
+
? [SOLAUTO_LUT, this.referralStateData?.lookupTable.toString()]
|
82
|
+
: [SOLAUTO_LUT];
|
84
83
|
}
|
85
84
|
|
86
85
|
public setReferredBy(referredBy?: PublicKey) {
|
@@ -89,35 +88,35 @@ export class ReferralStateManager extends TxHandler {
|
|
89
88
|
authorityReferralStateData &&
|
90
89
|
authorityReferralStateData.referredByState !==
|
91
90
|
publicKey(PublicKey.default);
|
92
|
-
const
|
91
|
+
const finalReferredBy =
|
93
92
|
!hasReferredBy &&
|
94
93
|
referredBy &&
|
95
94
|
!referredBy.equals(toWeb3JsPublicKey(this.signer.publicKey))
|
96
95
|
? referredBy
|
97
96
|
: undefined;
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
97
|
+
|
98
|
+
this.referredBy = finalReferredBy;
|
99
|
+
this.referredByState = finalReferredBy
|
100
|
+
? getReferralState(finalReferredBy)
|
101
|
+
: authorityReferralStateData
|
102
|
+
? toWeb3JsPublicKey(authorityReferralStateData.referredByState)
|
102
103
|
: undefined;
|
103
|
-
this.referredBy = referredByAuthority;
|
104
104
|
}
|
105
105
|
|
106
106
|
updateReferralStatesIx(
|
107
107
|
destFeesMint?: PublicKey,
|
108
|
-
referredBy?: PublicKey,
|
109
108
|
lookupTable?: PublicKey
|
110
109
|
): TransactionBuilder {
|
111
110
|
return updateReferralStates(this.umi, {
|
112
111
|
signer: this.signer,
|
113
112
|
signerReferralState: publicKey(this.referralState),
|
114
113
|
referralFeesDestMint: destFeesMint ? publicKey(destFeesMint) : null,
|
115
|
-
referredByState:
|
116
|
-
? publicKey(
|
117
|
-
:
|
118
|
-
|
119
|
-
|
120
|
-
|
114
|
+
referredByState: this.referredByState
|
115
|
+
? publicKey(this.referredByState)
|
116
|
+
: undefined,
|
117
|
+
referredByAuthority: this.referredBy
|
118
|
+
? publicKey(this.referredBy)
|
119
|
+
: undefined,
|
121
120
|
addressLookupTable: lookupTable ? publicKey(lookupTable) : null,
|
122
121
|
});
|
123
122
|
}
|
@@ -174,6 +174,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
174
174
|
signer: args.signer,
|
175
175
|
wallet: args.wallet,
|
176
176
|
});
|
177
|
+
console.log(this.referralStateManager.referredBy?.toString());
|
177
178
|
if (this.referralStateManager.referredByState !== undefined) {
|
178
179
|
this.referredBySupplyTa = getTokenAccount(
|
179
180
|
this.referralStateManager.referredByState,
|
@@ -215,7 +216,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
215
216
|
this.referralStateManager.setReferredBy(referredBy);
|
216
217
|
if (this.referralStateManager.referredByState !== undefined) {
|
217
218
|
this.referredBySupplyTa = getTokenAccount(
|
218
|
-
this.referralStateManager.referredByState
|
219
|
+
this.referralStateManager.referredByState!,
|
219
220
|
this.supplyMint
|
220
221
|
);
|
221
222
|
}
|
@@ -32,7 +32,7 @@ import {
|
|
32
32
|
marginfiRebalance,
|
33
33
|
marginfiRefreshData,
|
34
34
|
} from "../generated";
|
35
|
-
import { getMarginfiAccountPDA, getTokenAccount } from "../utils/accountUtils";
|
35
|
+
import { getMarginfiAccountPDA, getReferralState, getTokenAccount } from "../utils/accountUtils";
|
36
36
|
import { generateRandomU64, safeGetPrice } from "../utils/generalUtils";
|
37
37
|
import {
|
38
38
|
MARGINFI_PROGRAM_ID,
|
package/src/clients/txHandler.ts
CHANGED
@@ -57,7 +57,7 @@ import {
|
|
57
57
|
eligibleForRebalance,
|
58
58
|
positionStateWithLatestPrices,
|
59
59
|
} from "../utils/solauto/generalUtils";
|
60
|
-
import { getTokenAccount, getTokenAccountData } from "../utils/accountUtils";
|
60
|
+
import { getReferralState, getTokenAccount, getTokenAccountData } from "../utils/accountUtils";
|
61
61
|
import {
|
62
62
|
createMarginfiProgram,
|
63
63
|
getLendingAccountBorrowInstructionDataSerializer,
|
@@ -140,7 +140,7 @@ async function transactionChoresBefore(
|
|
140
140
|
|
141
141
|
if (
|
142
142
|
client.referralStateManager.referralStateData === null ||
|
143
|
-
(client.referralStateManager.
|
143
|
+
(client.referralStateManager.referredBy !== undefined &&
|
144
144
|
client.referralStateManager.referralStateData?.referredByState ===
|
145
145
|
publicKey(PublicKey.default)) ||
|
146
146
|
(client.authorityLutAddress !== undefined &&
|
@@ -150,7 +150,6 @@ async function transactionChoresBefore(
|
|
150
150
|
chores = chores.add(
|
151
151
|
client.referralStateManager.updateReferralStatesIx(
|
152
152
|
undefined,
|
153
|
-
client.referralStateManager.referredBy,
|
154
153
|
client.authorityLutAddress
|
155
154
|
)
|
156
155
|
);
|
@@ -22,12 +22,13 @@ import {
|
|
22
22
|
import { PublicKey } from "@solana/web3.js";
|
23
23
|
import { USDC } from "../../src/constants";
|
24
24
|
import { buildHeliusApiUrl } from "../../src/utils";
|
25
|
+
import { PriorityFeeSetting } from "../../src/types";
|
25
26
|
|
26
27
|
describe("Solauto Marginfi tests", async () => {
|
27
|
-
|
28
|
-
const signer = setupTest("solauto-manager");
|
28
|
+
const signer = setupTest();
|
29
|
+
// const signer = setupTest("solauto-manager");
|
29
30
|
|
30
|
-
const payForTransactions =
|
31
|
+
const payForTransactions = true;
|
31
32
|
const useJitoBundle = false;
|
32
33
|
const positionId = 1;
|
33
34
|
|
@@ -127,7 +128,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
127
128
|
transactionItems.push(
|
128
129
|
new TransactionItem(
|
129
130
|
async (attemptNum) =>
|
130
|
-
await buildSolautoRebalanceTransaction(client,
|
131
|
+
await buildSolautoRebalanceTransaction(client, 7000, attemptNum),
|
131
132
|
"rebalance"
|
132
133
|
)
|
133
134
|
);
|
@@ -163,7 +164,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
163
164
|
client,
|
164
165
|
undefined,
|
165
166
|
!payForTransactions ? "only-simulate" : "normal",
|
166
|
-
useJitoBundle
|
167
|
-
).clientSend(transactionItems);
|
167
|
+
useJitoBundle,
|
168
|
+
).clientSend(transactionItems, PriorityFeeSetting.Default);
|
168
169
|
});
|
169
170
|
});
|
@@ -59,7 +59,7 @@ function assertAccurateRebalance(
|
|
59
59
|
let adjustmentFeeBps = 0;
|
60
60
|
if (increasingLeverage) {
|
61
61
|
adjustmentFeeBps = getSolautoFeesBps(
|
62
|
-
client.
|
62
|
+
client.referredBy !== undefined,
|
63
63
|
targetLiqUtilizationRateBps,
|
64
64
|
fromBaseUnit(
|
65
65
|
client.solautoPositionState?.netWorth.baseAmountUsdValue ?? BigInt(0),
|