@haven-fi/solauto-sdk 1.0.33 → 1.0.35
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +4 -5
- package/dist/transactions/transactionUtils.d.ts +1 -1
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +10 -8
- package/dist/utils/marginfiUtils.d.ts.map +1 -1
- package/dist/utils/marginfiUtils.js +0 -1
- package/package.json +1 -1
- package/src/clients/solautoMarginfiClient.ts +4 -5
- package/src/transactions/transactionUtils.ts +13 -8
- package/src/utils/marginfiUtils.ts +0 -1
@@ -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,EACL,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,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;AAQnE,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,WA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2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IAgDrB,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"}
|
@@ -110,9 +110,9 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
110
110
|
: undefined,
|
111
111
|
solautoPosition: (0, umi_1.publicKey)(this.solautoPosition),
|
112
112
|
marginfiGroup: (0, umi_1.publicKey)(this.marginfiGroup),
|
113
|
-
marginfiAccount: this.
|
114
|
-
?
|
115
|
-
: this.marginfiAccount,
|
113
|
+
marginfiAccount: "publicKey" in this.marginfiAccount
|
114
|
+
? this.marginfiAccount
|
115
|
+
: (0, umi_1.publicKey)(this.marginfiAccount),
|
116
116
|
supplyMint: (0, umi_1.publicKey)(this.supplyMint),
|
117
117
|
supplyBank: (0, umi_1.publicKey)(this.marginfiSupplyBankAccounts.bank),
|
118
118
|
positionSupplyTa: (0, umi_1.publicKey)(this.positionSupplyTa),
|
@@ -125,7 +125,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
125
125
|
settingParams: settingParams ?? null,
|
126
126
|
dca: dca ?? null,
|
127
127
|
},
|
128
|
-
marginfiAccountSeedIdx: this.marginfiAccountSeedIdx
|
128
|
+
marginfiAccountSeedIdx: !this.selfManaged ? this.marginfiAccountSeedIdx : null,
|
129
129
|
});
|
130
130
|
}
|
131
131
|
refresh() {
|
@@ -153,7 +153,6 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
153
153
|
marginfiProtocolInteractionIx(args) {
|
154
154
|
switch (args.__kind) {
|
155
155
|
case "Deposit": {
|
156
|
-
console.log(args.fields[0]);
|
157
156
|
return (0, marginfi_sdk_1.lendingAccountDeposit)(this.umi, {
|
158
157
|
amount: args.fields[0],
|
159
158
|
signer: this.signer,
|
@@ -2,7 +2,7 @@ import { TransactionBuilder, Umi } from "@metaplex-foundation/umi";
|
|
2
2
|
import { Account as SplTokenAccount } from "@solana/spl-token";
|
3
3
|
import { ReferralState } from "../generated";
|
4
4
|
import { SolautoClient } from "../clients/solautoClient";
|
5
|
-
export declare function rebalanceChoresBefore(client: SolautoClient, tx: TransactionBuilder): Promise<TransactionBuilder>;
|
5
|
+
export declare function rebalanceChoresBefore(client: SolautoClient, tx: TransactionBuilder, accountsGettingCreated: string[]): Promise<TransactionBuilder>;
|
6
6
|
export declare function getTransactionChores(client: SolautoClient, tx: TransactionBuilder): Promise<[TransactionBuilder, TransactionBuilder]>;
|
7
7
|
export declare function buildSolautoRebalanceTransaction(client: SolautoClient, targetLiqUtilizationRateBps?: number, attemptNum?: number): Promise<{
|
8
8
|
tx: TransactionBuilder;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,OAAO,IAAI,eAAe,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,aAAa,EASd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAqMzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,
|
1
|
+
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,OAAO,IAAI,eAAe,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,aAAa,EASd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAqMzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAgG7B;AAmLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA4BnD;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACE,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACD,SAAS,CACZ,CA4GA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,eAAe,GAC5B,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC,CA8BzC"}
|
@@ -41,8 +41,7 @@ function getWSolUsage(client, solautoActions, initiatingDcaIn, cancellingDcaIn)
|
|
41
41
|
return undefined;
|
42
42
|
}
|
43
43
|
}
|
44
|
-
async function transactionChoresBefore(client, solautoActions, initiatingDcaIn) {
|
45
|
-
const accountsGettingCreated = [];
|
44
|
+
async function transactionChoresBefore(client, accountsGettingCreated, solautoActions, initiatingDcaIn) {
|
46
45
|
let chores = (0, umi_1.transactionBuilder)();
|
47
46
|
if (client.authorityReferralStateData === null ||
|
48
47
|
(client.referredByState !== undefined &&
|
@@ -54,7 +53,7 @@ async function transactionChoresBefore(client, solautoActions, initiatingDcaIn)
|
|
54
53
|
chores = chores.add(client.updateReferralStatesIx());
|
55
54
|
}
|
56
55
|
if (client.selfManaged) {
|
57
|
-
if (client.solautoPositionData ===
|
56
|
+
if (client.solautoPositionData === null) {
|
58
57
|
chores = chores.add(client.openPosition());
|
59
58
|
}
|
60
59
|
else if (client.lendingPlatform === generated_1.LendingPlatform.Marginfi &&
|
@@ -111,7 +110,7 @@ async function transactionChoresBefore(client, solautoActions, initiatingDcaIn)
|
|
111
110
|
}
|
112
111
|
return chores;
|
113
112
|
}
|
114
|
-
async function rebalanceChoresBefore(client, tx) {
|
113
|
+
async function rebalanceChoresBefore(client, tx, accountsGettingCreated) {
|
115
114
|
const rebalanceInstructions = getRebalanceInstructions(tx);
|
116
115
|
if (rebalanceInstructions.length === 0) {
|
117
116
|
return (0, umi_1.transactionBuilder)();
|
@@ -149,13 +148,15 @@ async function rebalanceChoresBefore(client, tx) {
|
|
149
148
|
!(0, generalUtils_1.rpcAccountCreated)(intermediaryMarginfiAccount)) {
|
150
149
|
chores = chores.add(client.createIntermediaryMarginfiAccount());
|
151
150
|
}
|
152
|
-
if (checkSignerSupplyTa && !(0, generalUtils_1.rpcAccountCreated)(signerSupplyTa)) {
|
151
|
+
if (checkSignerSupplyTa && !(0, generalUtils_1.rpcAccountCreated)(signerSupplyTa) && !accountsGettingCreated.includes(signerSupplyTa.publicKey.toString())) {
|
153
152
|
client.log("Creating signer supply token account");
|
154
153
|
chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), client.supplyMint));
|
154
|
+
accountsGettingCreated.push(signerSupplyTa.publicKey.toString());
|
155
155
|
}
|
156
|
-
if (checkSignerDebtTa && !(0, generalUtils_1.rpcAccountCreated)(signerDebtTa)) {
|
156
|
+
if (checkSignerDebtTa && !(0, generalUtils_1.rpcAccountCreated)(signerDebtTa) && !accountsGettingCreated.includes(signerDebtTa.publicKey.toString())) {
|
157
157
|
client.log("Creating signer debt token account");
|
158
158
|
chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(client.signer.publicKey), client.debtMint));
|
159
|
+
accountsGettingCreated.push(signerDebtTa.publicKey.toString());
|
159
160
|
}
|
160
161
|
return chores;
|
161
162
|
}
|
@@ -302,12 +303,13 @@ function getSolautoActions(tx) {
|
|
302
303
|
async function getTransactionChores(client, tx) {
|
303
304
|
let choresBefore = (0, umi_1.transactionBuilder)();
|
304
305
|
let choresAfter = (0, umi_1.transactionBuilder)();
|
306
|
+
const accountsGettingCreated = [];
|
305
307
|
const solautoActions = getSolautoActions(tx);
|
306
308
|
choresBefore = choresBefore.add([
|
307
|
-
await transactionChoresBefore(client, solautoActions, client.livePositionUpdates.debtTaBalanceAdjustment > 0
|
309
|
+
await transactionChoresBefore(client, accountsGettingCreated, solautoActions, client.livePositionUpdates.debtTaBalanceAdjustment > 0
|
308
310
|
? client.livePositionUpdates.debtTaBalanceAdjustment
|
309
311
|
: undefined),
|
310
|
-
await rebalanceChoresBefore(client, tx),
|
312
|
+
await rebalanceChoresBefore(client, tx, accountsGettingCreated),
|
311
313
|
]);
|
312
314
|
choresAfter = choresAfter.add(transactionChoresAfter(client, solautoActions, client.livePositionUpdates.debtTaBalanceAdjustment < 0));
|
313
315
|
return [choresBefore, choresAfter];
|
@@ -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,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EACL,IAAI,EAKL,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,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AG,IAAI,EACrB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAsC3B;AAED,wBAAsB,iCAAiC,CACrD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,qBAAqB,CAAC,EAAE,OAAO,GAC9B,OAAO,CACR;IAAE,eAAe,EAAE,SAAS,CAAC;IAAC,UAAU,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,EAAE,CAC/E,CA6CA;AA0DD,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,CA4IpC;AA+DD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA0B3B"}
|
@@ -67,7 +67,6 @@ async function getAllMarginfiAccountsByAuthority(umi, authority, compatibleWithS
|
|
67
67
|
],
|
68
68
|
});
|
69
69
|
if (compatibleWithSolauto) {
|
70
|
-
console.log(marginfiAccounts);
|
71
70
|
const positionStates = await Promise.all(marginfiAccounts.map(async (x) => ({
|
72
71
|
publicKey: x.publicKey,
|
73
72
|
state: await getMarginfiAccountPositionState(umi, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.publicKey)),
|
package/package.json
CHANGED
@@ -215,9 +215,9 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
215
215
|
solautoPosition: publicKey(this.solautoPosition),
|
216
216
|
marginfiGroup: publicKey(this.marginfiGroup),
|
217
217
|
marginfiAccount:
|
218
|
-
this.
|
219
|
-
?
|
220
|
-
: (this.marginfiAccount
|
218
|
+
"publicKey" in this.marginfiAccount
|
219
|
+
? this.marginfiAccount as Signer
|
220
|
+
: publicKey(this.marginfiAccount),
|
221
221
|
supplyMint: publicKey(this.supplyMint),
|
222
222
|
supplyBank: publicKey(this.marginfiSupplyBankAccounts.bank),
|
223
223
|
positionSupplyTa: publicKey(this.positionSupplyTa),
|
@@ -230,7 +230,7 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
230
230
|
settingParams: settingParams ?? null,
|
231
231
|
dca: dca ?? null,
|
232
232
|
},
|
233
|
-
marginfiAccountSeedIdx: this.marginfiAccountSeedIdx
|
233
|
+
marginfiAccountSeedIdx: !this.selfManaged ? this.marginfiAccountSeedIdx : null,
|
234
234
|
});
|
235
235
|
}
|
236
236
|
|
@@ -261,7 +261,6 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
261
261
|
private marginfiProtocolInteractionIx(args: SolautoActionArgs) {
|
262
262
|
switch (args.__kind) {
|
263
263
|
case "Deposit": {
|
264
|
-
console.log(args.fields[0]);
|
265
264
|
return lendingAccountDeposit(this.umi, {
|
266
265
|
amount: args.fields[0],
|
267
266
|
signer: this.signer,
|
@@ -101,10 +101,10 @@ function getWSolUsage(
|
|
101
101
|
|
102
102
|
async function transactionChoresBefore(
|
103
103
|
client: SolautoClient,
|
104
|
+
accountsGettingCreated: string[],
|
104
105
|
solautoActions?: SolautoAction[],
|
105
|
-
initiatingDcaIn?: bigint
|
106
|
+
initiatingDcaIn?: bigint,
|
106
107
|
): Promise<TransactionBuilder> {
|
107
|
-
const accountsGettingCreated: string[] = [];
|
108
108
|
let chores = transactionBuilder();
|
109
109
|
|
110
110
|
if (
|
@@ -120,7 +120,7 @@ async function transactionChoresBefore(
|
|
120
120
|
}
|
121
121
|
|
122
122
|
if (client.selfManaged) {
|
123
|
-
if (client.solautoPositionData ===
|
123
|
+
if (client.solautoPositionData === null) {
|
124
124
|
chores = chores.add(client.openPosition());
|
125
125
|
} else if (
|
126
126
|
client.lendingPlatform === LendingPlatform.Marginfi &&
|
@@ -224,7 +224,8 @@ async function transactionChoresBefore(
|
|
224
224
|
|
225
225
|
export async function rebalanceChoresBefore(
|
226
226
|
client: SolautoClient,
|
227
|
-
tx: TransactionBuilder
|
227
|
+
tx: TransactionBuilder,
|
228
|
+
accountsGettingCreated: string[]
|
228
229
|
): Promise<TransactionBuilder> {
|
229
230
|
const rebalanceInstructions = getRebalanceInstructions(tx);
|
230
231
|
if (rebalanceInstructions.length === 0) {
|
@@ -296,7 +297,7 @@ export async function rebalanceChoresBefore(
|
|
296
297
|
);
|
297
298
|
}
|
298
299
|
|
299
|
-
if (checkSignerSupplyTa && !rpcAccountCreated(signerSupplyTa)) {
|
300
|
+
if (checkSignerSupplyTa && !rpcAccountCreated(signerSupplyTa) && !accountsGettingCreated.includes(signerSupplyTa.publicKey.toString())) {
|
300
301
|
client.log("Creating signer supply token account");
|
301
302
|
chores = chores.add(
|
302
303
|
createAssociatedTokenAccountUmiIx(
|
@@ -305,9 +306,10 @@ export async function rebalanceChoresBefore(
|
|
305
306
|
client.supplyMint
|
306
307
|
)
|
307
308
|
);
|
309
|
+
accountsGettingCreated.push(signerSupplyTa.publicKey.toString());
|
308
310
|
}
|
309
311
|
|
310
|
-
if (checkSignerDebtTa && !rpcAccountCreated(signerDebtTa)) {
|
312
|
+
if (checkSignerDebtTa && !rpcAccountCreated(signerDebtTa) && !accountsGettingCreated.includes(signerDebtTa.publicKey.toString())) {
|
311
313
|
client.log("Creating signer debt token account");
|
312
314
|
chores = chores.add(
|
313
315
|
createAssociatedTokenAccountUmiIx(
|
@@ -316,6 +318,7 @@ export async function rebalanceChoresBefore(
|
|
316
318
|
client.debtMint
|
317
319
|
)
|
318
320
|
);
|
321
|
+
accountsGettingCreated.push(signerDebtTa.publicKey.toString());
|
319
322
|
}
|
320
323
|
|
321
324
|
return chores;
|
@@ -504,18 +507,20 @@ export async function getTransactionChores(
|
|
504
507
|
): Promise<[TransactionBuilder, TransactionBuilder]> {
|
505
508
|
let choresBefore = transactionBuilder();
|
506
509
|
let choresAfter = transactionBuilder();
|
510
|
+
const accountsGettingCreated: string[] = [];
|
507
511
|
|
508
512
|
const solautoActions = getSolautoActions(tx);
|
509
513
|
|
510
514
|
choresBefore = choresBefore.add([
|
511
515
|
await transactionChoresBefore(
|
512
516
|
client,
|
517
|
+
accountsGettingCreated,
|
513
518
|
solautoActions,
|
514
519
|
client.livePositionUpdates.debtTaBalanceAdjustment > 0
|
515
520
|
? client.livePositionUpdates.debtTaBalanceAdjustment
|
516
|
-
: undefined
|
521
|
+
: undefined,
|
517
522
|
),
|
518
|
-
await rebalanceChoresBefore(client, tx),
|
523
|
+
await rebalanceChoresBefore(client, tx, accountsGettingCreated),
|
519
524
|
]);
|
520
525
|
|
521
526
|
choresAfter = choresAfter.add(
|