@haven-fi/solauto-sdk 1.0.146 → 1.0.148

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/dist/clients/referralStateManager.d.ts +1 -1
  2. package/dist/clients/referralStateManager.js +2 -2
  3. package/dist/clients/solautoClient.d.ts +1 -1
  4. package/dist/clients/solautoClient.js +3 -3
  5. package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
  6. package/dist/clients/solautoMarginfiClient.js +2 -1
  7. package/dist/clients/txHandler.d.ts +2 -2
  8. package/dist/clients/txHandler.d.ts.map +1 -1
  9. package/dist/clients/txHandler.js +3 -3
  10. package/dist/generated/accounts/solautoPosition.d.ts +4 -1
  11. package/dist/generated/accounts/solautoPosition.d.ts.map +1 -1
  12. package/dist/generated/accounts/solautoPosition.js +4 -2
  13. package/dist/generated/instructions/marginfiOpenPosition.d.ts +3 -1
  14. package/dist/generated/instructions/marginfiOpenPosition.d.ts.map +1 -1
  15. package/dist/generated/instructions/marginfiOpenPosition.js +1 -0
  16. package/dist/generated/types/index.d.ts +1 -0
  17. package/dist/generated/types/index.d.ts.map +1 -1
  18. package/dist/generated/types/index.js +1 -0
  19. package/dist/generated/types/positionType.d.ts +15 -0
  20. package/dist/generated/types/positionType.d.ts.map +1 -0
  21. package/dist/generated/types/positionType.js +22 -0
  22. package/dist/types/solauto.d.ts +2 -1
  23. package/dist/types/solauto.d.ts.map +1 -1
  24. package/dist/utils/marginfiUtils.d.ts.map +1 -1
  25. package/dist/utils/marginfiUtils.js +8 -2
  26. package/dist/utils/solanaUtils.d.ts +2 -1
  27. package/dist/utils/solanaUtils.d.ts.map +1 -1
  28. package/dist/utils/solanaUtils.js +6 -2
  29. package/dist/utils/solauto/generalUtils.d.ts +3 -3
  30. package/dist/utils/solauto/generalUtils.d.ts.map +1 -1
  31. package/dist/utils/solauto/generalUtils.js +19 -5
  32. package/local/createSolautoManagerAccount.ts +2 -1
  33. package/local/shared.ts +2 -2
  34. package/package.json +1 -1
  35. package/src/clients/referralStateManager.ts +2 -2
  36. package/src/clients/solautoClient.ts +3 -3
  37. package/src/clients/solautoMarginfiClient.ts +4 -1
  38. package/src/clients/txHandler.ts +10 -9
  39. package/src/generated/accounts/solautoPosition.ts +10 -2
  40. package/src/generated/instructions/marginfiOpenPosition.ts +6 -0
  41. package/src/generated/types/index.ts +1 -0
  42. package/src/generated/types/positionType.ts +25 -0
  43. package/src/types/solauto.ts +2 -1
  44. package/src/utils/marginfiUtils.ts +43 -26
  45. package/src/utils/solanaUtils.ts +8 -7
  46. package/src/utils/solauto/generalUtils.ts +24 -6
  47. package/tests/transactions/solautoMarginfi.ts +3 -2
