@haven-fi/solauto-sdk 1.0.117 → 1.0.119
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/solautoClient.d.ts.map +1 -1
- package/dist/clients/solautoClient.js +22 -11
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +0 -1
- package/dist/utils/marginfiUtils.d.ts.map +1 -1
- package/dist/utils/marginfiUtils.js +4 -4
- package/dist/utils/solauto/generalUtils.js +3 -3
- package/package.json +1 -1
- package/src/clients/solautoClient.ts +34 -24
- package/src/clients/solautoMarginfiClient.ts +0 -1
- package/src/utils/marginfiUtils.ts +7 -5
- package/src/utils/solauto/generalUtils.ts +3 -3
- package/tests/transactions/solautoMarginfi.ts +14 -19
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,
|
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,EAChC,sBAAsB,EAMvB,MAAM,cAAc,CAAC;AAOtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAA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CAAC;CAalE"}
|
@@ -39,23 +39,27 @@ class SolautoClient extends txHandler_1.TxHandler {
|
|
39
39
|
this.selfManaged = this.positionId === 0;
|
40
40
|
this.lendingPlatform = lendingPlatform;
|
41
41
|
this.solautoPosition = (0, accountUtils_1.getSolautoPositionAccount)(this.authority, this.positionId);
|
42
|
-
this.solautoPositionData = await (0, generated_1.safeFetchSolautoPosition)(this.umi, (0, umi_1.publicKey)(this.solautoPosition));
|
42
|
+
this.solautoPositionData = await (0, generated_1.safeFetchSolautoPosition)(this.umi, (0, umi_1.publicKey)(this.solautoPosition), { commitment: "confirmed" });
|
43
43
|
this.solautoPositionState = this.solautoPositionData?.state;
|
44
44
|
this.supplyMint =
|
45
|
-
|
46
|
-
|
45
|
+
args.supplyMint ??
|
46
|
+
(this.solautoPositionData
|
47
|
+
? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.solautoPositionData.position.supplyMint)
|
48
|
+
: web3_js_1.PublicKey.default);
|
47
49
|
this.positionSupplyTa = (0, accountUtils_1.getTokenAccount)(this.solautoPosition, this.supplyMint);
|
48
50
|
this.signerSupplyTa = (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.supplyMint);
|
49
51
|
this.debtMint =
|
50
|
-
|
51
|
-
|
52
|
+
args.debtMint ??
|
53
|
+
(this.solautoPositionData
|
54
|
+
? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.solautoPositionData.position.debtMint)
|
55
|
+
: web3_js_1.PublicKey.default);
|
52
56
|
this.positionDebtTa = (0, accountUtils_1.getTokenAccount)(this.solautoPosition, this.debtMint);
|
53
57
|
this.signerDebtTa = (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.debtMint);
|
54
58
|
this.referralStateManager = new referralStateManager_1.ReferralStateManager(this.heliusApiKey);
|
55
59
|
await this.referralStateManager.initialize({
|
56
60
|
referralAuthority: this.authority,
|
57
61
|
signer: args.signer,
|
58
|
-
wallet: args.wallet
|
62
|
+
wallet: args.wallet,
|
59
63
|
});
|
60
64
|
const authorityReferralStateData = this.referralStateManager.referralStateData;
|
61
65
|
const hasReferredBy = authorityReferralStateData &&
|
@@ -77,9 +81,11 @@ class SolautoClient extends txHandler_1.TxHandler {
|
|
77
81
|
}
|
78
82
|
this.solautoFeesWallet = generalAccounts_1.SOLAUTO_FEES_WALLET;
|
79
83
|
this.solautoFeesSupplyTa = (0, accountUtils_1.getTokenAccount)(this.solautoFeesWallet, this.supplyMint);
|
80
|
-
this.authorityLutAddress =
|
81
|
-
|
82
|
-
|
84
|
+
this.authorityLutAddress =
|
85
|
+
authorityReferralStateData?.lookupTable &&
|
86
|
+
!(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(authorityReferralStateData.lookupTable).equals(web3_js_1.PublicKey.default)
|
87
|
+
? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(authorityReferralStateData.lookupTable)
|
88
|
+
: undefined;
|
83
89
|
this.log("Position state: ", this.solautoPositionState);
|
84
90
|
this.log("Position settings: ", this.solautoPositionData?.position?.settingParams);
|
85
91
|
this.log("Position DCA: ", (this.solautoPositionData?.position?.dca?.automation?.targetPeriods ??
|
@@ -107,7 +113,12 @@ class SolautoClient extends txHandler_1.TxHandler {
|
|
107
113
|
this.livePositionUpdates.reset();
|
108
114
|
}
|
109
115
|
defaultLookupTables() {
|
110
|
-
return [
|
116
|
+
return [
|
117
|
+
solautoConstants_1.SOLAUTO_LUT,
|
118
|
+
...(this.authorityLutAddress
|
119
|
+
? [this.authorityLutAddress.toString()]
|
120
|
+
: []),
|
121
|
+
];
|
111
122
|
}
|
112
123
|
lutAccountsToAdd() {
|
113
124
|
return [
|
@@ -255,7 +266,7 @@ class SolautoClient extends txHandler_1.TxHandler {
|
|
255
266
|
positionSupplyTa: (0, umi_1.publicKey)(this.positionSupplyTa),
|
256
267
|
positionDebtTa: (0, umi_1.publicKey)(this.positionDebtTa),
|
257
268
|
signerDebtTa: (0, umi_1.publicKey)(this.signerDebtTa),
|
258
|
-
protocolAccount: (0, umi_1.publicKey)(this.protocolAccount())
|
269
|
+
protocolAccount: (0, umi_1.publicKey)(this.protocolAccount()),
|
259
270
|
});
|
260
271
|
}
|
261
272
|
cancelDCAIx() {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAM1D,OAAO,EACL,kBAAkB,EAElB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EAKjC,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,eAAe,EAUhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAWnE,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,eAAe,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,qBAAa,qBAAsB,SAAQ,aAAa;IACtD,OAAO,CAAC,WAAW,CAAkB;IAE9B,eAAe,EAAG,SAAS,CAAC;IAE5B,sBAAsB,EAAE,MAAM,CAAa;IAC3C,eAAe,EAAG,SAAS,GAAG,MAAM,CAAC;IACrC,iBAAiB,EAAG,SAAS,CAAC;IAC9B,aAAa,EAAG,SAAS,CAAC;IAE1B,sBAAsB,EAAG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AAI,MAAM,EAAE;IAI/B,gBAAgB,IAAI,SAAS,EAAE;IAU/B,yBAAyB,IAAI,kBAAkB;IAS/C,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA6C9B,OAAO,IAAI,kBAAkB;IAc7B,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAUhE,OAAO,CAAC,6BAA6B;IAmErC,OAAO,CAAC,oCAAoC;IA0D5C,SAAS,CACP,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IA2DrB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAoFlE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAgBlE"}
|
@@ -414,7 +414,6 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
414
414
|
return state;
|
415
415
|
}
|
416
416
|
const freshState = await (0, marginfiUtils_1.getMarginfiAccountPositionState)(this.umi, this.marginfiAccountPk, this.supplyMint, this.debtMint, this.livePositionUpdates);
|
417
|
-
this.log("Fresh state:", freshState);
|
418
417
|
return freshState;
|
419
418
|
}
|
420
419
|
}
|
@@ -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,EAAyB,G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CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,EAAE,CAC/E,CA6CA;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,CAkJpC;AA+DD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA0B3B"}
|
@@ -60,7 +60,7 @@ async function getMaxLtvAndLiqThreshold(umi, supply, debt, supplyPrice) {
|
|
60
60
|
}
|
61
61
|
async function getAllMarginfiAccountsByAuthority(umi, authority, compatibleWithSolauto) {
|
62
62
|
const marginfiAccounts = await umi.rpc.getProgramAccounts(marginfi_sdk_1.MARGINFI_PROGRAM_ID, {
|
63
|
-
commitment: "
|
63
|
+
commitment: "confirmed",
|
64
64
|
dataSlice: {
|
65
65
|
offset: 0,
|
66
66
|
length: 0,
|
@@ -136,12 +136,12 @@ async function getTokenUsage(umi, bank, isAsset, shares, amountUsedAdjustment) {
|
|
136
136
|
};
|
137
137
|
}
|
138
138
|
async function getMarginfiAccountPositionState(umi, marginfiAccountPk, supplyMint, debtMint, livePositionUpdates) {
|
139
|
-
let marginfiAccount = await (0, marginfi_sdk_1.safeFetchMarginfiAccount)(umi, (0, umi_1.publicKey)(marginfiAccountPk));
|
139
|
+
let marginfiAccount = await (0, marginfi_sdk_1.safeFetchMarginfiAccount)(umi, (0, umi_1.publicKey)(marginfiAccountPk), { commitment: "confirmed" });
|
140
140
|
let supplyBank = supplyMint && supplyMint !== web3_js_1.PublicKey.default
|
141
|
-
? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[supplyMint.toString()].bank))
|
141
|
+
? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[supplyMint.toString()].bank), { commitment: "confirmed" })
|
142
142
|
: null;
|
143
143
|
let debtBank = debtMint && debtMint !== web3_js_1.PublicKey.default
|
144
|
-
? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[debtMint.toString()].bank))
|
144
|
+
? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[debtMint.toString()].bank), { commitment: "confirmed" })
|
145
145
|
: null;
|
146
146
|
let supplyUsage = undefined;
|
147
147
|
let debtUsage = undefined;
|
@@ -105,7 +105,7 @@ async function getSolautoManagedPositions(umi, authority) {
|
|
105
105
|
// authority: Pubkey
|
106
106
|
// lending_platform: u8
|
107
107
|
const accounts = await umi.rpc.getProgramAccounts(generated_1.SOLAUTO_PROGRAM_ID, {
|
108
|
-
commitment: "
|
108
|
+
commitment: "confirmed",
|
109
109
|
dataSlice: {
|
110
110
|
offset: 0,
|
111
111
|
length: 1 + 1 + 1 + 5 + 32 + 1, // bump + position_id + self_managed + padding + authority (pubkey) + lending_platform
|
@@ -147,7 +147,7 @@ async function getSolautoManagedPositions(umi, authority) {
|
|
147
147
|
}
|
148
148
|
async function getAllReferralStates(umi) {
|
149
149
|
const accounts = await umi.rpc.getProgramAccounts(generated_1.SOLAUTO_PROGRAM_ID, {
|
150
|
-
commitment: "
|
150
|
+
commitment: "confirmed",
|
151
151
|
dataSlice: {
|
152
152
|
offset: 0,
|
153
153
|
length: 0,
|
@@ -167,7 +167,7 @@ async function getReferralsByUser(umi, user) {
|
|
167
167
|
// referred_by_state: Pubkey,
|
168
168
|
const userReferralState = (0, accountUtils_1.getReferralState)(user);
|
169
169
|
const accounts = await umi.rpc.getProgramAccounts(generated_1.SOLAUTO_PROGRAM_ID, {
|
170
|
-
commitment: "
|
170
|
+
commitment: "confirmed",
|
171
171
|
dataSlice: {
|
172
172
|
offset: 0,
|
173
173
|
length: 0,
|
package/package.json
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
import "rpc-websockets/dist/lib/client";
|
2
|
-
import {
|
3
|
-
AddressLookupTableProgram,
|
4
|
-
PublicKey,
|
5
|
-
} from "@solana/web3.js";
|
2
|
+
import { AddressLookupTableProgram, PublicKey } from "@solana/web3.js";
|
6
3
|
import {
|
7
4
|
Signer,
|
8
5
|
TransactionBuilder,
|
@@ -40,9 +37,7 @@ import {
|
|
40
37
|
getSolautoPositionAccount,
|
41
38
|
getTokenAccount,
|
42
39
|
} from "../utils/accountUtils";
|
43
|
-
import {
|
44
|
-
SOLAUTO_FEES_WALLET,
|
45
|
-
} from "../constants/generalAccounts";
|
40
|
+
import { SOLAUTO_FEES_WALLET } from "../constants/generalAccounts";
|
46
41
|
import { JupSwapDetails } from "../utils/jupiterUtils";
|
47
42
|
import {
|
48
43
|
getWrappedInstruction,
|
@@ -138,13 +133,16 @@ export abstract class SolautoClient extends TxHandler {
|
|
138
133
|
);
|
139
134
|
this.solautoPositionData = await safeFetchSolautoPosition(
|
140
135
|
this.umi,
|
141
|
-
publicKey(this.solautoPosition)
|
136
|
+
publicKey(this.solautoPosition),
|
137
|
+
{ commitment: "confirmed" }
|
142
138
|
);
|
143
139
|
this.solautoPositionState = this.solautoPositionData?.state;
|
144
140
|
|
145
141
|
this.supplyMint =
|
146
142
|
args.supplyMint ??
|
147
|
-
|
143
|
+
(this.solautoPositionData
|
144
|
+
? toWeb3JsPublicKey(this.solautoPositionData!.position.supplyMint)
|
145
|
+
: PublicKey.default);
|
148
146
|
this.positionSupplyTa = getTokenAccount(
|
149
147
|
this.solautoPosition,
|
150
148
|
this.supplyMint
|
@@ -156,29 +154,32 @@ export abstract class SolautoClient extends TxHandler {
|
|
156
154
|
|
157
155
|
this.debtMint =
|
158
156
|
args.debtMint ??
|
159
|
-
|
157
|
+
(this.solautoPositionData
|
158
|
+
? toWeb3JsPublicKey(this.solautoPositionData!.position.debtMint)
|
159
|
+
: PublicKey.default);
|
160
160
|
this.positionDebtTa = getTokenAccount(this.solautoPosition, this.debtMint);
|
161
161
|
this.signerDebtTa = getTokenAccount(
|
162
162
|
toWeb3JsPublicKey(this.signer.publicKey),
|
163
163
|
this.debtMint
|
164
164
|
);
|
165
165
|
|
166
|
-
this.referralStateManager = new ReferralStateManager(this.heliusApiKey)
|
166
|
+
this.referralStateManager = new ReferralStateManager(this.heliusApiKey);
|
167
167
|
await this.referralStateManager.initialize({
|
168
168
|
referralAuthority: this.authority,
|
169
169
|
signer: args.signer,
|
170
|
-
wallet: args.wallet
|
170
|
+
wallet: args.wallet,
|
171
171
|
});
|
172
172
|
|
173
|
-
const authorityReferralStateData =
|
173
|
+
const authorityReferralStateData =
|
174
|
+
this.referralStateManager.referralStateData;
|
174
175
|
const hasReferredBy =
|
175
176
|
authorityReferralStateData &&
|
176
177
|
authorityReferralStateData.referredByState !==
|
177
|
-
|
178
|
+
publicKey(PublicKey.default);
|
178
179
|
const referredByAuthority =
|
179
180
|
!hasReferredBy &&
|
180
|
-
|
181
|
-
|
181
|
+
args.referredByAuthority &&
|
182
|
+
!args.referredByAuthority.equals(toWeb3JsPublicKey(this.signer.publicKey))
|
182
183
|
? args.referredByAuthority
|
183
184
|
: undefined;
|
184
185
|
this.referredByState = hasReferredBy
|
@@ -200,9 +201,13 @@ export abstract class SolautoClient extends TxHandler {
|
|
200
201
|
this.supplyMint
|
201
202
|
);
|
202
203
|
|
203
|
-
this.authorityLutAddress =
|
204
|
-
|
205
|
-
|
204
|
+
this.authorityLutAddress =
|
205
|
+
authorityReferralStateData?.lookupTable &&
|
206
|
+
!toWeb3JsPublicKey(authorityReferralStateData.lookupTable).equals(
|
207
|
+
PublicKey.default
|
208
|
+
)
|
209
|
+
? toWeb3JsPublicKey(authorityReferralStateData.lookupTable)
|
210
|
+
: undefined;
|
206
211
|
|
207
212
|
this.log("Position state: ", this.solautoPositionState);
|
208
213
|
this.log(
|
@@ -243,7 +248,12 @@ export abstract class SolautoClient extends TxHandler {
|
|
243
248
|
abstract protocolAccount(): PublicKey;
|
244
249
|
|
245
250
|
defaultLookupTables(): string[] {
|
246
|
-
return [
|
251
|
+
return [
|
252
|
+
SOLAUTO_LUT,
|
253
|
+
...(this.authorityLutAddress
|
254
|
+
? [this.authorityLutAddress.toString()]
|
255
|
+
: []),
|
256
|
+
];
|
247
257
|
}
|
248
258
|
|
249
259
|
lutAccountsToAdd(): PublicKey[] {
|
@@ -323,7 +333,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
323
333
|
const addingReferredBy =
|
324
334
|
accountsToAdd.length === 1 &&
|
325
335
|
accountsToAdd[0].toString().toLowerCase() ===
|
326
|
-
|
336
|
+
this.referredBySupplyTa?.toString().toLowerCase();
|
327
337
|
|
328
338
|
if (tx.getInstructions().length > 0) {
|
329
339
|
this.log("Updating authority lookup table...");
|
@@ -439,7 +449,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
439
449
|
positionSupplyTa: publicKey(this.positionSupplyTa),
|
440
450
|
positionDebtTa: publicKey(this.positionDebtTa),
|
441
451
|
signerDebtTa: publicKey(this.signerDebtTa),
|
442
|
-
protocolAccount: publicKey(this.protocolAccount())
|
452
|
+
protocolAccount: publicKey(this.protocolAccount()),
|
443
453
|
});
|
444
454
|
}
|
445
455
|
|
@@ -508,7 +518,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
508
518
|
BigInt(
|
509
519
|
Math.round(
|
510
520
|
Number(this.solautoPositionState!.debt.amountUsed.baseUnit) *
|
511
|
-
|
521
|
+
1.01
|
512
522
|
)
|
513
523
|
)
|
514
524
|
)
|
@@ -581,7 +591,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
581
591
|
Boolean(this.solautoPositionData) &&
|
582
592
|
Boolean(this.solautoPositionState) &&
|
583
593
|
Number(this.solautoPositionState!.lastUpdated) >
|
584
|
-
|
594
|
+
currentUnixSeconds() - MIN_POSITION_STATE_FRESHNESS_SECS &&
|
585
595
|
!this.livePositionUpdates.hasUpdates()
|
586
596
|
) {
|
587
597
|
return this.solautoPositionState;
|
@@ -23,7 +23,6 @@ import { PositionState, PositionTokenUsage } from "../generated";
|
|
23
23
|
import { USD_DECIMALS } from "../constants/generalAccounts";
|
24
24
|
import { LivePositionUpdates } from "./solauto/generalUtils";
|
25
25
|
import { currentUnixSecondsSolana } from "./solanaUtils";
|
26
|
-
import { getSolautoPositionAccount } from "./accountUtils";
|
27
26
|
|
28
27
|
export function findMarginfiAccounts(bank: PublicKey): MarginfiAssetAccounts {
|
29
28
|
for (const key in MARGINFI_ACCOUNTS) {
|
@@ -123,7 +122,7 @@ export async function getAllMarginfiAccountsByAuthority(
|
|
123
122
|
const marginfiAccounts = await umi.rpc.getProgramAccounts(
|
124
123
|
MARGINFI_PROGRAM_ID,
|
125
124
|
{
|
126
|
-
commitment: "
|
125
|
+
commitment: "confirmed",
|
127
126
|
dataSlice: {
|
128
127
|
offset: 0,
|
129
128
|
length: 0,
|
@@ -237,21 +236,24 @@ export async function getMarginfiAccountPositionState(
|
|
237
236
|
): Promise<PositionState | undefined> {
|
238
237
|
let marginfiAccount = await safeFetchMarginfiAccount(
|
239
238
|
umi,
|
240
|
-
publicKey(marginfiAccountPk)
|
239
|
+
publicKey(marginfiAccountPk),
|
240
|
+
{ commitment: "confirmed" }
|
241
241
|
);
|
242
242
|
|
243
243
|
let supplyBank: Bank | null =
|
244
244
|
supplyMint && supplyMint !== PublicKey.default
|
245
245
|
? await safeFetchBank(
|
246
246
|
umi,
|
247
|
-
publicKey(MARGINFI_ACCOUNTS[supplyMint.toString()].bank)
|
247
|
+
publicKey(MARGINFI_ACCOUNTS[supplyMint.toString()].bank),
|
248
|
+
{ commitment: "confirmed" }
|
248
249
|
)
|
249
250
|
: null;
|
250
251
|
let debtBank: Bank | null =
|
251
252
|
debtMint && debtMint !== PublicKey.default
|
252
253
|
? await safeFetchBank(
|
253
254
|
umi,
|
254
|
-
publicKey(MARGINFI_ACCOUNTS[debtMint.toString()].bank)
|
255
|
+
publicKey(MARGINFI_ACCOUNTS[debtMint.toString()].bank),
|
256
|
+
{ commitment: "confirmed" }
|
255
257
|
)
|
256
258
|
: null;
|
257
259
|
|
@@ -180,7 +180,7 @@ export async function getSolautoManagedPositions(
|
|
180
180
|
// lending_platform: u8
|
181
181
|
|
182
182
|
const accounts = await umi.rpc.getProgramAccounts(SOLAUTO_PROGRAM_ID, {
|
183
|
-
commitment: "
|
183
|
+
commitment: "confirmed",
|
184
184
|
dataSlice: {
|
185
185
|
offset: 0,
|
186
186
|
length: 1 + 1 + 1 + 5 + 32 + 1, // bump + position_id + self_managed + padding + authority (pubkey) + lending_platform
|
@@ -226,7 +226,7 @@ export async function getSolautoManagedPositions(
|
|
226
226
|
|
227
227
|
export async function getAllReferralStates(umi: Umi): Promise<PublicKey[]> {
|
228
228
|
const accounts = await umi.rpc.getProgramAccounts(SOLAUTO_PROGRAM_ID, {
|
229
|
-
commitment: "
|
229
|
+
commitment: "confirmed",
|
230
230
|
dataSlice: {
|
231
231
|
offset: 0,
|
232
232
|
length: 0,
|
@@ -252,7 +252,7 @@ export async function getReferralsByUser(
|
|
252
252
|
|
253
253
|
const userReferralState = getReferralState(user);
|
254
254
|
const accounts = await umi.rpc.getProgramAccounts(SOLAUTO_PROGRAM_ID, {
|
255
|
-
commitment: "
|
255
|
+
commitment: "confirmed",
|
256
256
|
dataSlice: {
|
257
257
|
offset: 0,
|
258
258
|
length: 0,
|
@@ -18,9 +18,6 @@ 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 {
|
22
|
-
ACCOUNT_SIZE as TOKEN_ACCOUNT_SIZE,
|
23
|
-
} from "@solana/spl-token";
|
24
21
|
|
25
22
|
describe("Solauto Marginfi tests", async () => {
|
26
23
|
const signer = setupTest();
|
@@ -52,14 +49,14 @@ describe("Solauto Marginfi tests", async () => {
|
|
52
49
|
);
|
53
50
|
|
54
51
|
const transactionItems: TransactionItem[] = [];
|
55
|
-
const settingParams: SolautoSettingsParametersInpArgs = {
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
};
|
52
|
+
// const settingParams: SolautoSettingsParametersInpArgs = {
|
53
|
+
// boostToBps: 4000,
|
54
|
+
// boostGap: 500,
|
55
|
+
// repayToBps: 7456,
|
56
|
+
// repayGap: 500,
|
57
|
+
// automation: none(),
|
58
|
+
// targetBoostToBps: none(),
|
59
|
+
// };
|
63
60
|
|
64
61
|
// if (client.solautoPositionData === null) {
|
65
62
|
// transactionItems.push(
|
@@ -158,13 +155,11 @@ describe("Solauto Marginfi tests", async () => {
|
|
158
155
|
// )
|
159
156
|
// );
|
160
157
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
console.log((await client.umi.rpc.getRent(TOKEN_ACCOUNT_SIZE)).basisPoints);
|
158
|
+
await new TransactionsManager(
|
159
|
+
client,
|
160
|
+
undefined,
|
161
|
+
!payForTransactions ? "only-simulate" : "normal",
|
162
|
+
useJitoBundle
|
163
|
+
).clientSend(transactionItems);
|
169
164
|
});
|
170
165
|
});
|