@haven-fi/solauto-sdk 1.0.219 → 1.0.221
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/solautoClient.d.ts +2 -1
- package/dist/clients/solautoClient.d.ts.map +1 -1
- package/dist/clients/solautoClient.js +8 -2
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +9 -3
- package/dist/generated/instructions/marginfiRebalance.d.ts +2 -2
- package/dist/generated/instructions/marginfiRebalance.d.ts.map +1 -1
- package/dist/generated/instructions/marginfiRebalance.js +4 -4
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +7 -7
- package/dist/utils/generalUtils.d.ts.map +1 -1
- package/dist/utils/generalUtils.js +2 -4
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +1 -0
- package/package.json +1 -1
- package/src/clients/solautoClient.ts +13 -3
- package/src/clients/solautoMarginfiClient.ts +16 -4
- package/src/generated/instructions/marginfiRebalance.ts +6 -6
- package/src/transactions/transactionUtils.ts +10 -10
- package/src/utils/generalUtils.ts +2 -4
- package/src/utils/solanaUtils.ts +1 -0
- package/tests/transactions/solautoMarginfi.ts +1 -1
- package/tests/unit/lookupTables.ts +6 -6
- package/tests/unit/rebalanceCalculations.ts +2 -1
@@ -29,12 +29,13 @@ export declare abstract class SolautoClient extends ReferralStateManager {
|
|
29
29
|
debtMint: PublicKey;
|
30
30
|
positionDebtTa: PublicKey;
|
31
31
|
signerDebtTa: PublicKey;
|
32
|
-
solautoFeesWallet: PublicKey;
|
33
32
|
solautoFeesSupplyTa: PublicKey;
|
33
|
+
solautoFeesDebtTa: PublicKey;
|
34
34
|
authorityLutAddress?: PublicKey;
|
35
35
|
livePositionUpdates: LivePositionUpdates;
|
36
36
|
initialize(args: SolautoClientArgs): Promise<void>;
|
37
37
|
referredBySupplyTa(): PublicKey | undefined;
|
38
|
+
referredByDebtTa(): PublicKey | undefined;
|
38
39
|
resetLiveTxUpdates(success?: boolean): Promise<void>;
|
39
40
|
abstract protocolAccount(): PublicKey;
|
40
41
|
defaultLookupTables(): string[];
|
@@ -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,EAMnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAEhC,sBAAsB,EAKvB,MAAM,cAAc,CAAC;AAUtB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAMpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,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;CACtB;AAED,8BAAsB,aAAc,SAAQ,oBAAoB;IACvD,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC,SAAS,EAAG,SAAS,CAAC;IACtB,MAAM,EAAG,MAAM,CAAC;IAEhB,UAAU,EAAG,MAAM,CAAC;IACpB,WAAW,EAAG,OAAO,CAAC;IACtB,eAAe,EAAG,SAAS,CAAC;IAC5B,mBAAmB,EAAG,eAAe,GAAG,IAAI,CAAC;IAC7C,oBAAoB,EAAG,aAAa,GAAG,SAAS,CAAC;IAE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,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,eAAe,EAAE,eAAe,EAChC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,GACnC,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAalE"}
|
@@ -43,8 +43,8 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
|
|
43
43
|
: web3_js_1.PublicKey.default);
|
44
44
|
this.positionDebtTa = (0, accountUtils_1.getTokenAccount)(this.solautoPosition, this.debtMint);
|
45
45
|
this.signerDebtTa = (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.debtMint);
|
46
|
-
this.
|
47
|
-
this.
|
46
|
+
this.solautoFeesSupplyTa = (0, accountUtils_1.getTokenAccount)(generalAccounts_1.SOLAUTO_FEES_WALLET, this.supplyMint);
|
47
|
+
this.solautoFeesDebtTa = (0, accountUtils_1.getTokenAccount)(generalAccounts_1.SOLAUTO_FEES_WALLET, this.debtMint);
|
48
48
|
this.authorityLutAddress =
|
49
49
|
this.referralStateData?.lookupTable &&
|
50
50
|
!(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.referralStateData.lookupTable).equals(web3_js_1.PublicKey.default)
|
@@ -63,6 +63,12 @@ class SolautoClient extends referralStateManager_1.ReferralStateManager {
|
|
63
63
|
}
|
64
64
|
return undefined;
|
65
65
|
}
|
66
|
+
referredByDebtTa() {
|
67
|
+
if (this.referredByState !== undefined) {
|
68
|
+
return (0, accountUtils_1.getTokenAccount)(this.referredByState, this.debtMint);
|
69
|
+
}
|
70
|
+
return undefined;
|
71
|
+
}
|
66
72
|
async resetLiveTxUpdates(success) {
|
67
73
|
if (success) {
|
68
74
|
if (!this.solautoPositionData) {
|
@@ -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,
|
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,EAGb,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EAKjC,MAAM,cAAc,CAAC;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AAkB;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,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,wBAAwB,EACvC,eAAe,EAAE,eAAe,EAChC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,GACnC,kBAAkB;IAgFrB,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;CA6ClE"}
|
@@ -299,10 +299,16 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
299
299
|
signer: this.signer,
|
300
300
|
marginfiProgram: (0, umi_1.publicKey)(marginfi_sdk_1.MARGINFI_PROGRAM_ID),
|
301
301
|
ixsSysvar: (0, umi_1.publicKey)(web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY),
|
302
|
-
|
302
|
+
solautoFeesTa: rebalanceStep === "B"
|
303
|
+
? (0, umi_1.publicKey)(rebalanceValues.rebalanceDirection === generated_1.RebalanceDirection.Boost
|
304
|
+
? this.solautoFeesSupplyTa
|
305
|
+
: this.solautoFeesDebtTa)
|
306
|
+
: undefined,
|
303
307
|
authorityReferralState: (0, umi_1.publicKey)(this.referralState),
|
304
|
-
|
305
|
-
? (0, umi_1.publicKey)(
|
308
|
+
referredByTa: this.referredByState
|
309
|
+
? (0, umi_1.publicKey)(rebalanceValues.rebalanceDirection === generated_1.RebalanceDirection.Boost
|
310
|
+
? this.referredBySupplyTa()
|
311
|
+
: this.referredByDebtTa())
|
306
312
|
: undefined,
|
307
313
|
positionAuthority: rebalanceValues.rebalanceAction === "dca"
|
308
314
|
? (0, umi_1.publicKey)(this.authority)
|
@@ -14,9 +14,9 @@ export type MarginfiRebalanceInstructionAccounts = {
|
|
14
14
|
systemProgram?: PublicKey | Pda;
|
15
15
|
tokenProgram?: PublicKey | Pda;
|
16
16
|
ixsSysvar: PublicKey | Pda;
|
17
|
-
|
17
|
+
solautoFeesTa?: PublicKey | Pda;
|
18
18
|
authorityReferralState: PublicKey | Pda;
|
19
|
-
|
19
|
+
referredByTa?: PublicKey | Pda;
|
20
20
|
positionAuthority?: PublicKey | Pda;
|
21
21
|
solautoPosition: PublicKey | Pda;
|
22
22
|
marginfiGroup: PublicKey | Pda;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marginfiRebalance.d.ts","sourceRoot":"","sources":["../../../src/generated/instructions/marginfiRebalance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,OAAO,EACP,MAAM,EACN,gBAAgB,EAChB,GAAG,EACH,SAAS,EACT,MAAM,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,UAAU,EAOX,MAAM,sCAAsC,CAAC;AAM9C,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EAEzB,MAAM,UAAU,CAAC;AAGlB,MAAM,MAAM,oCAAoC,GAAG;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,SAAS,GAAG,GAAG,CAAC;IACjC,aAAa,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAChC,YAAY,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAC/B,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC;IAC3B,
|
1
|
+
{"version":3,"file":"marginfiRebalance.d.ts","sourceRoot":"","sources":["../../../src/generated/instructions/marginfiRebalance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,OAAO,EACP,MAAM,EACN,gBAAgB,EAChB,GAAG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,EAAE,SAAS,GAAG,GAAG,CAAC;IAClC,WAAW,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAC9B,kBAAkB,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;CACtC,CAAC;AAGF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,oBAAoB,CAAC;IACpC,2BAA2B,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,sBAAsB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,aAAa,EAAE,wBAAwB,CAAC;IACxC,2BAA2B,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACtD,sBAAsB,EAAE,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CAC3D,CAAC;AAEF,wBAAgB,6CAA6C,IAAI,UAAU,CACzE,oCAAoC,EACpC,gCAAgC,CACjC,CAoBA;AAGD,MAAM,MAAM,gCAAgC,GAC1C,oCAAoC,CAAC;AAGvC,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,EAClC,KAAK,EAAE,oCAAoC,GAAG,gCAAgC,GAC7E,kBAAkB,CAkLpB"}
|
@@ -52,20 +52,20 @@ function marginfiRebalance(context, input) {
|
|
52
52
|
isWritable: false,
|
53
53
|
value: input.ixsSysvar ?? null,
|
54
54
|
},
|
55
|
-
|
55
|
+
solautoFeesTa: {
|
56
56
|
index: 5,
|
57
57
|
isWritable: true,
|
58
|
-
value: input.
|
58
|
+
value: input.solautoFeesTa ?? null,
|
59
59
|
},
|
60
60
|
authorityReferralState: {
|
61
61
|
index: 6,
|
62
62
|
isWritable: false,
|
63
63
|
value: input.authorityReferralState ?? null,
|
64
64
|
},
|
65
|
-
|
65
|
+
referredByTa: {
|
66
66
|
index: 7,
|
67
67
|
isWritable: true,
|
68
|
-
value: input.
|
68
|
+
value: input.referredByTa ?? null,
|
69
69
|
},
|
70
70
|
positionAuthority: {
|
71
71
|
index: 8,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAInB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAuBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;
|
1
|
+
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAInB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAuBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAwCzD,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAO7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAqLjD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAkH7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,aAAa,oBA2CzE;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsH5C;AAED,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsC5C;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG;;;;EAwC9D"}
|
@@ -127,7 +127,7 @@ async function rebalanceChoresBefore(client, tx, accountsGettingCreated) {
|
|
127
127
|
.getInstructions()
|
128
128
|
.some((t) => t.keys.some((k) => (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(k.pubkey).equals(key)));
|
129
129
|
const checkReferralSupplyTa = client.referredBySupplyTa() && usesAccount(client.referredBySupplyTa());
|
130
|
-
const
|
130
|
+
const checkReferralDebtTa = client.referredByDebtTa() && usesAccount(client.referredByDebtTa());
|
131
131
|
const checkIntermediaryMfiAccount = client.lendingPlatform === generated_1.LendingPlatform.Marginfi &&
|
132
132
|
usesAccount(client.intermediaryMarginfiAccountPk);
|
133
133
|
const checkSignerSupplyTa = usesAccount(client.signerSupplyTa);
|
@@ -136,7 +136,7 @@ async function rebalanceChoresBefore(client, tx, accountsGettingCreated) {
|
|
136
136
|
...[
|
137
137
|
checkReferralSupplyTa ? client.referredBySupplyTa() : web3_js_1.PublicKey.default,
|
138
138
|
],
|
139
|
-
...[
|
139
|
+
...[checkReferralDebtTa ? client.referredByDebtTa() : web3_js_1.PublicKey.default],
|
140
140
|
...[
|
141
141
|
checkIntermediaryMfiAccount
|
142
142
|
? client.intermediaryMarginfiAccountPk
|
@@ -145,15 +145,15 @@ async function rebalanceChoresBefore(client, tx, accountsGettingCreated) {
|
|
145
145
|
...[checkSignerSupplyTa ? client.signerSupplyTa : web3_js_1.PublicKey.default],
|
146
146
|
...[checkSignerDebtTa ? client.signerDebtTa : web3_js_1.PublicKey.default],
|
147
147
|
];
|
148
|
-
const [referredBySupplyTa,
|
148
|
+
const [referredBySupplyTa, referredByDebtTa, intermediaryMarginfiAccount, signerSupplyTa, signerDebtTa,] = await client.umi.rpc.getAccounts(accountsNeeded.map((x) => (0, umi_1.publicKey)(x ?? web3_js_1.PublicKey.default)));
|
149
149
|
let chores = (0, umi_1.transactionBuilder)();
|
150
150
|
if (checkReferralSupplyTa && !(0, generalUtils_1.rpcAccountCreated)(referredBySupplyTa)) {
|
151
|
-
client.log("Creating referred-by TA
|
151
|
+
client.log("Creating referred-by supply TA");
|
152
152
|
chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.referredByState, client.supplyMint));
|
153
153
|
}
|
154
|
-
if (
|
155
|
-
client.log("Creating
|
156
|
-
chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.
|
154
|
+
if (checkReferralDebtTa && !(0, generalUtils_1.rpcAccountCreated)(referredByDebtTa)) {
|
155
|
+
client.log("Creating referred-by debt TA");
|
156
|
+
chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.referredByState, client.debtMint));
|
157
157
|
}
|
158
158
|
if (checkIntermediaryMfiAccount &&
|
159
159
|
!(0, generalUtils_1.rpcAccountCreated)(intermediaryMarginfiAccount)) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,eAAe,EAEf,GAAG,EACH,SAAS,IAAI,YAAY,EAC1B,MAAM,0BAA0B,CAAC;AAKlC,wBAAgB,UAAU,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAI/C;AACD,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAO1C;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,SAAS,GACZ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,EAAE,GAAG,EAAE,KAAK,KAAK,CAAC,CAAC;AAEjE,wBAAgB,2BAA2B,CAAC,CAAC,EAC3C,EAAE,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EACtC,OAAO,GAAE,MAAU,EACnB,KAAK,GAAE,MAAY,EACnB,aAAa,CAAC,EAAE,aAAa,GAC5B,OAAO,CAAC,CAAC,CAAC,CA8BZ"}
|
@@ -64,10 +64,8 @@ async function fetchTokenPrices(mints) {
|
|
64
64
|
const prices = await retryWithExponentialBackoff(async () => {
|
65
65
|
let resp = await getReq();
|
66
66
|
let status = resp.status;
|
67
|
-
|
68
|
-
|
69
|
-
resp = await getReq();
|
70
|
-
status = resp.status;
|
67
|
+
if (status !== 200) {
|
68
|
+
throw new Error(JSON.stringify(resp));
|
71
69
|
}
|
72
70
|
const json = await resp.json();
|
73
71
|
const prices = json.parsed.map((x) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,GAAG,EACH,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAGL,UAAU,EACV,SAAS,EAIT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAYzB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAElE,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,UAErD;AAED,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,MAAM,UAE3D;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,GACb,CAAC,UAAU,EAAE,GAAG,CAAC,CAInB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,sBAAsB,GACzB,kBAAkB,CAMpB;AAED,wBAAgB,wBAAwB,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nB,kBAAkB,CAKpB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,GACb,kBAAkB,CAKpB;AAED,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,GAAG,EACR,oBAAoB,EAAE,MAAM,EAAE,GAC7B,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAkBpC;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,kBAAkB,EACtB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,CAAC,EAAE,MAAM,sBA4D1B;AAmBD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,kBAAkB,EACtB,eAAe,EAAE,kBAAkB,GAClC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAsB7B;AAED,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,kBAAkB,EACtB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,UAAU,CAAC,EAAE,MAAM,EACnB,eAAe,GAAE,kBAA+C,EAChE,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAmEjC"}
|
package/package.json
CHANGED
@@ -79,8 +79,8 @@ export abstract class SolautoClient extends ReferralStateManager {
|
|
79
79
|
public positionDebtTa!: PublicKey;
|
80
80
|
public signerDebtTa!: PublicKey;
|
81
81
|
|
82
|
-
public solautoFeesWallet!: PublicKey;
|
83
82
|
public solautoFeesSupplyTa!: PublicKey;
|
83
|
+
public solautoFeesDebtTa!: PublicKey;
|
84
84
|
|
85
85
|
public authorityLutAddress?: PublicKey;
|
86
86
|
|
@@ -132,11 +132,14 @@ export abstract class SolautoClient extends ReferralStateManager {
|
|
132
132
|
this.debtMint
|
133
133
|
);
|
134
134
|
|
135
|
-
this.solautoFeesWallet = SOLAUTO_FEES_WALLET;
|
136
135
|
this.solautoFeesSupplyTa = getTokenAccount(
|
137
|
-
|
136
|
+
SOLAUTO_FEES_WALLET,
|
138
137
|
this.supplyMint
|
139
138
|
);
|
139
|
+
this.solautoFeesDebtTa = getTokenAccount(
|
140
|
+
SOLAUTO_FEES_WALLET,
|
141
|
+
this.debtMint
|
142
|
+
);
|
140
143
|
|
141
144
|
this.authorityLutAddress =
|
142
145
|
this.referralStateData?.lookupTable &&
|
@@ -166,6 +169,13 @@ export abstract class SolautoClient extends ReferralStateManager {
|
|
166
169
|
}
|
167
170
|
return undefined;
|
168
171
|
}
|
172
|
+
|
173
|
+
referredByDebtTa(): PublicKey | undefined {
|
174
|
+
if (this.referredByState !== undefined) {
|
175
|
+
return getTokenAccount(this.referredByState, this.debtMint);
|
176
|
+
}
|
177
|
+
return undefined;
|
178
|
+
}
|
169
179
|
|
170
180
|
async resetLiveTxUpdates(success?: boolean) {
|
171
181
|
if (success) {
|
@@ -24,6 +24,7 @@ import {
|
|
24
24
|
LendingPlatform,
|
25
25
|
PositionState,
|
26
26
|
PositionType,
|
27
|
+
RebalanceDirection,
|
27
28
|
SolautoActionArgs,
|
28
29
|
SolautoRebalanceTypeArgs,
|
29
30
|
SolautoSettingsParametersInpArgs,
|
@@ -63,6 +64,7 @@ import {
|
|
63
64
|
} from "../utils/marginfiUtils";
|
64
65
|
import { bytesToI80F48, fromBaseUnit, toBps } from "../utils/numberUtils";
|
65
66
|
import { QuoteResponse } from "@jup-ag/api";
|
67
|
+
import { SOLAUTO_FEES_WALLET } from "../constants";
|
66
68
|
|
67
69
|
export interface SolautoMarginfiClientArgs extends SolautoClientArgs {
|
68
70
|
marginfiAccount?: PublicKey | Signer;
|
@@ -479,11 +481,21 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
479
481
|
signer: this.signer,
|
480
482
|
marginfiProgram: publicKey(MARGINFI_PROGRAM_ID),
|
481
483
|
ixsSysvar: publicKey(SYSVAR_INSTRUCTIONS_PUBKEY),
|
482
|
-
|
483
|
-
rebalanceStep === "B"
|
484
|
+
solautoFeesTa:
|
485
|
+
rebalanceStep === "B"
|
486
|
+
? publicKey(
|
487
|
+
rebalanceValues.rebalanceDirection === RebalanceDirection.Boost
|
488
|
+
? this.solautoFeesSupplyTa
|
489
|
+
: this.solautoFeesDebtTa
|
490
|
+
)
|
491
|
+
: undefined,
|
484
492
|
authorityReferralState: publicKey(this.referralState),
|
485
|
-
|
486
|
-
? publicKey(
|
493
|
+
referredByTa: this.referredByState
|
494
|
+
? publicKey(
|
495
|
+
rebalanceValues.rebalanceDirection === RebalanceDirection.Boost
|
496
|
+
? this.referredBySupplyTa()!
|
497
|
+
: this.referredByDebtTa()!
|
498
|
+
)
|
487
499
|
: undefined,
|
488
500
|
positionAuthority:
|
489
501
|
rebalanceValues.rebalanceAction === "dca"
|
@@ -43,9 +43,9 @@ export type MarginfiRebalanceInstructionAccounts = {
|
|
43
43
|
systemProgram?: PublicKey | Pda;
|
44
44
|
tokenProgram?: PublicKey | Pda;
|
45
45
|
ixsSysvar: PublicKey | Pda;
|
46
|
-
|
46
|
+
solautoFeesTa?: PublicKey | Pda;
|
47
47
|
authorityReferralState: PublicKey | Pda;
|
48
|
-
|
48
|
+
referredByTa?: PublicKey | Pda;
|
49
49
|
positionAuthority?: PublicKey | Pda;
|
50
50
|
solautoPosition: PublicKey | Pda;
|
51
51
|
marginfiGroup: PublicKey | Pda;
|
@@ -146,20 +146,20 @@ export function marginfiRebalance(
|
|
146
146
|
isWritable: false as boolean,
|
147
147
|
value: input.ixsSysvar ?? null,
|
148
148
|
},
|
149
|
-
|
149
|
+
solautoFeesTa: {
|
150
150
|
index: 5,
|
151
151
|
isWritable: true as boolean,
|
152
|
-
value: input.
|
152
|
+
value: input.solautoFeesTa ?? null,
|
153
153
|
},
|
154
154
|
authorityReferralState: {
|
155
155
|
index: 6,
|
156
156
|
isWritable: false as boolean,
|
157
157
|
value: input.authorityReferralState ?? null,
|
158
158
|
},
|
159
|
-
|
159
|
+
referredByTa: {
|
160
160
|
index: 7,
|
161
161
|
isWritable: true as boolean,
|
162
|
-
value: input.
|
162
|
+
value: input.referredByTa ?? null,
|
163
163
|
},
|
164
164
|
positionAuthority: {
|
165
165
|
index: 8,
|
@@ -58,7 +58,6 @@ import {
|
|
58
58
|
positionStateWithLatestPrices,
|
59
59
|
} from "../utils/solauto/generalUtils";
|
60
60
|
import {
|
61
|
-
getReferralState,
|
62
61
|
getTokenAccount,
|
63
62
|
getTokenAccountData,
|
64
63
|
} from "../utils/accountUtils";
|
@@ -77,7 +76,7 @@ import {
|
|
77
76
|
getJupiterErrorFromName,
|
78
77
|
JUPITER_PROGRAM_ID,
|
79
78
|
} from "../jupiter-sdk";
|
80
|
-
import { PRICES } from "../constants";
|
79
|
+
import { PRICES, SOLAUTO_FEES_WALLET } from "../constants";
|
81
80
|
import { TransactionItemInputs } from "../types";
|
82
81
|
|
83
82
|
interface wSolTokenUsage {
|
@@ -276,7 +275,8 @@ export async function rebalanceChoresBefore(
|
|
276
275
|
|
277
276
|
const checkReferralSupplyTa =
|
278
277
|
client.referredBySupplyTa() && usesAccount(client.referredBySupplyTa()!);
|
279
|
-
const
|
278
|
+
const checkReferralDebtTa =
|
279
|
+
client.referredByDebtTa() && usesAccount(client.referredByDebtTa()!);
|
280
280
|
const checkIntermediaryMfiAccount =
|
281
281
|
client.lendingPlatform === LendingPlatform.Marginfi &&
|
282
282
|
usesAccount(
|
@@ -289,7 +289,7 @@ export async function rebalanceChoresBefore(
|
|
289
289
|
...[
|
290
290
|
checkReferralSupplyTa ? client.referredBySupplyTa() : PublicKey.default,
|
291
291
|
],
|
292
|
-
...[
|
292
|
+
...[checkReferralDebtTa ? client.referredByDebtTa() : PublicKey.default],
|
293
293
|
...[
|
294
294
|
checkIntermediaryMfiAccount
|
295
295
|
? (client as SolautoMarginfiClient).intermediaryMarginfiAccountPk
|
@@ -301,7 +301,7 @@ export async function rebalanceChoresBefore(
|
|
301
301
|
|
302
302
|
const [
|
303
303
|
referredBySupplyTa,
|
304
|
-
|
304
|
+
referredByDebtTa,
|
305
305
|
intermediaryMarginfiAccount,
|
306
306
|
signerSupplyTa,
|
307
307
|
signerDebtTa,
|
@@ -312,7 +312,7 @@ export async function rebalanceChoresBefore(
|
|
312
312
|
let chores = transactionBuilder();
|
313
313
|
|
314
314
|
if (checkReferralSupplyTa && !rpcAccountCreated(referredBySupplyTa)) {
|
315
|
-
client.log("Creating referred-by TA
|
315
|
+
client.log("Creating referred-by supply TA");
|
316
316
|
chores = chores.add(
|
317
317
|
createAssociatedTokenAccountUmiIx(
|
318
318
|
client.signer,
|
@@ -322,13 +322,13 @@ export async function rebalanceChoresBefore(
|
|
322
322
|
);
|
323
323
|
}
|
324
324
|
|
325
|
-
if (
|
326
|
-
client.log("Creating
|
325
|
+
if (checkReferralDebtTa && !rpcAccountCreated(referredByDebtTa)) {
|
326
|
+
client.log("Creating referred-by debt TA");
|
327
327
|
chores = chores.add(
|
328
328
|
createAssociatedTokenAccountUmiIx(
|
329
329
|
client.signer,
|
330
|
-
client.
|
331
|
-
client.
|
330
|
+
client.referredByState!,
|
331
|
+
client.debtMint
|
332
332
|
)
|
333
333
|
);
|
334
334
|
}
|
@@ -82,10 +82,8 @@ export async function fetchTokenPrices(mints: PublicKey[]): Promise<number[]> {
|
|
82
82
|
async () => {
|
83
83
|
let resp = await getReq();
|
84
84
|
let status = resp.status;
|
85
|
-
|
86
|
-
|
87
|
-
resp = await getReq();
|
88
|
-
status = resp.status;
|
85
|
+
if (status !== 200) {
|
86
|
+
throw new Error(JSON.stringify(resp));
|
89
87
|
}
|
90
88
|
|
91
89
|
const json = await resp.json();
|
package/src/utils/solanaUtils.ts
CHANGED
@@ -28,7 +28,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
28
28
|
// const signer = setupTest();
|
29
29
|
const signer = setupTest("solauto-manager");
|
30
30
|
|
31
|
-
const payForTransactions =
|
31
|
+
const payForTransactions = true;
|
32
32
|
const useJitoBundle = false;
|
33
33
|
const positionId = 1;
|
34
34
|
|
@@ -22,17 +22,17 @@ describe("Assert lookup tables up-to-date", async () => {
|
|
22
22
|
|
23
23
|
for (const group in MARGINFI_ACCOUNTS) {
|
24
24
|
for (const key in MARGINFI_ACCOUNTS[group]) {
|
25
|
-
if (key ===
|
25
|
+
if (key === PublicKey.default.toString()) {
|
26
26
|
continue;
|
27
27
|
}
|
28
28
|
|
29
|
-
const
|
29
|
+
const accounts = MARGINFI_ACCOUNTS[group][key];
|
30
30
|
const addresses = [
|
31
31
|
new PublicKey(key),
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
accounts.bank,
|
33
|
+
accounts.liquidityVault,
|
34
|
+
accounts.vaultAuthority,
|
35
|
+
accounts.priceOracle,
|
36
36
|
];
|
37
37
|
|
38
38
|
if (addresses.find((x) => !existingAccounts.includes(x.toString()))) {
|
@@ -37,6 +37,7 @@ import {
|
|
37
37
|
safeGetPrice,
|
38
38
|
} from "../../src/utils/generalUtils";
|
39
39
|
import { USDC } from "../../src/constants/tokenConstants";
|
40
|
+
import { buildHeliusApiUrl } from "../../src/utils";
|
40
41
|
|
41
42
|
const signer = setupTest(undefined, true);
|
42
43
|
|
@@ -108,7 +109,7 @@ async function getFakePosition(
|
|
108
109
|
dca?: DCASettings
|
109
110
|
): Promise<SolautoClient> {
|
110
111
|
const client = new SolautoMarginfiClient(
|
111
|
-
process.env.HELIUS_API_KEY
|
112
|
+
buildHeliusApiUrl(process.env.HELIUS_API_KEY!),
|
112
113
|
true
|
113
114
|
);
|
114
115
|
await client.initialize({
|