@@ -15,7 +15,7 @@ export declare class ReferralStateManager extends TxHandler {
15
15
  referralAuthority: PublicKey;
16
16
  referralState: PublicKey;
17
17
  referralStateData: ReferralState | null;
18
- constructor(heliusApiKey: string, localTest?: boolean | undefined);
18
+ constructor(heliusApiUrl: string, localTest?: boolean | undefined);
19
19
  initialize(args: ReferralStateManagerArgs): Promise<void>;
20
20
  defaultLookupTables(): string[];
21
21
  updateReferralStatesIx(destFeesMint?: PublicKey, referredBy?: PublicKey, lookupTable?: PublicKey): TransactionBuilder;
@@ -9,8 +9,8 @@ const generated_1 = require("../generated");
9
9
  const utils_1 = require("../utils");
10
10
  const txHandler_1 = require("./txHandler");
11
11
  class ReferralStateManager extends txHandler_1.TxHandler {
12
- constructor(heliusApiKey, localTest) {
13
- super(heliusApiKey, localTest);
12
+ constructor(heliusApiUrl, localTest) {
13
+ super(heliusApiUrl, localTest);
14
14
  this.localTest = localTest;
15
15
  this.umi = this.umi.use({
16
16
  install(umi) {
@@ -41,7 +41,7 @@ export declare abstract class SolautoClient extends TxHandler {
41
41
  solautoFeesSupplyTa: PublicKey;
42
42
  authorityLutAddress?: PublicKey;
43
43
  livePositionUpdates: LivePositionUpdates;
44
- constructor(heliusApiKey: string, localTest?: boolean | undefined);
44
+ constructor(heliusApiUrl: string, localTest?: boolean | undefined);
45
45
  initialize(args: SolautoClientArgs, lendingPlatform: LendingPlatform): Promise<void>;
46
46
  resetLiveTxUpdates(success?: boolean): Promise<void>;
47
47
  abstract protocolAccount(): PublicKey;
@@ -16,8 +16,8 @@ const generalUtils_2 = require("../utils/solauto/generalUtils");
16
16
  const referralStateManager_1 = require("./referralStateManager");
17
17
  const txHandler_1 = require("./txHandler");
18
18
  class SolautoClient extends txHandler_1.TxHandler {
19
- constructor(heliusApiKey, localTest) {
20
- super(heliusApiKey, localTest);
19
+ constructor(heliusApiUrl, localTest) {
20
+ super(heliusApiUrl, localTest);
21
21
  this.localTest = localTest;
22
22
  this.livePositionUpdates = new generalUtils_2.LivePositionUpdates();
23
23
  this.umi = this.umi.use({
@@ -55,7 +55,7 @@ class SolautoClient extends txHandler_1.TxHandler {
55
55
  : web3_js_1.PublicKey.default);
56
56
  this.positionDebtTa = (0, accountUtils_1.getTokenAccount)(this.solautoPosition, this.debtMint);
57
57
  this.signerDebtTa = (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.debtMint);
58
- this.referralStateManager = new referralStateManager_1.ReferralStateManager(this.heliusApiKey);
58
+ this.referralStateManager = new referralStateManager_1.ReferralStateManager(this.heliusApiUrl);
59
59
  await this.referralStateManager.initialize({
60
60
  referralAuthority: this.authority,
61
61
  signer: args.signer,
@@ -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,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,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;CA4BlE"}
@@ -109,7 +109,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
109
109
  .openPosition(settingParams, dca)
110
110
  .add(this.marginfiOpenPositionIx(settingParams, dca));
111
111
  }
112
- marginfiOpenPositionIx(settingParams, dca) {
112
+ marginfiOpenPositionIx(settingParams, dca, positionType) {
113
113
  let signerDebtTa = undefined;
114
114
  if (dca) {
115
115
  signerDebtTa = (0, umi_1.publicKey)(this.signerDebtTa);
@@ -138,6 +138,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
138
138
  debtBank: (0, umi_1.publicKey)(this.marginfiDebtAccounts.bank),
139
139
  positionDebtTa: (0, umi_1.publicKey)(this.positionDebtTa),
140
140
  signerDebtTa: signerDebtTa,
141
+ positionType: positionType ?? generated_1.PositionType.Leverage,
141
142
  positionData: {
142
143
  positionId: this.positionId,
143
144
  settingParams: settingParams ?? null,
@@ -2,10 +2,10 @@ import { Umi } from "@metaplex-foundation/umi";
2
2
  import { Connection } from "@solana/web3.js";
3
3
  export declare abstract class TxHandler {
4
4
  localTest?: boolean | undefined;
5
- heliusApiKey: string;
5
+ heliusApiUrl: string;
6
6
  umi: Umi;
7
7
  connection: Connection;
8
- constructor(heliusApiKey: string, localTest?: boolean | undefined);
8
+ constructor(heliusApiUrl: string, localTest?: boolean | undefined);
9
9
  log(...args: any[]): void;
10
10
  abstract defaultLookupTables(): string[];
11
11
  abstract resetLiveTxUpdates(success?: boolean): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../src/clients/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,8BAAsB,SAAS;IAMpB,SAAS,CAAC,EAAE,OAAO;IALrB,YAAY,EAAG,MAAM,CAAC;IACtB,GAAG,EAAG,GAAG,CAAC;IACV,UAAU,EAAG,UAAU,CAAC;gBAEnB,YAAY,EAAE,MAAM,EACvB,SAAS,CAAC,EAAE,OAAO,YAAA;IAO5B,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAMzB,QAAQ,CAAC,mBAAmB,IAAI,MAAM,EAAE;IAExC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC9D"}
1
+ {"version":3,"file":"txHandler.d.ts","sourceRoot":"","sources":["../../src/clients/txHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,8BAAsB,SAAS;IAOpB,SAAS,CAAC,EAAE,OAAO;IANrB,YAAY,EAAG,MAAM,CAAC;IACtB,GAAG,EAAG,GAAG,CAAC;IACV,UAAU,EAAG,UAAU,CAAC;gBAG7B,YAAY,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,OAAO,YAAA;IAQ5B,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAMzB,QAAQ,CAAC,mBAAmB,IAAI,MAAM,EAAE;IAExC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC9D"}
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TxHandler = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  class TxHandler {
6
- constructor(heliusApiKey, localTest) {
6
+ constructor(heliusApiUrl, localTest) {
7
7
  this.localTest = localTest;
8
- this.heliusApiKey = heliusApiKey;
9
- const [connection, umi] = (0, utils_1.getSolanaRpcConnection)(this.heliusApiKey);
8
+ this.heliusApiUrl = heliusApiUrl;
9
+ const [connection, umi] = (0, utils_1.getSolanaRpcConnection)(this.heliusApiUrl);
10
10
  this.connection = connection;
11
11
  this.umi = umi;
12
12
  }
@@ -7,12 +7,13 @@
7
7
  */
8
8
  import { Account, Context, Pda, PublicKey, RpcAccount, RpcGetAccountOptions, RpcGetAccountsOptions } from '@metaplex-foundation/umi';
9
9
  import { Serializer } from '@metaplex-foundation/umi/serializers';
10
- import { PodBool, PodBoolArgs, PositionData, PositionDataArgs, PositionState, PositionStateArgs, RebalanceData, RebalanceDataArgs } from '../types';
10
+ import { PodBool, PodBoolArgs, PositionData, PositionDataArgs, PositionState, PositionStateArgs, PositionType, PositionTypeArgs, RebalanceData, RebalanceDataArgs } from '../types';
11
11
  export type SolautoPosition = Account<SolautoPositionAccountData>;
12
12
  export type SolautoPositionAccountData = {
13
13
  bump: Array<number>;
14
14
  positionId: Array<number>;
15
15
  selfManaged: PodBool;
16
+ positionType: PositionType;
16
17
  padding1: Array<number>;
17
18
  authority: PublicKey;
18
19
  position: PositionData;
@@ -24,6 +25,7 @@ export type SolautoPositionAccountDataArgs = {
24
25
  bump: Array<number>;
25
26
  positionId: Array<number>;
26
27
  selfManaged: PodBoolArgs;
28
+ positionType: PositionTypeArgs;
27
29
  padding1: Array<number>;
28
30
  authority: PublicKey;
29
31
  position: PositionDataArgs;
@@ -41,6 +43,7 @@ export declare function getSolautoPositionGpaBuilder(context: Pick<Context, 'rpc
41
43
  bump: Array<number>;
42
44
  positionId: Array<number>;
43
45
  selfManaged: PodBoolArgs;
46
+ positionType: PositionTypeArgs;
44
47
  padding1: Array<number>;
45
48
  authority: PublicKey;
46
49
  position: PositionDataArgs;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoPosition.d.ts","sourceRoot":"","sources":["../../../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sB,IAAI,MAAM,CAE/C"}
1
+ {"version":3,"file":"solautoPosition.d.ts","sourceRoot":"","sources":["../../../src/generated/accounts/solautoPosition.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,OAAO,EACP,OAAO,EACP,GAAG,EACH,SAAS,EACT,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EAKtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,UAAU,EAMX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,OAAO,EACP,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EAMlB,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAElE,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,aAAa,CAAC;IACzB,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,SAAS,EAAE,SAAS,CAAC;IACrB,QA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CAAC,MAAM,CAAC;iBACZ,WAAW;kBACV,gBAAgB;cACpB,KAAK,CAAC,MAAM,CAAC;eACZ,SAAS;cACV,gBAAgB;WACnB,iBAAiB;eACb,iBAAiB;aACnB,KAAK,CAAC,MAAM,CAAC;GAgB3B;AAED,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C"}
@@ -23,7 +23,8 @@ function getSolautoPositionAccountDataSerializer() {
23
23
  ['bump', (0, serializers_1.array)((0, serializers_1.u8)(), { size: 1 })],
24
24
  ['positionId', (0, serializers_1.array)((0, serializers_1.u8)(), { size: 1 })],
25
25
  ['selfManaged', (0, types_1.getPodBoolSerializer)()],
26
- ['padding1', (0, serializers_1.array)((0, serializers_1.u8)(), { size: 5 })],
26
+ ['positionType', (0, types_1.getPositionTypeSerializer)()],
27
+ ['padding1', (0, serializers_1.array)((0, serializers_1.u8)(), { size: 4 })],
27
28
  ['authority', (0, serializers_1.publicKey)()],
28
29
  ['position', (0, types_1.getPositionDataSerializer)()],
29
30
  ['state', (0, types_1.getPositionStateSerializer)()],
@@ -63,7 +64,8 @@ function getSolautoPositionGpaBuilder(context) {
63
64
  bump: [0, (0, serializers_1.array)((0, serializers_1.u8)(), { size: 1 })],
64
65
  positionId: [1, (0, serializers_1.array)((0, serializers_1.u8)(), { size: 1 })],
65
66
  selfManaged: [2, (0, types_1.getPodBoolSerializer)()],
66
- padding1: [3, (0, serializers_1.array)((0, serializers_1.u8)(), { size: 5 })],
67
+ positionType: [3, (0, types_1.getPositionTypeSerializer)()],
68
+ padding1: [4, (0, serializers_1.array)((0, serializers_1.u8)(), { size: 4 })],
67
69
  authority: [8, (0, serializers_1.publicKey)()],
68
70
  position: [40, (0, types_1.getPositionDataSerializer)()],
69
71
  state: [360, (0, types_1.getPositionStateSerializer)()],
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { Context, Option, OptionOrNullable, Pda, PublicKey, Signer, TransactionBuilder } from '@metaplex-foundation/umi';
9
9
  import { Serializer } from '@metaplex-foundation/umi/serializers';
10
- import { UpdatePositionData, UpdatePositionDataArgs } from '../types';
10
+ import { PositionType, PositionTypeArgs, UpdatePositionData, UpdatePositionDataArgs } from '../types';
11
11
  export type MarginfiOpenPositionInstructionAccounts = {
12
12
  signer: Signer;
13
13
  marginfiProgram: PublicKey | Pda;
@@ -33,10 +33,12 @@ export type MarginfiOpenPositionInstructionAccounts = {
33
33
  };
34
34
  export type MarginfiOpenPositionInstructionData = {
35
35
  discriminator: number;
36
+ positionType: PositionType;
36
37
  positionData: UpdatePositionData;
37
38
  marginfiAccountSeedIdx: Option<bigint>;
38
39
  };
39
40
  export type MarginfiOpenPositionInstructionDataArgs = {
41
+ positionType: PositionTypeArgs;
40
42
  positionData: UpdatePositionDataArgs;
41
43
  marginfiAccountSeedIdx: OptionOrNullable<number | bigint>;
42
44
  };
@@ -1 +1 @@
1
- {"version":3,"file":"marginfiOpenPosition.d.ts","sourceRoot":"","sources":["../../../src/generated/instructions/marginfiOpenPosition.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,OAAO,EACP,MAAM,EACN,gBAAgB,EAChB,GAAG,EACH,SAAS,EACT,MAAM,EACN,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,UAAU,EAMX,MAAM,sCAAsC,CAAC;AAM9C,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EAEvB,MAAM,UAAU,CAAC;AAGlB,MAAM,MAAM,uCAAuC,GAAG;IACpD,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,UAAU,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IAC7B,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;IACvB,iBAAiB,EAAE,SAAS,GAAG,GAAG,CAAC;IACnC,mBAA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,GAAG,GAAG,CAAC;IAC1B,cAAc,EAAE,SAAS,GAAG,GAAG,CAAC;IAChC,YAAY,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC;CAChC,CAAC;AAGF,MAAM,MAAM,mCAAmC,GAAG;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,kBAAkB,CAAC;IACjC,sBAAsB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG;IACpD,YAAY,EAAE,gBAAgB,CAAC;IAC/B,YAAY,EAAE,sBAAsB,CAAC;IACrC,sBAAsB,EAAE,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CAC3D,CAAC;AAEF,wBAAgB,gDAAgD,IAAI,UAAU,CAC5E,uCAAuC,EACvC,mCAAmC,CACpC,CAoBA;AAGD,MAAM,MAAM,mCAAmC,GAC7C,uCAAuC,CAAC;AAG1C,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,EAClC,KAAK,EAAE,uCAAuC,GAC5C,mCAAmC,GACpC,kBAAkB,CAsKpB"}
@@ -16,6 +16,7 @@ const types_1 = require("../types");
16
16
  function getMarginfiOpenPositionInstructionDataSerializer() {
17
17
  return (0, serializers_1.mapSerializer)((0, serializers_1.struct)([
18
18
  ['discriminator', (0, serializers_1.u8)()],
19
+ ['positionType', (0, types_1.getPositionTypeSerializer)()],
19
20
  ['positionData', (0, types_1.getUpdatePositionDataSerializer)()],
20
21
  ['marginfiAccountSeedIdx', (0, serializers_1.option)((0, serializers_1.u64)())],
21
22
  ], { description: 'MarginfiOpenPositionInstructionData' }), (value) => ({ ...value, discriminator: 6 }));
@@ -14,6 +14,7 @@ export * from './podBool';
14
14
  export * from './positionData';
15
15
  export * from './positionState';
16
16
  export * from './positionTokenUsage';
17
+ export * from './positionType';
17
18
  export * from './rebalanceData';
18
19
  export * from './solautoAction';
19
20
  export * from './solautoRebalanceType';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generated/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generated/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC"}
@@ -30,6 +30,7 @@ __exportStar(require("./podBool"), exports);
30
30
  __exportStar(require("./positionData"), exports);
31
31
  __exportStar(require("./positionState"), exports);
32
32
  __exportStar(require("./positionTokenUsage"), exports);
33
+ __exportStar(require("./positionType"), exports);
33
34
  __exportStar(require("./rebalanceData"), exports);
34
35
  __exportStar(require("./solautoAction"), exports);
35
36
  __exportStar(require("./solautoRebalanceType"), exports);
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the kinobi library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun kinobi to update it.
5
+ *
6
+ * @see https://github.com/metaplex-foundation/kinobi
7
+ */
8
+ import { Serializer } from '@metaplex-foundation/umi/serializers';
9
+ export declare enum PositionType {
10
+ Leverage = 0,
11
+ SafeLoan = 1
12
+ }
13
+ export type PositionTypeArgs = PositionType;
14
+ export declare function getPositionTypeSerializer(): Serializer<PositionTypeArgs, PositionType>;
15
+ //# sourceMappingURL=positionType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"positionType.d.ts","sourceRoot":"","sources":["../../../src/generated/types/positionType.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAc,MAAM,sCAAsC,CAAC;AAE9E,oBAAY,YAAY;IACtB,QAAQ,IAAA;IACR,QAAQ,IAAA;CACT;AAED,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAE5C,wBAAgB,yBAAyB,IAAI,UAAU,CACrD,gBAAgB,EAChB,YAAY,CACb,CAIA"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ /**
3
+ * This code was AUTOGENERATED using the kinobi library.
4
+ * Please DO NOT EDIT THIS FILE, instead use visitors
5
+ * to add features, then rerun kinobi to update it.
6
+ *
7
+ * @see https://github.com/metaplex-foundation/kinobi
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.PositionType = void 0;
11
+ exports.getPositionTypeSerializer = getPositionTypeSerializer;
12
+ const serializers_1 = require("@metaplex-foundation/umi/serializers");
13
+ var PositionType;
14
+ (function (PositionType) {
15
+ PositionType[PositionType["Leverage"] = 0] = "Leverage";
16
+ PositionType[PositionType["SafeLoan"] = 1] = "SafeLoan";
17
+ })(PositionType || (exports.PositionType = PositionType = {}));
18
+ function getPositionTypeSerializer() {
19
+ return (0, serializers_1.scalarEnum)(PositionType, {
20
+ description: 'PositionType',
21
+ });
22
+ }
@@ -1,9 +1,10 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
- import { LendingPlatform } from "../generated";
2
+ import { LendingPlatform, PositionType } from "../generated";
3
3
  export interface SolautoPositionDetails {
4
4
  publicKey?: PublicKey;
5
5
  authority: PublicKey;
6
6
  positionId: number;
7
+ positionType: PositionType;
7
8
  lendingPlatform: LendingPlatform;
8
9
  protocolAccount?: PublicKey;
9
10
  supplyMint?: PublicKey;
@@ -1 +1 @@
1
- {"version":3,"file":"solauto.d.ts","sourceRoot":"","sources":["../../src/types/solauto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,oBAAY,kBAAkB;IAC5B,OAAO,WAAW;IAClB,IAAI,SAAS;CACd;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,eAAe,GAAG,QAAQ,CAAC"}
1
+ {"version":3,"file":"solauto.d.ts","sourceRoot":"","sources":["../../src/types/solauto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE7D,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,oBAAY,kBAAkB;IAC5B,OAAO,WAAW;IAClB,IAAI,SAAS;CACd;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,eAAe,GAAG,QAAQ,CAAC"}
@@ -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,wBAAwB,CAAC;AAE7D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,qBAAqB,CAU3E;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE;IACN,IAAI,EAAE,SAAS,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MAAM,wBAAwB,CAAC;AAE7D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,qBAAqB,CAU3E;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE;IACN,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,EACD,IAAI,EAAE;IACJ,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,EACD,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA+D3B;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,CAwDA;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,CAsJpC;AA+DD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAyB3B"}
@@ -81,6 +81,8 @@ async function getAllMarginfiAccountsByAuthority(umi, authority, compatibleWithS
81
81
  state: await getMarginfiAccountPositionState(umi, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.publicKey)),
82
82
  })));
83
83
  return positionStates
84
+ .sort((a, b) => (0, numberUtils_1.fromBaseUnit)(b.state?.netWorth.baseAmountUsdValue ?? BigInt(0), generalAccounts_1.USD_DECIMALS) -
85
+ (0, numberUtils_1.fromBaseUnit)(a.state?.netWorth.baseAmountUsdValue ?? BigInt(0), generalAccounts_1.USD_DECIMALS))
84
86
  .filter((x) => x.state !== undefined)
85
87
  .map((x) => ({
86
88
  marginfiAccount: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.publicKey),
@@ -153,7 +155,9 @@ async function getMarginfiAccountPositionState(umi, marginfiAccountPk, supplyMin
153
155
  }
154
156
  if (supplyBalances.length > 0) {
155
157
  if (supplyBank === null) {
156
- supplyBank = await (0, marginfi_sdk_1.safeFetchBank)(umi, supplyBalances[0].bankPk, { commitment: "confirmed" });
158
+ supplyBank = await (0, marginfi_sdk_1.safeFetchBank)(umi, supplyBalances[0].bankPk, {
159
+ commitment: "confirmed",
160
+ });
157
161
  }
158
162
  if (!supplyMint) {
159
163
  supplyMint = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(supplyBank.mint);
@@ -162,7 +166,9 @@ async function getMarginfiAccountPositionState(umi, marginfiAccountPk, supplyMin
162
166
  }
163
167
  if (debtBalances.length > 0) {
164
168
  if (debtBank === null) {
165
- debtBank = await (0, marginfi_sdk_1.safeFetchBank)(umi, debtBalances[0].bankPk, { commitment: "confirmed" });
169
+ debtBank = await (0, marginfi_sdk_1.safeFetchBank)(umi, debtBalances[0].bankPk, {
170
+ commitment: "confirmed",
171
+ });
166
172
  }
167
173
  if (!debtMint) {
168
174
  debtMint = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(debtBank.mint);
@@ -1,7 +1,8 @@
1
1
  import { AddressLookupTableInput, Signer, TransactionBuilder, Umi, WrappedInstruction } from "@metaplex-foundation/umi";
2
2
  import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
3
3
  import { PriorityFeeSetting, TransactionRunType } from "../types";
4
- export declare function getSolanaRpcConnection(heliusApiKey: string): [Connection, Umi];
4
+ export declare function buildHeliusApiUrl(heliusApiKey: string): string;
5
+ export declare function getSolanaRpcConnection(rpcUrl: string): [Connection, Umi];
5
6
  export declare function getWrappedInstruction(signer: Signer, ix: TransactionInstruction): WrappedInstruction;
6
7
  export declare function setComputeUnitLimitUmiIx(signer: Signer, maxComputeUnits: number): WrappedInstruction;
7
8
  export declare function setComputeUnitPriceUmiIx(signer: Signer, lamports: number): WrappedInstruction;
@@ -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,sBAAsB,CACpC,YAAY,EAAE,MAAM,GACnB,CAAC,UAAU,EAAE,GAAG,CAAC,CAOnB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,sBAAsB,GACzB,kBAAkB,CAMpB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,GACtB,kBAAkB,CAOpB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,kBAAkB,CAOpB;AAED,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,GACd,kBAAkB,CAUpB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,SAAS,EACtB,QAAQ,EAAE,MAAM,GACf,kBAAkB,CASpB;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,YAAY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E,EAAE,kBAAkB,EACtB,eAAe,EAAE,kBAAkB,GAClC,OAAO,CAAC,MAAM,CAAC,CAgBjB;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,CA8DjC"}
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildHeliusApiUrl = buildHeliusApiUrl;
6
7
  exports.getSolanaRpcConnection = getSolanaRpcConnection;
7
8
  exports.getWrappedInstruction = getWrappedInstruction;
8
9
  exports.setComputeUnitLimitUmiIx = setComputeUnitLimitUmiIx;
@@ -25,8 +26,11 @@ const accountUtils_1 = require("./accountUtils");
25
26
  const generalUtils_1 = require("./generalUtils");
26
27
  const marginfi_sdk_1 = require("../marginfi-sdk");
27
28
  const types_1 = require("../types");
28
- function getSolanaRpcConnection(heliusApiKey) {
29
- const connection = new web3_js_1.Connection(`https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`, "confirmed");
29
+ function buildHeliusApiUrl(heliusApiKey) {
30
+ return `https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`;
31
+ }
32
+ function getSolanaRpcConnection(rpcUrl) {
33
+ const connection = new web3_js_1.Connection(rpcUrl, "confirmed");
30
34
  const umi = (0, umi_bundle_defaults_1.createUmi)(connection);
31
35
  return [connection, umi];
32
36
  }
@@ -1,6 +1,6 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import { Umi } from "@metaplex-foundation/umi";
3
- import { AutomationSettings, DCASettings, DCASettingsInpArgs, PositionState, SolautoSettingsParameters, SolautoSettingsParametersInpArgs, TokenType } from "../../generated";
3
+ import { AutomationSettings, DCASettings, DCASettingsInpArgs, PositionState, PositionType, SolautoSettingsParameters, SolautoSettingsParametersInpArgs, TokenType } from "../../generated";
4
4
  import { RebalanceAction, SolautoPositionDetails } from "../../types/solauto";
5
5
  export declare function findMintByTicker(ticker: string): PublicKey;
6
6
  export declare function nextAutomationPeriodTimestamp(automation: AutomationSettings): number;
@@ -9,10 +9,10 @@ export declare function getUpdatedValueFromAutomation(currValue: number, targetV
9
9
  export declare function getAdjustedSettingsFromAutomation(settings: SolautoSettingsParameters, currentUnixTime: number): SolautoSettingsParameters;
10
10
  export declare function eligibleForRebalance(positionState: PositionState, positionSettings: SolautoSettingsParameters, positionDca: DCASettings | undefined, currentUnixTime: number, bpsDistanceThreshold?: number): RebalanceAction | undefined;
11
11
  export declare function eligibleForRefresh(positionState: PositionState, positionSettings: SolautoSettingsParameters, currentUnixTime: number): boolean;
12
- export declare function getSolautoManagedPositions(umi: Umi, authority?: PublicKey): Promise<SolautoPositionDetails[]>;
12
+ export declare function getSolautoManagedPositions(umi: Umi, authority?: PublicKey, positionTypeFilter?: PositionType): Promise<SolautoPositionDetails[]>;
13
13
  export declare function getAllReferralStates(umi: Umi): Promise<PublicKey[]>;
14
14
  export declare function getReferralsByUser(umi: Umi, user: PublicKey): Promise<PublicKey[]>;
15
- export declare function getAllPositionsByAuthority(umi: Umi, user: PublicKey): Promise<SolautoPositionDetails[]>;
15
+ export declare function getAllPositionsByAuthority(umi: Umi, user: PublicKey, positionTypeFilter?: PositionType): Promise<SolautoPositionDetails[]>;
16
16
  export declare function positionStateWithLatestPrices(state: PositionState, supplyPrice?: number, debtPrice?: number): Promise<PositionState>;
17
17
  interface AssetProps {
18
18
  mint: PublicKey;
@@ -1 +1 @@
1
- {"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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GACtB,aAAa,CA8Df;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,gCAAgC,GACzC,yBAAyB,CA8B3B;AAED,KAAK,kBAAkB,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,gCAAgC,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,SAAS,CAAC;KAAE,CAAA;CAAE,GAC1E;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;CAAE,CAAC;AAEjD,qBAAa,mBAAmB;IACvB,gBAAgB,SAAa;IAC7B,cAAc,SAAa;IAC3B,QAAQ,EAAE,yBAAyB,GAAG,SAAS,CAAa;IAC5D,SAAS,EAAE,WAAW,GAAG,SAAS,CAAa;IAC/C,YAAY,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,SAAS,CAAC;KAAE,CAAa;IACrE,aAAa,EAAE,SAAS,GAAG,SAAS,CAAa;IAExD,GAAG,CAAC,MAAM,EAAE,kBAAkB;IA6B9B,KAAK;IASL,UAAU,IAAI,OAAO;CAStB"}
@@ -98,11 +98,12 @@ function eligibleForRefresh(positionState, positionSettings, currentUnixTime) {
98
98
  60 * 60 * 24 * 7);
99
99
  }
100
100
  }
101
- async function getSolautoManagedPositions(umi, authority) {
101
+ async function getSolautoManagedPositions(umi, authority, positionTypeFilter) {
102
102
  // bump: [u8; 1]
103
103
  // position_id: [u8; 1]
104
104
  // self_managed: u8 - (1 for true, 0 for false)
105
- // padding: [u8; 5]
105
+ // position_type: PositionType
106
+ // padding: [u8; 4]
106
107
  // authority: pubkey
107
108
  // lending_platform: u8
108
109
  // padding: [u8; 7]
@@ -113,7 +114,7 @@ async function getSolautoManagedPositions(umi, authority) {
113
114
  commitment: "confirmed",
114
115
  dataSlice: {
115
116
  offset: 0,
116
- length: 1 + 1 + 1 + 5 + 32 + 1 + 7 + 32 + 32 + 32, // bump + position_id + self_managed + padding (5) + authority (pubkey) + lending_platform + padding (7) + protocol account (pubkey) + supply mint (pubkey) + debt mint (pubkey)
117
+ length: 1 + 1 + 1 + 1 + 4 + 32 + 1 + 7 + 32 + 32 + 32, // bump + position_id + self_managed + position_type + padding (4) + authority (pubkey) + lending_platform + padding (7) + protocol account (pubkey) + supply mint (pubkey) + debt mint (pubkey)
117
118
  },
118
119
  filters: [
119
120
  {
@@ -135,6 +136,14 @@ async function getSolautoManagedPositions(umi, authority) {
135
136
  },
136
137
  ]
137
138
  : []),
139
+ ...(positionTypeFilter !== undefined ? [
140
+ {
141
+ memcmp: {
142
+ bytes: new Uint8Array(positionTypeFilter),
143
+ offset: 3
144
+ }
145
+ }
146
+ ] : [])
138
147
  ],
139
148
  });
140
149
  return accounts.map((x) => {
@@ -147,6 +156,7 @@ async function getSolautoManagedPositions(umi, authority) {
147
156
  authority: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(position.authority),
148
157
  positionId: position.positionId[0],
149
158
  lendingPlatform: position.position.lendingPlatform,
159
+ positionType: position.positionType,
150
160
  protocolAccount: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(position.position.protocolAccount),
151
161
  supplyMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(position.position.supplyMint),
152
162
  debtMint: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(position.position.debtMint),
@@ -194,16 +204,19 @@ async function getReferralsByUser(umi, user) {
194
204
  });
195
205
  return accounts.map((x) => (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.publicKey));
196
206
  }
197
- async function getAllPositionsByAuthority(umi, user) {
207
+ async function getAllPositionsByAuthority(umi, user, positionTypeFilter) {
198
208
  const solautoCompatiblePositions = await Promise.all([
199
209
  (async () => {
200
- const solautoManagedPositions = await getSolautoManagedPositions(umi, user);
210
+ const solautoManagedPositions = await getSolautoManagedPositions(umi, user, positionTypeFilter);
201
211
  return solautoManagedPositions.map((x) => ({
202
212
  ...x,
203
213
  authority: user,
204
214
  }));
205
215
  })(),
206
216
  (async () => {
217
+ if (positionTypeFilter === generated_1.PositionType.SafeLoan) {
218
+ return [];
219
+ }
207
220
  let marginfiPositions = await (0, marginfiUtils_1.getAllMarginfiAccountsByAuthority)(umi, user, true);
208
221
  marginfiPositions = marginfiPositions.filter((x) => x.supplyMint &&
209
222
  (x.debtMint.equals(web3_js_1.PublicKey.default) ||
@@ -212,6 +225,7 @@ async function getAllPositionsByAuthority(umi, user) {
212
225
  publicKey: x.marginfiAccount,
213
226
  authority: user,
214
227
  positionId: 0,
228
+ positionType: generated_1.PositionType.Leverage,
215
229
  lendingPlatform: generated_1.LendingPlatform.Marginfi,
216
230
  protocolAccount: x.marginfiAccount,
217
231
  supplyMint: x.supplyMint,
@@ -5,6 +5,7 @@ import {
5
5
  transactionBuilder,
6
6
  } from "@metaplex-foundation/umi";
7
7
  import {
8
+ buildHeliusApiUrl,
8
9
  getSolanaRpcConnection,
9
10
  sendSingleOptimizedTransaction,
10
11
  } from "../src/utils/solanaUtils";
@@ -14,7 +15,7 @@ import { getSecretKey } from "./shared";
14
15
  import { updateSolautoLut } from "./updateSolautoLUT";
15
16
 
16
17
  async function create() {
17
- let [connection, umi] = getSolanaRpcConnection(process.env.HELIUS_API_KEY!);
18
+ let [connection, umi] = getSolanaRpcConnection(buildHeliusApiUrl(process.env.HELIUS_API_KEY!));
18
19
 
19
20
  const secretKey = getSecretKey("solauto-manager");
20
21
  const signerKeypair = umi.eddsa.createKeypairFromSecretKey(secretKey);
package/local/shared.ts CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  VersionedTransaction,
9
9
  PublicKey,
10
10
  } from "@solana/web3.js";
11
- import { getSolanaRpcConnection } from "../src/utils/solanaUtils";
11
+ import { buildHeliusApiUrl, getSolanaRpcConnection } from "../src/utils/solanaUtils";
12
12
 
13
13
  function loadSecretKey(keypairPath: string) {
14
14
  const secretKey = JSON.parse(fs.readFileSync(keypairPath, "utf8"));
@@ -22,7 +22,7 @@ export function getSecretKey(keypairFilename: string = "id"): Uint8Array {
22
22
  }
23
23
 
24
24
  const keypair = Keypair.fromSecretKey(getSecretKey());
25
- const [connection, _] = getSolanaRpcConnection(process.env.HELIUS_API_KEY ?? "");
25
+ const [connection, _] = getSolanaRpcConnection(buildHeliusApiUrl(process.env.HELIUS_API_KEY ?? ""));
26
26
 
27
27
  async function createAndSendV0Tx(txInstructions: TransactionInstruction[]) {
28
28
  let latestBlockhash = await connection.getLatestBlockhash("finalized");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.146",
3
+ "version": "1.0.148",
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",
@@ -21,8 +21,8 @@ export class ReferralStateManager extends TxHandler {
21
21
  public referralState!: PublicKey;
22
22
  public referralStateData!: ReferralState | null;
23
23
 
24
- constructor(heliusApiKey: string, public localTest?: boolean) {
25
- super(heliusApiKey, localTest)
24
+ constructor(heliusApiUrl: string, public localTest?: boolean) {
25
+ super(heliusApiUrl, localTest)
26
26
  this.umi = this.umi.use({
27
27
  install(umi) {
28
28
  umi.programs.add(createSolautoProgram(), false);
@@ -100,10 +100,10 @@ export abstract class SolautoClient extends TxHandler {
100
100
  public livePositionUpdates: LivePositionUpdates = new LivePositionUpdates();
101
101
 
102
102
  constructor(
103
- heliusApiKey: string,
103
+ heliusApiUrl: string,
104
104
  public localTest?: boolean
105
105
  ) {
106
- super(heliusApiKey, localTest);
106
+ super(heliusApiUrl, localTest);
107
107
 
108
108
  this.umi = this.umi.use({
109
109
  install(umi) {
@@ -164,7 +164,7 @@ export abstract class SolautoClient extends TxHandler {
164
164
  this.debtMint
165
165
  );
166
166
 
167
- this.referralStateManager = new ReferralStateManager(this.heliusApiKey);
167
+ this.referralStateManager = new ReferralStateManager(this.heliusApiUrl);
168
168
  await this.referralStateManager.initialize({
169
169
  referralAuthority: this.authority,
170
170
  signer: args.signer,
@@ -23,6 +23,7 @@ import {
23
23
  DCASettingsInpArgs,
24
24
  LendingPlatform,
25
25
  PositionState,
26
+ PositionType,
26
27
  SolautoActionArgs,
27
28
  SolautoRebalanceTypeArgs,
28
29
  SolautoSettingsParametersInpArgs,
@@ -232,7 +233,8 @@ export class SolautoMarginfiClient extends SolautoClient {
232
233
 
233
234
  private marginfiOpenPositionIx(
234
235
  settingParams?: SolautoSettingsParametersInpArgs,
235
- dca?: DCASettingsInpArgs
236
+ dca?: DCASettingsInpArgs,
237
+ positionType?: PositionType
236
238
  ): TransactionBuilder {
237
239
  let signerDebtTa: UmiPublicKey | undefined = undefined;
238
240
  if (dca) {
@@ -264,6 +266,7 @@ export class SolautoMarginfiClient extends SolautoClient {
264
266
  debtBank: publicKey(this.marginfiDebtAccounts.bank),
265
267
  positionDebtTa: publicKey(this.positionDebtTa),
266
268
  signerDebtTa: signerDebtTa,
269
+ positionType: positionType ?? PositionType.Leverage,
267
270
  positionData: {
268
271
  positionId: this.positionId!,
269
272
  settingParams: settingParams ?? null,
@@ -2,18 +2,19 @@ import { Umi } from "@metaplex-foundation/umi";
2
2
  import { Connection } from "@solana/web3.js";
3
3
  import { getSolanaRpcConnection } from "../utils";
4
4
 
5
-
6
5
  export abstract class TxHandler {
7
- public heliusApiKey!: string;
6
+ public heliusApiUrl!: string;
8
7
  public umi!: Umi;
9
8
  public connection!: Connection;
10
9
 
11
- constructor(heliusApiKey: string,
12
- public localTest?: boolean) {
13
- this.heliusApiKey = heliusApiKey;
14
- const [connection, umi] = getSolanaRpcConnection(this.heliusApiKey);
15
- this.connection = connection;
16
- this.umi = umi;
10
+ constructor(
11
+ heliusApiUrl: string,
12
+ public localTest?: boolean
13
+ ) {
14
+ this.heliusApiUrl = heliusApiUrl;
15
+ const [connection, umi] = getSolanaRpcConnection(this.heliusApiUrl);
16
+ this.connection = connection;
17
+ this.umi = umi;
17
18
  }
18
19
 
19
20
  log(...args: any[]): void {
@@ -25,4 +26,4 @@ export abstract class TxHandler {
25
26
  abstract defaultLookupTables(): string[];
26
27
 
27
28
  abstract resetLiveTxUpdates(success?: boolean): Promise<void>;
28
- }
29
+ }
@@ -34,11 +34,14 @@ import {
34
34
  PositionDataArgs,
35
35
  PositionState,
36
36
  PositionStateArgs,
37
+ PositionType,
38
+ PositionTypeArgs,
37
39
  RebalanceData,
38
40
  RebalanceDataArgs,
39
41
  getPodBoolSerializer,
40
42
  getPositionDataSerializer,
41
43
  getPositionStateSerializer,
44
+ getPositionTypeSerializer,
42
45
  getRebalanceDataSerializer,
43
46
  } from '../types';
44
47
 
@@ -48,6 +51,7 @@ export type SolautoPositionAccountData = {
48
51
  bump: Array<number>;
49
52
  positionId: Array<number>;
50
53
  selfManaged: PodBool;
54
+ positionType: PositionType;
51
55
  padding1: Array<number>;
52
56
  authority: PublicKey;
53
57
  position: PositionData;
@@ -60,6 +64,7 @@ export type SolautoPositionAccountDataArgs = {
60
64
  bump: Array<number>;
61
65
  positionId: Array<number>;
62
66
  selfManaged: PodBoolArgs;
67
+ positionType: PositionTypeArgs;
63
68
  padding1: Array<number>;
64
69
  authority: PublicKey;
65
70
  position: PositionDataArgs;
@@ -77,7 +82,8 @@ export function getSolautoPositionAccountDataSerializer(): Serializer<
77
82
  ['bump', array(u8(), { size: 1 })],
78
83
  ['positionId', array(u8(), { size: 1 })],
79
84
  ['selfManaged', getPodBoolSerializer()],
80
- ['padding1', array(u8(), { size: 5 })],
85
+ ['positionType', getPositionTypeSerializer()],
86
+ ['padding1', array(u8(), { size: 4 })],
81
87
  ['authority', publicKeySerializer()],
82
88
  ['position', getPositionDataSerializer()],
83
89
  ['state', getPositionStateSerializer()],
@@ -165,6 +171,7 @@ export function getSolautoPositionGpaBuilder(
165
171
  bump: Array<number>;
166
172
  positionId: Array<number>;
167
173
  selfManaged: PodBoolArgs;
174
+ positionType: PositionTypeArgs;
168
175
  padding1: Array<number>;
169
176
  authority: PublicKey;
170
177
  position: PositionDataArgs;
@@ -175,7 +182,8 @@ export function getSolautoPositionGpaBuilder(
175
182
  bump: [0, array(u8(), { size: 1 })],
176
183
  positionId: [1, array(u8(), { size: 1 })],
177
184
  selfManaged: [2, getPodBoolSerializer()],
178
- padding1: [3, array(u8(), { size: 5 })],
185
+ positionType: [3, getPositionTypeSerializer()],
186
+ padding1: [4, array(u8(), { size: 4 })],
179
187
  authority: [8, publicKeySerializer()],
180
188
  position: [40, getPositionDataSerializer()],
181
189
  state: [360, getPositionStateSerializer()],
@@ -31,8 +31,11 @@ import {
31
31
  getAccountMetasAndSigners,
32
32
  } from '../shared';
33
33
  import {
34
+ PositionType,
35
+ PositionTypeArgs,
34
36
  UpdatePositionData,
35
37
  UpdatePositionDataArgs,
38
+ getPositionTypeSerializer,
36
39
  getUpdatePositionDataSerializer,
37
40
  } from '../types';
38
41
 
@@ -64,11 +67,13 @@ export type MarginfiOpenPositionInstructionAccounts = {
64
67
  // Data.
65
68
  export type MarginfiOpenPositionInstructionData = {
66
69
  discriminator: number;
70
+ positionType: PositionType;
67
71
  positionData: UpdatePositionData;
68
72
  marginfiAccountSeedIdx: Option<bigint>;
69
73
  };
70
74
 
71
75
  export type MarginfiOpenPositionInstructionDataArgs = {
76
+ positionType: PositionTypeArgs;
72
77
  positionData: UpdatePositionDataArgs;
73
78
  marginfiAccountSeedIdx: OptionOrNullable<number | bigint>;
74
79
  };
@@ -85,6 +90,7 @@ export function getMarginfiOpenPositionInstructionDataSerializer(): Serializer<
85
90
  struct<MarginfiOpenPositionInstructionData>(
86
91
  [
87
92
  ['discriminator', u8()],
93
+ ['positionType', getPositionTypeSerializer()],
88
94
  ['positionData', getUpdatePositionDataSerializer()],
89
95
  ['marginfiAccountSeedIdx', option(u64())],
90
96
  ],
@@ -15,6 +15,7 @@ export * from './podBool';
15
15
  export * from './positionData';
16
16
  export * from './positionState';
17
17
  export * from './positionTokenUsage';
18
+ export * from './positionType';
18
19
  export * from './rebalanceData';
19
20
  export * from './solautoAction';
20
21
  export * from './solautoRebalanceType';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the kinobi library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun kinobi to update it.
5
+ *
6
+ * @see https://github.com/metaplex-foundation/kinobi
7
+ */
8
+
9
+ import { Serializer, scalarEnum } from '@metaplex-foundation/umi/serializers';
10
+
11
+ export enum PositionType {
12
+ Leverage,
13
+ SafeLoan,
14
+ }
15
+
16
+ export type PositionTypeArgs = PositionType;
17
+
18
+ export function getPositionTypeSerializer(): Serializer<
19
+ PositionTypeArgs,
20
+ PositionType
21
+ > {
22
+ return scalarEnum<PositionType>(PositionType, {
23
+ description: 'PositionType',
24
+ }) as Serializer<PositionTypeArgs, PositionType>;
25
+ }
@@ -1,10 +1,11 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
- import { LendingPlatform } from "../generated";
2
+ import { LendingPlatform, PositionType } from "../generated";
3
3
 
4
4
  export interface SolautoPositionDetails {
5
5
  publicKey?: PublicKey;
6
6
  authority: PublicKey;
7
7
  positionId: number;
8
+ positionType: PositionType;
8
9
  lendingPlatform: LendingPlatform;
9
10
  protocolAccount?: PublicKey;
10
11
  supplyMint?: PublicKey;
@@ -8,7 +8,11 @@ import {
8
8
  safeFetchBank,
9
9
  safeFetchMarginfiAccount,
10
10
  } from "../marginfi-sdk";
11
- import { currentUnixSeconds, fetchTokenPrices, safeGetPrice } from "./generalUtils";
11
+ import {
12
+ currentUnixSeconds,
13
+ fetchTokenPrices,
14
+ safeGetPrice,
15
+ } from "./generalUtils";
12
16
  import {
13
17
  bytesToI80F48,
14
18
  fromBaseUnit,
@@ -64,9 +68,7 @@ export async function getMaxLtvAndLiqThreshold(
64
68
  ) {
65
69
  debt.bank = await safeFetchBank(
66
70
  umi,
67
- publicKey(
68
- MARGINFI_ACCOUNTS[debt.mint.toString()].bank
69
- ),
71
+ publicKey(MARGINFI_ACCOUNTS[debt.mint.toString()].bank),
70
72
  { commitment: "confirmed" }
71
73
  );
72
74
  }
@@ -94,7 +96,7 @@ export async function getMaxLtvAndLiqThreshold(
94
96
  BigInt(
95
97
  Math.round(
96
98
  bytesToI80F48(supply.bank!.totalAssetShares.value) *
97
- bytesToI80F48(supply.bank!.assetShareValue.value)
99
+ bytesToI80F48(supply.bank!.assetShareValue.value)
98
100
  )
99
101
  ),
100
102
  supply.bank!.mintDecimals
@@ -152,6 +154,17 @@ export async function getAllMarginfiAccountsByAuthority(
152
154
  }))
153
155
  );
154
156
  return positionStates
157
+ .sort(
158
+ (a, b) =>
159
+ fromBaseUnit(
160
+ b.state?.netWorth.baseAmountUsdValue ?? BigInt(0),
161
+ USD_DECIMALS
162
+ ) -
163
+ fromBaseUnit(
164
+ a.state?.netWorth.baseAmountUsdValue ?? BigInt(0),
165
+ USD_DECIMALS
166
+ )
167
+ )
155
168
  .filter((x) => x.state !== undefined)
156
169
  .map((x) => ({
157
170
  marginfiAccount: toWeb3JsPublicKey(x.publicKey),
@@ -190,7 +203,7 @@ async function getTokenUsage(
190
203
  amountCanBeUsed = isAsset
191
204
  ? Number(bank.config.depositLimit) - totalDeposited
192
205
  : totalDeposited -
193
- bytesToI80F48(bank.totalLiabilityShares.value) * liabilityShareValue;
206
+ bytesToI80F48(bank.totalLiabilityShares.value) * liabilityShareValue;
194
207
  }
195
208
 
196
209
  return {
@@ -200,22 +213,22 @@ async function getTokenUsage(
200
213
  baseUnit: BigInt(Math.round(amountUsed)),
201
214
  baseAmountUsdValue: bank
202
215
  ? toBaseUnit(
203
- fromBaseUnit(BigInt(Math.round(amountUsed)), bank.mintDecimals) *
204
- marketPrice,
205
- USD_DECIMALS
206
- )
216
+ fromBaseUnit(BigInt(Math.round(amountUsed)), bank.mintDecimals) *
217
+ marketPrice,
218
+ USD_DECIMALS
219
+ )
207
220
  : BigInt(0),
208
221
  },
209
222
  amountCanBeUsed: {
210
223
  baseUnit: BigInt(Math.round(amountCanBeUsed)),
211
224
  baseAmountUsdValue: bank
212
225
  ? toBaseUnit(
213
- fromBaseUnit(
214
- BigInt(Math.round(amountCanBeUsed)),
215
- bank.mintDecimals
216
- ) * marketPrice,
217
- USD_DECIMALS
218
- )
226
+ fromBaseUnit(
227
+ BigInt(Math.round(amountCanBeUsed)),
228
+ bank.mintDecimals
229
+ ) * marketPrice,
230
+ USD_DECIMALS
231
+ )
219
232
  : BigInt(0),
220
233
  },
221
234
  baseAmountMarketPriceUsd: toBaseUnit(marketPrice, USD_DECIMALS),
@@ -243,18 +256,18 @@ export async function getMarginfiAccountPositionState(
243
256
  let supplyBank: Bank | null =
244
257
  supplyMint && supplyMint !== PublicKey.default
245
258
  ? await safeFetchBank(
246
- umi,
247
- publicKey(MARGINFI_ACCOUNTS[supplyMint.toString()].bank),
248
- { commitment: "confirmed" }
249
- )
259
+ umi,
260
+ publicKey(MARGINFI_ACCOUNTS[supplyMint.toString()].bank),
261
+ { commitment: "confirmed" }
262
+ )
250
263
  : null;
251
264
  let debtBank: Bank | null =
252
265
  debtMint && debtMint !== PublicKey.default
253
266
  ? await safeFetchBank(
254
- umi,
255
- publicKey(MARGINFI_ACCOUNTS[debtMint.toString()].bank),
256
- { commitment: "confirmed" }
257
- )
267
+ umi,
268
+ publicKey(MARGINFI_ACCOUNTS[debtMint.toString()].bank),
269
+ { commitment: "confirmed" }
270
+ )
258
271
  : null;
259
272
 
260
273
  let supplyUsage: PositionTokenUsage | undefined = undefined;
@@ -280,7 +293,9 @@ export async function getMarginfiAccountPositionState(
280
293
 
281
294
  if (supplyBalances.length > 0) {
282
295
  if (supplyBank === null) {
283
- supplyBank = await safeFetchBank(umi, supplyBalances[0].bankPk, { commitment: "confirmed" });
296
+ supplyBank = await safeFetchBank(umi, supplyBalances[0].bankPk, {
297
+ commitment: "confirmed",
298
+ });
284
299
  }
285
300
  if (!supplyMint) {
286
301
  supplyMint = toWeb3JsPublicKey(supplyBank!.mint);
@@ -296,7 +311,9 @@ export async function getMarginfiAccountPositionState(
296
311
 
297
312
  if (debtBalances.length > 0) {
298
313
  if (debtBank === null) {
299
- debtBank = await safeFetchBank(umi, debtBalances[0].bankPk, { commitment: "confirmed" });
314
+ debtBank = await safeFetchBank(umi, debtBalances[0].bankPk, {
315
+ commitment: "confirmed",
316
+ });
300
317
  }
301
318
  if (!debtMint) {
302
319
  debtMint = toWeb3JsPublicKey(debtBank!.mint);
@@ -38,13 +38,14 @@ import {
38
38
  } from "../marginfi-sdk";
39
39
  import { PriorityFeeSetting, TransactionRunType } from "../types";
40
40
 
41
+ export function buildHeliusApiUrl(heliusApiKey: string) {
42
+ return `https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`;
43
+ }
44
+
41
45
  export function getSolanaRpcConnection(
42
- heliusApiKey: string
46
+ rpcUrl: string
43
47
  ): [Connection, Umi] {
44
- const connection = new Connection(
45
- `https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`,
46
- "confirmed"
47
- );
48
+ const connection = new Connection(rpcUrl, "confirmed");
48
49
  const umi = createUmi(connection);
49
50
  return [connection, umi];
50
51
  }
@@ -306,7 +307,7 @@ export async function sendSingleOptimizedTransaction(
306
307
  ),
307
308
  3
308
309
  );
309
-
310
+
310
311
  const computeUnitLimit = Math.round(
311
312
  simulationResult.value.unitsConsumed! * 1.1
312
313
  );
@@ -328,7 +329,7 @@ export async function sendSingleOptimizedTransaction(
328
329
  confirm: { commitment: "confirmed" },
329
330
  });
330
331
  const txSig = bs58.encode(result.signature);
331
- console.log(`Transaction signature: ${txSig}`)
332
+ console.log(`Transaction signature: ${txSig}`);
332
333
  console.log(`https://solscan.io/tx/${txSig}`);
333
334
  if (result.result.value.err !== null) {
334
335
  throw new Error(result.result.value.err.toString());
@@ -6,6 +6,7 @@ import {
6
6
  DCASettingsInpArgs,
7
7
  LendingPlatform,
8
8
  PositionState,
9
+ PositionType,
9
10
  SOLAUTO_PROGRAM_ID,
10
11
  SolautoSettingsParameters,
11
12
  SolautoSettingsParametersInpArgs,
@@ -13,7 +14,6 @@ import {
13
14
  getReferralStateSize,
14
15
  getSolautoPositionAccountDataSerializer,
15
16
  getSolautoPositionSize,
16
- safeFetchAllSolautoPosition,
17
17
  } from "../../generated";
18
18
  import { currentUnixSeconds, fetchTokenPrices } from "../generalUtils";
19
19
  import {
@@ -174,12 +174,14 @@ export function eligibleForRefresh(
174
174
 
175
175
  export async function getSolautoManagedPositions(
176
176
  umi: Umi,
177
- authority?: PublicKey
177
+ authority?: PublicKey,
178
+ positionTypeFilter?: PositionType
178
179
  ): Promise<SolautoPositionDetails[]> {
179
180
  // bump: [u8; 1]
180
181
  // position_id: [u8; 1]
181
182
  // self_managed: u8 - (1 for true, 0 for false)
182
- // padding: [u8; 5]
183
+ // position_type: PositionType
184
+ // padding: [u8; 4]
183
185
  // authority: pubkey
184
186
  // lending_platform: u8
185
187
  // padding: [u8; 7]
@@ -191,7 +193,7 @@ export async function getSolautoManagedPositions(
191
193
  commitment: "confirmed",
192
194
  dataSlice: {
193
195
  offset: 0,
194
- length: 1 + 1 + 1 + 5 + 32 + 1 + 7 + 32 + 32 + 32, // bump + position_id + self_managed + padding (5) + authority (pubkey) + lending_platform + padding (7) + protocol account (pubkey) + supply mint (pubkey) + debt mint (pubkey)
196
+ length: 1 + 1 + 1 + 1 + 4 + 32 + 1 + 7 + 32 + 32 + 32, // bump + position_id + self_managed + position_type + padding (4) + authority (pubkey) + lending_platform + padding (7) + protocol account (pubkey) + supply mint (pubkey) + debt mint (pubkey)
195
197
  },
196
198
  filters: [
197
199
  {
@@ -213,6 +215,14 @@ export async function getSolautoManagedPositions(
213
215
  },
214
216
  ]
215
217
  : []),
218
+ ...(positionTypeFilter !== undefined ? [
219
+ {
220
+ memcmp: {
221
+ bytes: new Uint8Array(positionTypeFilter),
222
+ offset: 3
223
+ }
224
+ }
225
+ ] : [])
216
226
  ],
217
227
  });
218
228
 
@@ -228,6 +238,7 @@ export async function getSolautoManagedPositions(
228
238
  authority: toWeb3JsPublicKey(position.authority),
229
239
  positionId: position.positionId[0],
230
240
  lendingPlatform: position.position.lendingPlatform,
241
+ positionType: position.positionType,
231
242
  protocolAccount: toWeb3JsPublicKey(position.position.protocolAccount),
232
243
  supplyMint: toWeb3JsPublicKey(position.position.supplyMint),
233
244
  debtMint: toWeb3JsPublicKey(position.position.debtMint),
@@ -286,14 +297,16 @@ export async function getReferralsByUser(
286
297
 
287
298
  export async function getAllPositionsByAuthority(
288
299
  umi: Umi,
289
- user: PublicKey
300
+ user: PublicKey,
301
+ positionTypeFilter?: PositionType
290
302
  ): Promise<SolautoPositionDetails[]> {
291
303
  const solautoCompatiblePositions: SolautoPositionDetails[][] =
292
304
  await Promise.all([
293
305
  (async () => {
294
306
  const solautoManagedPositions = await getSolautoManagedPositions(
295
307
  umi,
296
- user
308
+ user,
309
+ positionTypeFilter
297
310
  );
298
311
  return solautoManagedPositions.map((x) => ({
299
312
  ...x,
@@ -301,6 +314,10 @@ export async function getAllPositionsByAuthority(
301
314
  }));
302
315
  })(),
303
316
  (async () => {
317
+ if (positionTypeFilter === PositionType.SafeLoan) {
318
+ return [];
319
+ }
320
+
304
321
  let marginfiPositions = await getAllMarginfiAccountsByAuthority(
305
322
  umi,
306
323
  user,
@@ -316,6 +333,7 @@ export async function getAllPositionsByAuthority(
316
333
  publicKey: x.marginfiAccount,
317
334
  authority: user,
318
335
  positionId: 0,
336
+ positionType: PositionType.Leverage,
319
337
  lendingPlatform: LendingPlatform.Marginfi,
320
338
  protocolAccount: x.marginfiAccount,
321
339
  supplyMint: x.supplyMint,
@@ -18,6 +18,7 @@ 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 { buildHeliusApiUrl } from "../../src/utils";
21
22
 
22
23
  describe("Solauto Marginfi tests", async () => {
23
24
  // const signer = setupTest();
@@ -29,7 +30,7 @@ describe("Solauto Marginfi tests", async () => {
29
30
 
30
31
  it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
31
32
 
32
- const client = new SolautoMarginfiClient(process.env.HELIUS_API_KEY!, true);
33
+ const client = new SolautoMarginfiClient(buildHeliusApiUrl(process.env.HELIUS_API_KEY!), true);
33
34
 
34
35
  const supply = NATIVE_MINT;
35
36
  const supplyDecimals = 9;
@@ -39,7 +40,7 @@ describe("Solauto Marginfi tests", async () => {
39
40
  {
40
41
  signer,
41
42
  positionId,
42
- // authority: new PublicKey("")
43
+ authority: new PublicKey("AprYCPiVeKMCgjQ2ZufwChMzvQ5kFjJo2ekTLSkXsQDm")
43
44
  // marginfiAccount: new PublicKey(
44
45
  // "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
45
46
  // ),