@haven-fi/solauto-sdk 1.0.218 → 1.0.220

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,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AAE,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.solautoFeesWallet = generalAccounts_1.SOLAUTO_FEES_WALLET;
47
- this.solautoFeesSupplyTa = (0, accountUtils_1.getTokenAccount)(this.solautoFeesWallet, this.supplyMint);
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,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,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,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
- solautoFeesSupplyTa: rebalanceStep === "B" ? (0, umi_1.publicKey)(this.solautoFeesSupplyTa) : undefined,
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
- referredBySupplyTa: this.referredBySupplyTa()
305
- ? (0, umi_1.publicKey)(this.referredBySupplyTa())
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
- solautoFeesSupplyTa?: PublicKey | Pda;
17
+ solautoFeesTa?: PublicKey | Pda;
18
18
  authorityReferralState: PublicKey | Pda;
19
- referredBySupplyTa?: PublicKey | Pda;
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,mBAAmB,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IACtC,sBAAsB,EAAE,SAAS,GAAG,GAAG,CAAC;IACxC,kBAAkB,CAAC,EAAE,S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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"}
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,aAAa,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAChC,sBAAsB,EAAE,SAAS,GAAG,GAAG,CAAC;IACxC,YAAY,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAC/B,iBAAiB,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IACpC,eAAe,EAAE,SAAS,GAAG,GAAG,CAAC;IACjC,aAAa,EAAE,SAAS,GAAG,GAAG,CAAC;IAC/B,eAAe,EAAE,SAAS,GAAG,GAAG,CAAC;IACjC,cAAc,CAAC,EAAE,SAAS,GAAG,GAAG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,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
- solautoFeesSupplyTa: {
55
+ solautoFeesTa: {
56
56
  index: 5,
57
57
  isWritable: true,
58
- value: input.solautoFeesSupplyTa ?? null,
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
- referredBySupplyTa: {
65
+ referredByTa: {
66
66
  index: 7,
67
67
  isWritable: true,
68
- value: input.referredBySupplyTa ?? null,
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;AAyCzD,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,CAiH7B;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,EA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C,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,9 @@ 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 checkSolautoFeesTa = usesAccount(client.solautoFeesSupplyTa);
130
+ const checkReferralDebtTa = client.referredByDebtTa() && usesAccount(client.referredByDebtTa());
131
+ const checkSolautoFeesSupplyTa = usesAccount(client.solautoFeesSupplyTa);
132
+ const checkSolautoFeesDebtTa = usesAccount(client.solautoFeesDebtTa);
131
133
  const checkIntermediaryMfiAccount = client.lendingPlatform === generated_1.LendingPlatform.Marginfi &&
132
134
  usesAccount(client.intermediaryMarginfiAccountPk);
133
135
  const checkSignerSupplyTa = usesAccount(client.signerSupplyTa);
@@ -136,7 +138,7 @@ async function rebalanceChoresBefore(client, tx, accountsGettingCreated) {
136
138
  ...[
137
139
  checkReferralSupplyTa ? client.referredBySupplyTa() : web3_js_1.PublicKey.default,
138
140
  ],
139
- ...[checkSolautoFeesTa ? client.solautoFeesSupplyTa : web3_js_1.PublicKey.default],
141
+ ...[checkReferralDebtTa ? client.referredByDebtTa() : web3_js_1.PublicKey.default],
140
142
  ...[
141
143
  checkIntermediaryMfiAccount
142
144
  ? client.intermediaryMarginfiAccountPk
@@ -145,15 +147,15 @@ async function rebalanceChoresBefore(client, tx, accountsGettingCreated) {
145
147
  ...[checkSignerSupplyTa ? client.signerSupplyTa : web3_js_1.PublicKey.default],
146
148
  ...[checkSignerDebtTa ? client.signerDebtTa : web3_js_1.PublicKey.default],
147
149
  ];
148
- const [referredBySupplyTa, solautoFeesSupplyTa, intermediaryMarginfiAccount, signerSupplyTa, signerDebtTa,] = await client.umi.rpc.getAccounts(accountsNeeded.map((x) => (0, umi_1.publicKey)(x ?? web3_js_1.PublicKey.default)));
150
+ 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
151
  let chores = (0, umi_1.transactionBuilder)();
150
152
  if (checkReferralSupplyTa && !(0, generalUtils_1.rpcAccountCreated)(referredBySupplyTa)) {
151
- client.log("Creating referred-by TA for ", client.supplyMint.toString());
153
+ client.log("Creating referred-by supply TA");
152
154
  chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.referredByState, client.supplyMint));
153
155
  }
154
- if (checkSolautoFeesTa && !(0, generalUtils_1.rpcAccountCreated)(solautoFeesSupplyTa)) {
155
- client.log("Creating Solauto fees TA for ", client.supplyMint.toString());
156
- chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.solautoFeesWallet, client.supplyMint));
156
+ if (checkReferralDebtTa && !(0, generalUtils_1.rpcAccountCreated)(referredByDebtTa)) {
157
+ client.log("Creating referred-by debt TA");
158
+ chores = chores.add((0, solanaUtils_1.createAssociatedTokenAccountUmiIx)(client.signer, client.referredByState, client.debtMint));
157
159
  }
158
160
  if (checkIntermediaryMfiAccount &&
159
161
  !(0, generalUtils_1.rpcAccountCreated)(intermediaryMarginfiAccount)) {
@@ -1,3 +1,4 @@
1
+ import { RebalanceDirection } from "../generated";
1
2
  export declare function getLiqUtilzationRateBps(supplyUsd: number, debtUsd: number, liqThresholdBps: number): number;
2
3
  export declare function toBaseUnit(value: number, decimals: number): bigint;
3
4
  export declare function fromBaseUnit(value: bigint, decimals: number): number;
@@ -6,7 +7,7 @@ export declare function toBps(value: number): number;
6
7
  export declare function bytesToI80F48(bytes: number[]): number;
7
8
  export declare function uint8ArrayToBigInt(uint8Array: Uint8Array): bigint;
8
9
  export declare function getDebtAdjustmentUsd(liqThresholdBps: number, supplyUsd: number, debtUsd: number, targetLiqUtilizationRateBps: number, adjustmentFeeBps?: number): number;
9
- export declare function getSolautoFeesBps(isReferred: boolean, targetLiqUtilizationRateBps: number | undefined, positionNetWorthUsd: number, rebalanceDirection: "boost" | "repay"): {
10
+ export declare function getSolautoFeesBps(isReferred: boolean, targetLiqUtilizationRateBps: number | undefined, positionNetWorthUsd: number, rebalanceDirection: RebalanceDirection): {
10
11
  solauto: number;
11
12
  referrer: number;
12
13
  total: number;
@@ -1 +1 @@
1
- {"version":3,"file":"numberUtils.d.ts","sourceRoot":"","sources":["../../src/utils/numberUtils.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,GACtB,MAAM,CAMR;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAqBrD;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAejE;AAED,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,2BAA2B,EAAE,MAAM,EACnC,gBAAgB,CAAC,EAAE,MAAM,UAW1B;A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AAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAejE;AAED,wBAAgB,oBAAoB,CAClC,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,2BAA2B,EAAE,MAAM,EACnC,gBAAgB,CAAC,EAAE,MAAM,UAW1B;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,OAAO,EACnB,2BAA2B,EAAE,MAAM,GAAG,SAAS,EAC/C,mBAAmB,EAAE,MAAM,EAC3B,kBAAkB,EAAE,kBAAkB,GACrC;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAgCA;AAED,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAER;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKzE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKvE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKvE"}
@@ -14,6 +14,7 @@ exports.maxRepayFromBps = maxRepayFromBps;
14
14
  exports.maxRepayToBps = maxRepayToBps;
15
15
  exports.maxBoostToBps = maxBoostToBps;
16
16
  const constants_1 = require("../constants");
17
+ const generated_1 = require("../generated");
17
18
  function getLiqUtilzationRateBps(supplyUsd, debtUsd, liqThresholdBps) {
18
19
  if (supplyUsd === 0) {
19
20
  return 0;
@@ -73,7 +74,7 @@ function getSolautoFeesBps(isReferred, targetLiqUtilizationRateBps, positionNetW
73
74
  const minFeeBps = 50; // Fee in basis points for maxSize (0.5%)
74
75
  const k = 1.5;
75
76
  let feeBps = 0;
76
- if (targetLiqUtilizationRateBps !== undefined || rebalanceDirection === "repay") {
77
+ if (targetLiqUtilizationRateBps !== undefined || rebalanceDirection === generated_1.RebalanceDirection.Repay) {
77
78
  feeBps = 25;
78
79
  }
79
80
  else if (positionNetWorthUsd <= minSize) {
@@ -1,17 +1,17 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import { SolautoClient } from "../../clients/solautoClient";
3
- import { DCASettings, PositionState, SolautoSettingsParameters, TokenType } from "../../generated";
3
+ import { DCASettings, PositionState, RebalanceDirection, SolautoSettingsParameters, TokenType } from "../../generated";
4
4
  import { QuoteResponse } from "@jup-ag/api";
5
5
  import { JupSwapDetails } from "../jupiterUtils";
6
6
  import { RebalanceAction } from "../../types";
7
7
  export interface RebalanceValues {
8
- increasingLeverage: boolean;
9
8
  debtAdjustmentUsd: number;
10
9
  repayingCloseToMaxLtv: boolean;
11
10
  amountToDcaIn: number;
12
11
  amountUsdToDcaIn: number;
13
12
  dcaTokenType?: TokenType;
14
13
  rebalanceAction: RebalanceAction;
14
+ rebalanceDirection: RebalanceDirection;
15
15
  }
16
16
  export declare function getRebalanceValues(state: PositionState, settings: SolautoSettingsParameters | undefined, dca: DCASettings | undefined, currentUnixTime: number, supplyPrice: number, debtPrice: number, targetLiqUtilizationRateBps?: number): RebalanceValues;
17
17
  export interface FlashLoanDetails {
@@ -1 +1 @@
1
- {"version":3,"file":"rebalanceUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/rebalanceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACL,WAAW,EACX,aAAa,EAEb,yBAAyB,EACzB,SAAS,EACV,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAajD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAk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AC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAajD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAkI9C,MAAM,WAAW,eAAe;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,eAAe,EAAE,eAAe,CAAC;IACjC,kBAAkB,EAAE,kBAAkB,CAAA;CACvC;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,yBAAyB,GAAG,SAAS,EAC/C,GAAG,EAAE,WAAW,GAAG,SAAS,EAC5B,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,2BAA2B,CAAC,EAAE,MAAM,GACnC,eAAe,CAgDjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,GACtB,gBAAgB,GAAG,SAAS,CA0D9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CAyChB"}
@@ -83,21 +83,21 @@ function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice,
83
83
  const { targetRateBps, amountToDcaIn } = getTargetRateAndDcaAmount(state, settings, dca, currentUnixTime, targetLiqUtilizationRateBps);
84
84
  const amountUsdToDcaIn = (0, numberUtils_1.fromBaseUnit)(BigInt(Math.round(amountToDcaIn ?? 0)), state.debt.decimals) *
85
85
  (dca?.tokenType === generated_1.TokenType.Debt ? debtPrice : supplyPrice);
86
- const increasingLeverage = amountUsdToDcaIn > 0 || state.liqUtilizationRateBps < targetRateBps;
87
- const adjustmentFeeBps = (0, numberUtils_1.getSolautoFeesBps)(false, targetLiqUtilizationRateBps, (0, numberUtils_1.fromBaseUnit)(state.netWorth.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS), increasingLeverage ? "boost" : "repay").total;
86
+ const rebalanceDirection = amountUsdToDcaIn > 0 || state.liqUtilizationRateBps < targetRateBps ? generated_1.RebalanceDirection.Boost : generated_1.RebalanceDirection.Repay;
87
+ const adjustmentFeeBps = (0, numberUtils_1.getSolautoFeesBps)(false, targetLiqUtilizationRateBps, (0, numberUtils_1.fromBaseUnit)(state.netWorth.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS), rebalanceDirection).total;
88
88
  const supplyUsd = (0, numberUtils_1.fromBaseUnit)(state.supply.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS) +
89
89
  amountUsdToDcaIn;
90
90
  const debtUsd = (0, numberUtils_1.fromBaseUnit)(state.debt.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS);
91
91
  let debtAdjustmentUsd = (0, numberUtils_1.getDebtAdjustmentUsd)(state.liqThresholdBps, supplyUsd, debtUsd, targetRateBps, adjustmentFeeBps);
92
92
  const maxRepayTo = (0, numberUtils_1.maxRepayToBps)(state.maxLtvBps, state.liqThresholdBps);
93
93
  return {
94
- increasingLeverage,
95
94
  debtAdjustmentUsd,
96
95
  repayingCloseToMaxLtv: state.liqUtilizationRateBps > maxRepayTo && targetRateBps >= maxRepayTo,
97
96
  amountToDcaIn: amountToDcaIn ?? 0,
98
97
  amountUsdToDcaIn,
99
98
  dcaTokenType: dca?.tokenType,
100
- rebalanceAction: (amountToDcaIn ?? 0) > 0 ? "dca" : increasingLeverage ? "boost" : "repay",
99
+ rebalanceAction: (amountToDcaIn ?? 0) > 0 ? "dca" : rebalanceDirection === generated_1.RebalanceDirection.Boost ? "boost" : "repay",
100
+ rebalanceDirection,
101
101
  };
102
102
  }
103
103
  function getFlashLoanDetails(client, values, jupQuote) {
@@ -115,7 +115,7 @@ function getFlashLoanDetails(client, values, jupQuote) {
115
115
  (0, numberUtils_1.getMaxLiqUtilizationRateBps)(client.solautoPositionState.maxLtvBps, client.solautoPositionState.liqThresholdBps, 0.01);
116
116
  let flashLoanToken = undefined;
117
117
  let flashLoanTokenPrice = 0;
118
- if (values.increasingLeverage) {
118
+ if (values.rebalanceDirection === generated_1.RebalanceDirection.Boost) {
119
119
  flashLoanToken = client.solautoPositionState.debt;
120
120
  flashLoanTokenPrice = (0, generalUtils_2.safeGetPrice)(client.debtMint);
121
121
  }
@@ -136,10 +136,10 @@ function getFlashLoanDetails(client, values, jupQuote) {
136
136
  : undefined;
137
137
  }
138
138
  function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps, attemptNum) {
139
- const input = values.increasingLeverage
139
+ const input = values.rebalanceDirection === generated_1.RebalanceDirection.Boost
140
140
  ? client.solautoPositionState.debt
141
141
  : client.solautoPositionState.supply;
142
- const output = values.increasingLeverage
142
+ const output = values.rebalanceDirection === generated_1.RebalanceDirection.Boost
143
143
  ? client.solautoPositionState.supply
144
144
  : client.solautoPositionState.debt;
145
145
  const usdToSwap = Math.abs(values.debtAdjustmentUsd) +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.218",
3
+ "version": "1.0.220",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Typescript SDK for the Solauto program on the Solana blockchain",
@@ -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
- this.solautoFeesWallet,
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
- solautoFeesSupplyTa:
483
- rebalanceStep === "B" ? publicKey(this.solautoFeesSupplyTa) : undefined,
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
- referredBySupplyTa: this.referredBySupplyTa()
486
- ? publicKey(this.referredBySupplyTa()!)
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
- solautoFeesSupplyTa?: PublicKey | Pda;
46
+ solautoFeesTa?: PublicKey | Pda;
47
47
  authorityReferralState: PublicKey | Pda;
48
- referredBySupplyTa?: PublicKey | Pda;
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
- solautoFeesSupplyTa: {
149
+ solautoFeesTa: {
150
150
  index: 5,
151
151
  isWritable: true as boolean,
152
- value: input.solautoFeesSupplyTa ?? null,
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
- referredBySupplyTa: {
159
+ referredByTa: {
160
160
  index: 7,
161
161
  isWritable: true as boolean,
162
- value: input.referredBySupplyTa ?? null,
162
+ value: input.referredByTa ?? null,
163
163
  },
164
164
  positionAuthority: {
165
165
  index: 8,
@@ -77,7 +77,7 @@ import {
77
77
  getJupiterErrorFromName,
78
78
  JUPITER_PROGRAM_ID,
79
79
  } from "../jupiter-sdk";
80
- import { PRICES } from "../constants";
80
+ import { PRICES, SOLAUTO_FEES_WALLET } from "../constants";
81
81
  import { TransactionItemInputs } from "../types";
82
82
 
83
83
  interface wSolTokenUsage {
@@ -276,7 +276,10 @@ export async function rebalanceChoresBefore(
276
276
 
277
277
  const checkReferralSupplyTa =
278
278
  client.referredBySupplyTa() && usesAccount(client.referredBySupplyTa()!);
279
- const checkSolautoFeesTa = usesAccount(client.solautoFeesSupplyTa);
279
+ const checkReferralDebtTa =
280
+ client.referredByDebtTa() && usesAccount(client.referredByDebtTa()!);
281
+ const checkSolautoFeesSupplyTa = usesAccount(client.solautoFeesSupplyTa);
282
+ const checkSolautoFeesDebtTa = usesAccount(client.solautoFeesDebtTa);
280
283
  const checkIntermediaryMfiAccount =
281
284
  client.lendingPlatform === LendingPlatform.Marginfi &&
282
285
  usesAccount(
@@ -289,7 +292,7 @@ export async function rebalanceChoresBefore(
289
292
  ...[
290
293
  checkReferralSupplyTa ? client.referredBySupplyTa() : PublicKey.default,
291
294
  ],
292
- ...[checkSolautoFeesTa ? client.solautoFeesSupplyTa : PublicKey.default],
295
+ ...[checkReferralDebtTa ? client.referredByDebtTa() : PublicKey.default],
293
296
  ...[
294
297
  checkIntermediaryMfiAccount
295
298
  ? (client as SolautoMarginfiClient).intermediaryMarginfiAccountPk
@@ -301,7 +304,7 @@ export async function rebalanceChoresBefore(
301
304
 
302
305
  const [
303
306
  referredBySupplyTa,
304
- solautoFeesSupplyTa,
307
+ referredByDebtTa,
305
308
  intermediaryMarginfiAccount,
306
309
  signerSupplyTa,
307
310
  signerDebtTa,
@@ -312,7 +315,7 @@ export async function rebalanceChoresBefore(
312
315
  let chores = transactionBuilder();
313
316
 
314
317
  if (checkReferralSupplyTa && !rpcAccountCreated(referredBySupplyTa)) {
315
- client.log("Creating referred-by TA for ", client.supplyMint.toString());
318
+ client.log("Creating referred-by supply TA");
316
319
  chores = chores.add(
317
320
  createAssociatedTokenAccountUmiIx(
318
321
  client.signer,
@@ -322,13 +325,13 @@ export async function rebalanceChoresBefore(
322
325
  );
323
326
  }
324
327
 
325
- if (checkSolautoFeesTa && !rpcAccountCreated(solautoFeesSupplyTa)) {
326
- client.log("Creating Solauto fees TA for ", client.supplyMint.toString());
328
+ if (checkReferralDebtTa && !rpcAccountCreated(referredByDebtTa)) {
329
+ client.log("Creating referred-by debt TA");
327
330
  chores = chores.add(
328
331
  createAssociatedTokenAccountUmiIx(
329
332
  client.signer,
330
- client.solautoFeesWallet,
331
- client.supplyMint
333
+ client.referredByState!,
334
+ client.debtMint
332
335
  )
333
336
  );
334
337
  }
@@ -1,4 +1,5 @@
1
1
  import { BASIS_POINTS, MIN_REPAY_GAP_BPS } from "../constants";
2
+ import { RebalanceDirection } from "../generated";
2
3
 
3
4
  export function getLiqUtilzationRateBps(
4
5
  supplyUsd: number,
@@ -90,7 +91,7 @@ export function getSolautoFeesBps(
90
91
  isReferred: boolean,
91
92
  targetLiqUtilizationRateBps: number | undefined,
92
93
  positionNetWorthUsd: number,
93
- rebalanceDirection: "boost" | "repay"
94
+ rebalanceDirection: RebalanceDirection
94
95
  ): {
95
96
  solauto: number;
96
97
  referrer: number;
@@ -104,7 +105,7 @@ export function getSolautoFeesBps(
104
105
 
105
106
  let feeBps: number = 0;
106
107
 
107
- if (targetLiqUtilizationRateBps !== undefined || rebalanceDirection === "repay") {
108
+ if (targetLiqUtilizationRateBps !== undefined || rebalanceDirection === RebalanceDirection.Repay) {
108
109
  feeBps = 25;
109
110
  } else if (positionNetWorthUsd <= minSize) {
110
111
  feeBps = maxFeeBps;
@@ -4,6 +4,7 @@ import {
4
4
  DCASettings,
5
5
  PositionState,
6
6
  PositionTokenUsage,
7
+ RebalanceDirection,
7
8
  SolautoSettingsParameters,
8
9
  TokenType,
9
10
  } from "../../generated";
@@ -158,13 +159,13 @@ function getTargetRateAndDcaAmount(
158
159
  }
159
160
 
160
161
  export interface RebalanceValues {
161
- increasingLeverage: boolean;
162
162
  debtAdjustmentUsd: number;
163
163
  repayingCloseToMaxLtv: boolean;
164
164
  amountToDcaIn: number;
165
165
  amountUsdToDcaIn: number;
166
166
  dcaTokenType?: TokenType;
167
167
  rebalanceAction: RebalanceAction;
168
+ rebalanceDirection: RebalanceDirection
168
169
  }
169
170
 
170
171
  export function getRebalanceValues(
@@ -188,13 +189,12 @@ export function getRebalanceValues(
188
189
  fromBaseUnit(BigInt(Math.round(amountToDcaIn ?? 0)), state.debt.decimals) *
189
190
  (dca?.tokenType === TokenType.Debt ? debtPrice : supplyPrice);
190
191
 
191
- const increasingLeverage =
192
- amountUsdToDcaIn > 0 || state.liqUtilizationRateBps < targetRateBps;
192
+ const rebalanceDirection = amountUsdToDcaIn > 0 || state.liqUtilizationRateBps < targetRateBps ? RebalanceDirection.Boost : RebalanceDirection.Repay;
193
193
  const adjustmentFeeBps = getSolautoFeesBps(
194
194
  false,
195
195
  targetLiqUtilizationRateBps,
196
196
  fromBaseUnit(state.netWorth.baseAmountUsdValue, USD_DECIMALS),
197
- increasingLeverage ? "boost" : "repay"
197
+ rebalanceDirection
198
198
  ).total;
199
199
 
200
200
  const supplyUsd =
@@ -214,7 +214,6 @@ export function getRebalanceValues(
214
214
 
215
215
  const maxRepayTo = maxRepayToBps(state.maxLtvBps, state.liqThresholdBps);
216
216
  return {
217
- increasingLeverage,
218
217
  debtAdjustmentUsd,
219
218
  repayingCloseToMaxLtv:
220
219
  state.liqUtilizationRateBps > maxRepayTo && targetRateBps >= maxRepayTo,
@@ -222,7 +221,8 @@ export function getRebalanceValues(
222
221
  amountUsdToDcaIn,
223
222
  dcaTokenType: dca?.tokenType,
224
223
  rebalanceAction:
225
- (amountToDcaIn ?? 0) > 0 ? "dca" : increasingLeverage ? "boost" : "repay",
224
+ (amountToDcaIn ?? 0) > 0 ? "dca" : rebalanceDirection === RebalanceDirection.Boost ? "boost" : "repay",
225
+ rebalanceDirection,
226
226
  };
227
227
  }
228
228
 
@@ -269,7 +269,7 @@ export function getFlashLoanDetails(
269
269
 
270
270
  let flashLoanToken: PositionTokenUsage | undefined = undefined;
271
271
  let flashLoanTokenPrice = 0;
272
- if (values.increasingLeverage) {
272
+ if (values.rebalanceDirection === RebalanceDirection.Boost) {
273
273
  flashLoanToken = client.solautoPositionState!.debt;
274
274
  flashLoanTokenPrice = safeGetPrice(client.debtMint)!;
275
275
  } else {
@@ -301,10 +301,10 @@ export function getJupSwapRebalanceDetails(
301
301
  targetLiqUtilizationRateBps?: number,
302
302
  attemptNum?: number
303
303
  ): JupSwapDetails {
304
- const input = values.increasingLeverage
304
+ const input = values.rebalanceDirection === RebalanceDirection.Boost
305
305
  ? client.solautoPositionState!.debt
306
306
  : client.solautoPositionState!.supply;
307
- const output = values.increasingLeverage
307
+ const output = values.rebalanceDirection === RebalanceDirection.Boost
308
308
  ? client.solautoPositionState!.supply
309
309
  : client.solautoPositionState!.debt;
310
310
 
@@ -25,10 +25,10 @@ import { buildHeliusApiUrl } from "../../src/utils";
25
25
  import { PriorityFeeSetting } from "../../src/types";
26
26
 
27
27
  describe("Solauto Marginfi tests", async () => {
28
- // const signer = setupTest();
29
- const signer = setupTest("solauto-manager");
28
+ const signer = setupTest();
29
+ // const signer = setupTest("solauto-manager");
30
30
 
31
- const payForTransactions = false;
31
+ const payForTransactions = true;
32
32
  const useJitoBundle = false;
33
33
  const positionId = 1;
34
34
 
@@ -128,7 +128,7 @@ describe("Solauto Marginfi tests", async () => {
128
128
  transactionItems.push(
129
129
  new TransactionItem(
130
130
  async (attemptNum) =>
131
- await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
131
+ await buildSolautoRebalanceTransaction(client, 7000, attemptNum),
132
132
  "rebalance"
133
133
  )
134
134
  );
@@ -165,6 +165,6 @@ describe("Solauto Marginfi tests", async () => {
165
165
  undefined,
166
166
  !payForTransactions ? "only-simulate" : "normal",
167
167
  useJitoBundle,
168
- ).clientSend(transactionItems, PriorityFeeSetting.Default);
168
+ ).clientSend(transactionItems, PriorityFeeSetting.High);
169
169
  });
170
170
  });
@@ -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 === DEFAULT_PUBKEY) {
25
+ if (key === PublicKey.default.toString()) {
26
26
  continue;
27
27
  }
28
28
 
29
- const tokenAccounts = MARGINFI_ACCOUNTS[key];
29
+ const accounts = MARGINFI_ACCOUNTS[group][key];
30
30
  const addresses = [
31
31
  new PublicKey(key),
32
- tokenAccounts.bank,
33
- tokenAccounts.liquidityVault,
34
- tokenAccounts.vaultAuthority,
35
- tokenAccounts.priceOracle,
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
 
@@ -46,7 +47,7 @@ function assertAccurateRebalance(
46
47
  targetLiqUtilizationRateBps?: number,
47
48
  expectedUsdToDcaIn?: number
48
49
  ) {
49
- const { increasingLeverage, debtAdjustmentUsd, amountUsdToDcaIn } =
50
+ const { rebalanceDirection, debtAdjustmentUsd, amountUsdToDcaIn } =
50
51
  getRebalanceValues(
51
52
  client.solautoPositionState!,
52
53
  client.solautoPositionSettings(),
@@ -58,17 +59,15 @@ function assertAccurateRebalance(
58
59
  );
59
60
 
60
61
  let adjustmentFeeBps = 0;
61
- if (increasingLeverage) {
62
- adjustmentFeeBps = getSolautoFeesBps(
63
- client.referredBy !== undefined,
64
- targetLiqUtilizationRateBps,
65
- fromBaseUnit(
66
- client.solautoPositionState?.netWorth.baseAmountUsdValue ?? BigInt(0),
67
- USD_DECIMALS
68
- ),
69
- increasingLeverage ? "boost" : "repay"
70
- ).total;
71
- }
62
+ adjustmentFeeBps = getSolautoFeesBps(
63
+ client.referredBy !== undefined,
64
+ targetLiqUtilizationRateBps,
65
+ fromBaseUnit(
66
+ client.solautoPositionState?.netWorth.baseAmountUsdValue ?? BigInt(0),
67
+ USD_DECIMALS
68
+ ),
69
+ rebalanceDirection
70
+ ).total;
72
71
 
73
72
  assert(
74
73
  Math.round(amountUsdToDcaIn) === Math.round(expectedUsdToDcaIn ?? 0),
@@ -110,7 +109,7 @@ async function getFakePosition(
110
109
  dca?: DCASettings
111
110
  ): Promise<SolautoClient> {
112
111
  const client = new SolautoMarginfiClient(
113
- process.env.HELIUS_API_KEY ?? "",
112
+ buildHeliusApiUrl(process.env.HELIUS_API_KEY!),
114
113
  true
115
114
  );
116
115
  await client.initialize({