@haven-fi/solauto-sdk 1.0.69 → 1.0.71

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
  2. package/dist/clients/solautoMarginfiClient.js +7 -9
  3. package/dist/constants/marginfiAccounts.d.ts.map +1 -1
  4. package/dist/constants/marginfiAccounts.js +14 -4
  5. package/dist/constants/pythConstants.d.ts +2 -0
  6. package/dist/constants/pythConstants.d.ts.map +1 -1
  7. package/dist/constants/pythConstants.js +2 -0
  8. package/dist/constants/tokenConstants.d.ts +10 -4
  9. package/dist/constants/tokenConstants.d.ts.map +1 -1
  10. package/dist/constants/tokenConstants.js +21 -8
  11. package/dist/generated/accounts/solautoPosition.d.ts +7 -1
  12. package/dist/generated/accounts/solautoPosition.d.ts.map +1 -1
  13. package/dist/generated/accounts/solautoPosition.js +6 -2
  14. package/dist/generated/types/feeType.d.ts +15 -0
  15. package/dist/generated/types/feeType.d.ts.map +1 -0
  16. package/dist/generated/types/feeType.js +20 -0
  17. package/dist/generated/types/index.d.ts +1 -0
  18. package/dist/generated/types/index.d.ts.map +1 -1
  19. package/dist/generated/types/index.js +1 -0
  20. package/dist/transactions/transactionUtils.d.ts.map +1 -1
  21. package/dist/transactions/transactionUtils.js +1 -1
  22. package/dist/types/accounts.d.ts +0 -1
  23. package/dist/types/accounts.d.ts.map +1 -1
  24. package/dist/utils/marginfiUtils.d.ts +1 -4
  25. package/dist/utils/marginfiUtils.d.ts.map +1 -1
  26. package/dist/utils/marginfiUtils.js +9 -15
  27. package/dist/utils/numberUtils.d.ts +2 -1
  28. package/dist/utils/numberUtils.d.ts.map +1 -1
  29. package/dist/utils/numberUtils.js +3 -2
  30. package/dist/utils/solauto/generalUtils.js +2 -2
  31. package/dist/utils/solauto/rebalanceUtils.d.ts +2 -2
  32. package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
  33. package/dist/utils/solauto/rebalanceUtils.js +2 -2
  34. package/local/updateMarginfiLUT.ts +1 -1
  35. package/package.json +1 -1
  36. package/src/clients/solautoMarginfiClient.ts +10 -15
  37. package/src/constants/marginfiAccounts.ts +15 -5
  38. package/src/constants/pythConstants.ts +4 -2
  39. package/src/constants/tokenConstants.ts +26 -8
  40. package/src/generated/accounts/solautoPosition.ts +15 -2
  41. package/src/generated/types/feeType.ts +23 -0
  42. package/src/generated/types/index.ts +1 -0
  43. package/src/transactions/transactionUtils.ts +1 -0
  44. package/src/types/accounts.ts +0 -1
  45. package/src/utils/marginfiUtils.ts +13 -23
  46. package/src/utils/numberUtils.ts +3 -2
  47. package/src/utils/solauto/generalUtils.ts +3 -3
  48. package/src/utils/solauto/rebalanceUtils.ts +3 -1
  49. package/tests/transactions/solautoMarginfi.ts +25 -22
  50. package/tests/unit/rebalanceCalculations.ts +5 -1
@@ -1 +1 @@
1
- {"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAK1D,OAAO,EACL,kBAAkB,EAElB,aAAa,EACb,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EAKjC,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,eAAe,EAUhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AASnE,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,eAAe,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aAAa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IAC1C,2BAA2B,CAAC,EAAE,eAAe,CAAC;IAE/C,UAAU,CAAC,IAAI,EAAE,yBAAyB;IAuC1C,8BAA8B;IA0CpC,mBAAmB,IAAI,MAAM,EAAE;IAI/B,gBAAgB,IAAI,SAAS,EAAE;IAU/B,yBAAyB,IAAI,kBAAkB;IAS/C,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA8C9B,OAAO,IAAI,kBAAkB;IAc7B,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAUhE,OAAO,CAAC,6BAA6B;IAmErC,OAAO,CAAC,oCAAoC;IA0D5C,SAAS,CACP,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IA2DrB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IA6ElE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAiBlE"}
@@ -40,12 +40,9 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
40
40
  this.marginfiGroup = marginfiAccountData
41
41
  ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(marginfiAccountData.group)
42
42
  : args.marginfiGroup ?? new web3_js_1.PublicKey(marginfiAccounts_1.DEFAULT_MARGINFI_GROUP);
43
- this.marginfiSupplyAccounts = (0, marginfiUtils_1.findMarginfiAccounts)({
44
- mint: this.supplyMint.toString(),
45
- });
46
- this.marginfiDebtAccounts = (0, marginfiUtils_1.findMarginfiAccounts)({
47
- mint: this.debtMint.toString(),
48
- });
43
+ this.marginfiSupplyAccounts =
44
+ marginfiAccounts_1.MARGINFI_ACCOUNTS[this.supplyMint.toString()];
45
+ this.marginfiDebtAccounts = marginfiAccounts_1.MARGINFI_ACCOUNTS[this.debtMint.toString()];
49
46
  if (!this.initialized) {
50
47
  await this.setIntermediaryMarginfiDetails();
51
48
  }
@@ -78,7 +75,9 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
78
75
  return [
79
76
  ...super.lutAccountsToAdd(),
80
77
  this.marginfiAccountPk,
81
- ...(this.signer.publicKey.toString() === this.authority.toString() ? [this.intermediaryMarginfiAccountPk] : []),
78
+ ...(this.signer.publicKey.toString() === this.authority.toString()
79
+ ? [this.intermediaryMarginfiAccountPk]
80
+ : []),
82
81
  ];
83
82
  }
84
83
  marginfiAccountInitialize() {
@@ -344,8 +343,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
344
343
  isWritable: false,
345
344
  },
346
345
  {
347
- pubkey: (0, umi_1.publicKey)((0, marginfiUtils_1.findMarginfiAccounts)({ bank: x.bankPk.toString() })
348
- .priceOracle),
346
+ pubkey: (0, umi_1.publicKey)((0, marginfiUtils_1.findMarginfiAccounts)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.bankPk)).priceOracle),
349
347
  isSigner: false,
350
348
  isWritable: false,
351
349
  },
@@ -1 +1 @@
1
- {"version":3,"file":"marginfiAccounts.d.ts","sourceRoot":"","sources":["../../src/constants/marginfiAccounts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,eAAO,MAAM,sBAAsB,iDAAiD,CAAC;AAErF,eAAO,MAAM,iBAAiB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAA;CAerE,CAAC;AAEF,eAAO,MAAM,8BAA8B,iDAAiD,CAAC"}
1
+ {"version":3,"file":"marginfiAccounts.d.ts","sourceRoot":"","sources":["../../src/constants/marginfiAccounts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,eAAO,MAAM,sBAAsB,iDAAiD,CAAC;AAErF,eAAO,MAAM,iBAAiB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAA;CAyBrE,CAAC;AAEF,eAAO,MAAM,8BAA8B,iDAAiD,CAAC"}
@@ -5,19 +5,29 @@ const spl_token_1 = require("@solana/spl-token");
5
5
  const tokenConstants_1 = require("./tokenConstants");
6
6
  exports.DEFAULT_MARGINFI_GROUP = "4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8";
7
7
  exports.MARGINFI_ACCOUNTS = {
8
- SOL: {
9
- mint: spl_token_1.NATIVE_MINT.toString(),
8
+ [spl_token_1.NATIVE_MINT.toString()]: {
10
9
  bank: "CCKtUs6Cgwo4aaQUmBPmyoApH2gUDErxNZCAntD6LYGh",
11
10
  liquidityVault: "2eicbpitfJXDwqCuFAmPgDP7t2oUotnAzbGzRKLMgSLe",
12
11
  vaultAuthority: "DD3AeAssFvjqTvRTrRAtpfjkBF8FpVKnFuwnMLN9haXD",
13
12
  priceOracle: "7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE"
14
13
  },
15
- USDC: {
16
- mint: tokenConstants_1.USDC_MINT,
14
+ [tokenConstants_1.USDC_MINT]: {
17
15
  bank: "2s37akK2eyBbp8DZgCm7RtsaEz8eJP3Nxd4urLHQv7yB",
18
16
  liquidityVault: "7jaiZR5Sk8hdYN9MxTpczTcwbWpb5WEoxSANuUwveuat",
19
17
  vaultAuthority: "3uxNepDbmkDNq6JhRja5Z8QwbTrfmkKP8AKZV5chYDGG",
20
18
  priceOracle: "Dpw1EAVrSB1ibxiDQyTAW6Zip3J4Btk2x4SgApQCeFbX"
19
+ },
20
+ [tokenConstants_1.B_SOL]: {
21
+ bank: "6hS9i46WyTq1KXcoa2Chas2Txh9TJAVr6n1t3tnrE23K",
22
+ liquidityVault: "2WMipeKDB2CENxbzdmnVrRbsxCA2LY6kCtBe6AAqDP9p",
23
+ vaultAuthority: "8RcZHucpVHkHWRRdMhJZsxBK9mqKSYnMKGqtF84U8YEo",
24
+ priceOracle: "5cN76Xm2Dtx9MnrQqBDeZZRsWruTTcw37UruznAdSvvE",
25
+ },
26
+ [tokenConstants_1.JUP]: {
27
+ bank: "Guu5uBc8k1WK1U2ihGosNaCy57LSgCkpWAabtzQqrQf8",
28
+ liquidityVault: "4w49W4fNDn778wsBa6TNq9hvebZKU17ymsptrEZ8zrsm",
29
+ vaultAuthority: "2MBwwAhL3c73Jy7HkWd9ofzh1bU39JBabrZCFQR2tUof",
30
+ priceOracle: "7dbob1psH1iZBS7qPsm3Kwbf5DzSXK8Jyg31CTgTnxH5",
21
31
  }
22
32
  };
23
33
  exports.MARGINFI_ACCOUNTS_LOOKUP_TABLE = "GAjmWmBPcH5Gxbiykasydj6RsCEaCLyHEvK6kHdFigc6";
@@ -1,5 +1,7 @@
1
1
  export declare const PYTH_PRICE_FEED_IDS: {
2
2
  [x: string]: string;
3
3
  EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: string;
4
+ bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1: string;
5
+ JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN: string;
4
6
  };
5
7
  //# sourceMappingURL=pythConstants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pythConstants.d.ts","sourceRoot":"","sources":["../../src/constants/pythConstants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB;;;CAK/B,CAAC"}
1
+ {"version":3,"file":"pythConstants.d.ts","sourceRoot":"","sources":["../../src/constants/pythConstants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB;;;;;CAO/B,CAAC"}
@@ -7,4 +7,6 @@ const tokenConstants_1 = require("./tokenConstants");
7
7
  exports.PYTH_PRICE_FEED_IDS = {
8
8
  [spl_token_1.NATIVE_MINT.toString()]: "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
9
9
  [tokenConstants_1.USDC_MINT]: "0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
10
+ [tokenConstants_1.B_SOL]: "0x89875379e70f8fbadc17aef315adf3a8d5d160b811435537e03c97e8aac97d9c",
11
+ [tokenConstants_1.JUP]: "0x0a0408d619e9380abad35060f9192039ed5042fa6f82301d0e48bb52be830996",
10
12
  };
@@ -1,8 +1,14 @@
1
1
  export declare const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
2
+ export declare const B_SOL = "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1";
3
+ export declare const JUP = "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN";
2
4
  export declare const ALL_SUPPORTED_TOKENS: string[];
3
- export declare const TOKEN_DECIMALS: {
4
- [x: string]: number;
5
- EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: number;
5
+ interface TokenInfo {
6
+ decimals: number;
7
+ isStableCoin?: boolean;
8
+ isLST?: boolean;
9
+ }
10
+ export declare const TOKEN_INFO: {
11
+ [key: string]: TokenInfo;
6
12
  };
7
- export declare const STABLECOINS: string[];
13
+ export {};
8
14
  //# sourceMappingURL=tokenConstants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tokenConstants.d.ts","sourceRoot":"","sources":["../../src/constants/tokenConstants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,iDAAiD,CAAC;AAGxE,eAAO,MAAM,oBAAoB,UAGhC,CAAC;AAEF,eAAO,MAAM,cAAc;;;CAG1B,CAAC;AAEF,eAAO,MAAM,WAAW,UAEvB,CAAC"}
1
+ {"version":3,"file":"tokenConstants.d.ts","sourceRoot":"","sources":["../../src/constants/tokenConstants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,iDAAiD,CAAC;AACxE,eAAO,MAAM,KAAK,gDAAgD,CAAC;AACnE,eAAO,MAAM,GAAG,gDAAgD,CAAC;AAGjE,eAAO,MAAM,oBAAoB,UAKhC,CAAC;AAEF,UAAU,SAAS;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,UAAU,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAelD,CAAC"}
@@ -1,17 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STABLECOINS = exports.TOKEN_DECIMALS = exports.ALL_SUPPORTED_TOKENS = exports.USDC_MINT = void 0;
3
+ exports.TOKEN_INFO = exports.ALL_SUPPORTED_TOKENS = exports.JUP = exports.B_SOL = exports.USDC_MINT = void 0;
4
4
  const spl_token_1 = require("@solana/spl-token");
5
- // When adding token ensure a price feed is provided in pythConstants.ts & the token is added to the necessary lists below
5
+ // When adding token ensure a price feed is provided in pythConstants.ts & the token is in TOKEN_INFO
6
6
  exports.USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
7
+ exports.B_SOL = "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1";
8
+ exports.JUP = "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN";
7
9
  exports.ALL_SUPPORTED_TOKENS = [
8
10
  spl_token_1.NATIVE_MINT.toString(),
9
11
  exports.USDC_MINT,
12
+ exports.B_SOL,
13
+ exports.JUP,
10
14
  ];
11
- exports.TOKEN_DECIMALS = {
12
- [spl_token_1.NATIVE_MINT.toString()]: 9,
13
- [exports.USDC_MINT]: 6
15
+ exports.TOKEN_INFO = {
16
+ [spl_token_1.NATIVE_MINT.toString()]: {
17
+ decimals: 9,
18
+ },
19
+ [exports.USDC_MINT]: {
20
+ decimals: 6,
21
+ isStableCoin: true
22
+ },
23
+ [exports.B_SOL]: {
24
+ decimals: 9,
25
+ isLST: true
26
+ },
27
+ [exports.JUP]: {
28
+ decimals: 6
29
+ }
14
30
  };
15
- exports.STABLECOINS = [
16
- exports.USDC_MINT
17
- ];
@@ -7,7 +7,7 @@
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 { FeeType, FeeTypeArgs, PodBool, PodBoolArgs, PositionData, PositionDataArgs, PositionState, PositionStateArgs, RebalanceData, RebalanceDataArgs } from '../types';
11
11
  export type SolautoPosition = Account<SolautoPositionAccountData>;
12
12
  export type SolautoPositionAccountData = {
13
13
  bump: Array<number>;
@@ -18,6 +18,8 @@ export type SolautoPositionAccountData = {
18
18
  position: PositionData;
19
19
  state: PositionState;
20
20
  rebalance: RebalanceData;
21
+ feeType: FeeType;
22
+ padding2: Array<number>;
21
23
  padding: Array<number>;
22
24
  };
23
25
  export type SolautoPositionAccountDataArgs = {
@@ -29,6 +31,8 @@ export type SolautoPositionAccountDataArgs = {
29
31
  position: PositionDataArgs;
30
32
  state: PositionStateArgs;
31
33
  rebalance: RebalanceDataArgs;
34
+ feeType: FeeTypeArgs;
35
+ padding2: Array<number>;
32
36
  padding: Array<number>;
33
37
  };
34
38
  export declare function getSolautoPositionAccountDataSerializer(): Serializer<SolautoPositionAccountDataArgs, SolautoPositionAccountData>;
@@ -46,6 +50,8 @@ export declare function getSolautoPositionGpaBuilder(context: Pick<Context, 'rpc
46
50
  position: PositionDataArgs;
47
51
  state: PositionStateArgs;
48
52
  rebalance: RebalanceDataArgs;
53
+ feeType: FeeTypeArgs;
54
+ padding2: Array<number>;
49
55
  padding: Array<number>;
50
56
  }>;
51
57
  export declare function getSolautoPositionSize(): number;
@@ -1 +1 @@
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,aAAa,EACb,iBAAiB,EAKlB,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,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,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,S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CAAC,MAAM,CAAC;gBACP,KAAK,CAAC,MAAM,CAAC;iBACZ,WAAW;cACd,KAAK,CAAC,MAAM,CAAC;eACZ,SAAS;cACV,gBAAgB;WACnB,iBAAiB;eACb,iBAAiB;aACnB,KAAK,CAAC,MAAM,CAAC;GAe3B;AAED,wBAAgB,sBAAsB,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,OAAO,EACP,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,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,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,OAAO,CAAC;IACjB,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,I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AAO,EAAE,KAAK,CAAC,EAC7B,UAAU,EAAE,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC,EAClC,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,eAAe,EAAE,CAAC,CAU5B;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,GAAG,UAAU,CAAC;UAQhC,KAAK,CAAC,MAAM,CAAC;gBACP,KAAK,CAAC,MAAM,CAAC;iBACZ,WAAW;cACd,KAAK,CAAC,MAAM,CAAC;eACZ,SAAS;cACV,gBAAgB;WACnB,iBAAiB;eACb,iBAAiB;aACnB,WAAW;cACV,KAAK,CAAC,MAAM,CAAC;aACd,KAAK,CAAC,MAAM,CAAC;GAiB3B;AAED,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C"}
@@ -28,7 +28,9 @@ function getSolautoPositionAccountDataSerializer() {
28
28
  ['position', (0, types_1.getPositionDataSerializer)()],
29
29
  ['state', (0, types_1.getPositionStateSerializer)()],
30
30
  ['rebalance', (0, types_1.getRebalanceDataSerializer)()],
31
- ['padding', (0, serializers_1.array)((0, serializers_1.u32)(), { size: 32 })],
31
+ ['feeType', (0, types_1.getFeeTypeSerializer)()],
32
+ ['padding2', (0, serializers_1.array)((0, serializers_1.u8)(), { size: 7 })],
33
+ ['padding', (0, serializers_1.array)((0, serializers_1.u32)(), { size: 30 })],
32
34
  ], { description: 'SolautoPositionAccountData' });
33
35
  }
34
36
  function deserializeSolautoPosition(rawAccount) {
@@ -68,7 +70,9 @@ function getSolautoPositionGpaBuilder(context) {
68
70
  position: [40, (0, types_1.getPositionDataSerializer)()],
69
71
  state: [360, (0, types_1.getPositionStateSerializer)()],
70
72
  rebalance: [648, (0, types_1.getRebalanceDataSerializer)()],
71
- padding: [704, (0, serializers_1.array)((0, serializers_1.u32)(), { size: 32 })],
73
+ feeType: [704, (0, types_1.getFeeTypeSerializer)()],
74
+ padding2: [705, (0, serializers_1.array)((0, serializers_1.u8)(), { size: 7 })],
75
+ padding: [712, (0, serializers_1.array)((0, serializers_1.u32)(), { size: 30 })],
72
76
  })
73
77
  .deserializeUsing((account) => deserializeSolautoPosition(account));
74
78
  }
@@ -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 FeeType {
10
+ Small = 0,
11
+ Default = 1
12
+ }
13
+ export type FeeTypeArgs = FeeType;
14
+ export declare function getFeeTypeSerializer(): Serializer<FeeTypeArgs, FeeType>;
15
+ //# sourceMappingURL=feeType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feeType.d.ts","sourceRoot":"","sources":["../../../src/generated/types/feeType.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAc,MAAM,sCAAsC,CAAC;AAE9E,oBAAY,OAAO;IACjB,KAAK,IAAA;IACL,OAAO,IAAA;CACR;AAED,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;AAElC,wBAAgB,oBAAoB,IAAI,UAAU,CAAC,WAAW,EAAE,OAAO,CAAC,CAKvE"}
@@ -0,0 +1,20 @@
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.FeeType = void 0;
11
+ exports.getFeeTypeSerializer = getFeeTypeSerializer;
12
+ const serializers_1 = require("@metaplex-foundation/umi/serializers");
13
+ var FeeType;
14
+ (function (FeeType) {
15
+ FeeType[FeeType["Small"] = 0] = "Small";
16
+ FeeType[FeeType["Default"] = 1] = "Default";
17
+ })(FeeType || (exports.FeeType = FeeType = {}));
18
+ function getFeeTypeSerializer() {
19
+ return (0, serializers_1.scalarEnum)(FeeType, { description: 'FeeType' });
20
+ }
@@ -9,6 +9,7 @@ export * from './automationSettings';
9
9
  export * from './automationSettingsInp';
10
10
  export * from './dCASettings';
11
11
  export * from './dCASettingsInp';
12
+ export * from './feeType';
12
13
  export * from './lendingPlatform';
13
14
  export * from './podBool';
14
15
  export * from './positionData';
@@ -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,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,WAAW,CAAC;AAC1B,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,sBAAsB,CAAC"}
@@ -25,6 +25,7 @@ __exportStar(require("./automationSettings"), exports);
25
25
  __exportStar(require("./automationSettingsInp"), exports);
26
26
  __exportStar(require("./dCASettings"), exports);
27
27
  __exportStar(require("./dCASettingsInp"), exports);
28
+ __exportStar(require("./feeType"), exports);
28
29
  __exportStar(require("./lendingPlatform"), exports);
29
30
  __exportStar(require("./podBool"), exports);
30
31
  __exportStar(require("./positionData"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,OAAO,IAAI,eAAe,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,aAAa,EASd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAuMzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA8G7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA4BnD;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACE,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACD,SAAS,CACZ,CA0HA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,eAAe,GAC5B,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC,CA8BzC"}
1
+ {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,OAAO,IAAI,eAAe,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,aAAa,EASd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAuMzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA8G7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA4BnD;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACE,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACD,SAAS,CACZ,CA2HA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,eAAe,GAC5B,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC,CA8BzC"}
@@ -329,7 +329,7 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
329
329
  client.log("Not eligible for a rebalance");
330
330
  return undefined;
331
331
  }
332
- const values = (0, rebalanceUtils_1.getRebalanceValues)(client.solautoPositionState, client.solautoPositionSettings(), client.solautoPositionActiveDca(), (0, generalUtils_1.currentUnixSeconds)(), constants_1.PRICES[client.supplyMint.toString()].price, constants_1.PRICES[client.debtMint.toString()].price, targetLiqUtilizationRateBps);
332
+ const values = (0, rebalanceUtils_1.getRebalanceValues)(client.solautoPositionState, client.solautoPositionSettings(), client.solautoPositionActiveDca(), client.solautoPositionData.feeType, (0, generalUtils_1.currentUnixSeconds)(), constants_1.PRICES[client.supplyMint.toString()].price, constants_1.PRICES[client.debtMint.toString()].price, targetLiqUtilizationRateBps);
333
333
  client.log("Rebalance values: ", values);
334
334
  const swapDetails = (0, rebalanceUtils_1.getJupSwapRebalanceDetails)(client, values, targetLiqUtilizationRateBps, attemptNum);
335
335
  const { jupQuote, lookupTableAddresses, setupInstructions, tokenLedgerIx, swapIx, } = await (0, jupiterUtils_1.getJupSwapTransaction)(client.signer, swapDetails, attemptNum);
@@ -1,5 +1,4 @@
1
1
  export interface MarginfiAssetAccounts {
2
- mint: string;
3
2
  bank: string;
4
3
  liquidityVault: string;
5
4
  vaultAuthority: string;
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/types/accounts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB"}
1
+ {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/types/accounts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -4,10 +4,7 @@ import { Bank } from "../marginfi-sdk";
4
4
  import { MarginfiAssetAccounts } from "../types/accounts";
5
5
  import { PositionState } from "../generated";
6
6
  import { LivePositionUpdates } from "./solauto/generalUtils";
7
- export declare function findMarginfiAccounts({ mint, bank, }: {
8
- mint?: string;
9
- bank?: string;
10
- }): MarginfiAssetAccounts;
7
+ export declare function findMarginfiAccounts(bank: PublicKey): MarginfiAssetAccounts;
11
8
  export declare function getMaxLtvAndLiqThreshold(umi: Umi, supply: {
12
9
  mint: PublicKey;
13
10
  bank?: Bank | null;
@@ -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;AAG7D,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,IAAI,GACL,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,qBAAqB,CAWxB;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,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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,CA2D3B;AAED,wBAAsB,iCAAiC,CACrD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,qBAAqB,CAAC,EAAE,OAAO,GAC9B,OAAO,CACR;IAAE,eAAe,EAAE,SAAS,CAAC;IAAC,UAAU,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,EAAE,CAC/E,CA6CA;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,CA+IpC;AA+DD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA0B3B"}
@@ -15,28 +15,22 @@ const solautoConstants_1 = require("../constants/solautoConstants");
15
15
  const marginfiAccounts_1 = require("../constants/marginfiAccounts");
16
16
  const generalAccounts_1 = require("../constants/generalAccounts");
17
17
  const solanaUtils_1 = require("./solanaUtils");
18
- function findMarginfiAccounts({ mint, bank, }) {
18
+ function findMarginfiAccounts(bank) {
19
19
  for (const key in marginfiAccounts_1.MARGINFI_ACCOUNTS) {
20
20
  const account = marginfiAccounts_1.MARGINFI_ACCOUNTS[key];
21
- if (mint && account.mint.toString().toLowerCase() === mint.toLowerCase()) {
22
- return account;
23
- }
24
- if (bank && account.bank.toString().toLowerCase() === bank.toLowerCase()) {
21
+ if (account.bank.toString().toLowerCase() === bank.toString().toLowerCase()) {
25
22
  return account;
26
23
  }
27
24
  }
28
- throw new Error(`Marginfi accounts not found by the mint: ${mint}`);
25
+ throw new Error(`Marginfi accounts not found by the bank: ${bank}`);
29
26
  }
30
27
  async function getMaxLtvAndLiqThreshold(umi, supply, debt, supplyPrice) {
31
28
  if (!supply.bank || supply.bank === null) {
32
- supply.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(findMarginfiAccounts({
33
- mint: supply.mint.toString(),
34
- }).bank));
29
+ supply.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[supply.mint.toString()].bank));
35
30
  }
36
- if ((!debt.bank || debt.bank === null) && !debt.mint.equals(web3_js_1.PublicKey.default)) {
37
- debt.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(findMarginfiAccounts({
38
- mint: debt.mint.toString(),
39
- }).bank));
31
+ if ((!debt.bank || debt.bank === null) &&
32
+ !debt.mint.equals(web3_js_1.PublicKey.default)) {
33
+ debt.bank = await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[debt.mint.toString()].bank));
40
34
  }
41
35
  if (!supplyPrice) {
42
36
  const [price] = await (0, generalUtils_1.getTokenPrices)([
@@ -141,10 +135,10 @@ async function getTokenUsage(umi, bank, isAsset, shares, amountUsedAdjustment) {
141
135
  async function getMarginfiAccountPositionState(umi, marginfiAccountPk, supplyMint, debtMint, livePositionUpdates) {
142
136
  let marginfiAccount = await (0, marginfi_sdk_1.safeFetchMarginfiAccount)(umi, (0, umi_1.publicKey)(marginfiAccountPk));
143
137
  let supplyBank = supplyMint && supplyMint !== web3_js_1.PublicKey.default
144
- ? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(findMarginfiAccounts({ mint: supplyMint.toString() }).bank))
138
+ ? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[supplyMint.toString()].bank))
145
139
  : null;
146
140
  let debtBank = debtMint && debtMint !== web3_js_1.PublicKey.default
147
- ? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(findMarginfiAccounts({ mint: debtMint.toString() }).bank))
141
+ ? await (0, marginfi_sdk_1.safeFetchBank)(umi, (0, umi_1.publicKey)(marginfiAccounts_1.MARGINFI_ACCOUNTS[debtMint.toString()].bank))
148
142
  : null;
149
143
  let supplyUsage = undefined;
150
144
  let debtUsage = undefined;
@@ -1,3 +1,4 @@
1
+ import { FeeType } 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, selfManaged: boolean, positionNetWorthUsd: number): {
10
+ export declare function getSolautoFeesBps(isReferred: boolean, feeType: FeeType, positionNetWorthUsd: number): {
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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AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAKvE"}
@@ -14,6 +14,7 @@ exports.maxBoostToBps = maxBoostToBps;
14
14
  exports.maxRepayFromBps = maxRepayFromBps;
15
15
  exports.maxRepayToBps = maxRepayToBps;
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;
@@ -66,13 +67,13 @@ function getDebtAdjustmentUsd(liqThresholdBps, supplyUsd, debtUsd, targetLiqUtil
66
67
  (1 - targetLiqUtilizationRate * (1 - adjustmentFee) * liqThreshold);
67
68
  return debtAdjustmentUsd;
68
69
  }
69
- function getSolautoFeesBps(isReferred, selfManaged, positionNetWorthUsd) {
70
+ function getSolautoFeesBps(isReferred, feeType, positionNetWorthUsd) {
70
71
  const minSize = 10000; // Minimum position size
71
72
  const maxSize = 1000000; // Maximum position size
72
73
  const maxFeeBps = 500; // Fee in basis points for minSize (5%)
73
74
  const minFeeBps = 100; // Fee in basis points for maxSize (1%)
74
75
  let feeBps = 0;
75
- if (selfManaged) {
76
+ if (feeType === generated_1.FeeType.Small) {
76
77
  feeBps = 100;
77
78
  }
78
79
  else if (positionNetWorthUsd <= minSize) {
@@ -235,8 +235,8 @@ async function positionStateWithLatestPrices(state, supplyPrice, debtPrice) {
235
235
  };
236
236
  }
237
237
  function createFakePositionState(supply, debt, maxLtvBps, liqThresholdBps) {
238
- const supplyDecimals = constants_1.TOKEN_DECIMALS[supply.mint.toString()];
239
- const debtDecimals = constants_1.TOKEN_DECIMALS[debt.mint.toString()];
238
+ const supplyDecimals = constants_1.TOKEN_INFO[supply.mint.toString()].decimals;
239
+ const debtDecimals = constants_1.TOKEN_INFO[debt.mint.toString()].decimals;
240
240
  const supplyUsd = supply.amountUsed * supply.price;
241
241
  const debtUsd = debt.amountUsed * debt.price;
242
242
  return {
@@ -1,6 +1,6 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import { SolautoClient } from "../../clients/solautoClient";
3
- import { DCASettings, PositionState, SolautoSettingsParameters } from "../../generated";
3
+ import { DCASettings, FeeType, PositionState, SolautoSettingsParameters } from "../../generated";
4
4
  import { QuoteResponse } from "@jup-ag/api";
5
5
  import { JupSwapDetails } from "../jupiterUtils";
6
6
  export interface RebalanceValues {
@@ -9,7 +9,7 @@ export interface RebalanceValues {
9
9
  amountToDcaIn: number;
10
10
  amountUsdToDcaIn: number;
11
11
  }
12
- export declare function getRebalanceValues(state: PositionState, settings: SolautoSettingsParameters | undefined, dca: DCASettings | undefined, currentUnixTime: number, supplyPrice: number, debtPrice: number, targetLiqUtilizationRateBps?: number, limitGapBps?: number): RebalanceValues;
12
+ export declare function getRebalanceValues(state: PositionState, settings: SolautoSettingsParameters | undefined, dca: DCASettings | undefined, feeType: FeeType, currentUnixTime: number, supplyPrice: number, debtPrice: number, targetLiqUtilizationRateBps?: number, limitGapBps?: number): RebalanceValues;
13
13
  export interface FlashLoanDetails {
14
14
  baseUnitAmount: bigint;
15
15
  mint: PublicKey;
@@ -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,EAC1B,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAkJjD,MAAM,WAAW,eAAe;IAC9B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB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AED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,yBAAyB,GAAG,SAAS,EAC/C,GAAG,EAAE,WAAW,GAAG,SAAS,EAC5B,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,CA0EjB;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,CAmE9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CAkChB"}
@@ -79,7 +79,7 @@ function getTargetRateAndDcaAmount(state, settings, dca, currentUnixTime, target
79
79
  };
80
80
  }
81
81
  }
82
- function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice, debtPrice, targetLiqUtilizationRateBps, limitGapBps) {
82
+ function getRebalanceValues(state, settings, dca, feeType, currentUnixTime, supplyPrice, debtPrice, targetLiqUtilizationRateBps, limitGapBps) {
83
83
  if (state === undefined ||
84
84
  state.lastUpdated <
85
85
  BigInt(Math.round((0, generalUtils_2.currentUnixSeconds)() - solautoConstants_1.MIN_POSITION_STATE_FRESHNESS_SECS))) {
@@ -91,7 +91,7 @@ function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice,
91
91
  const increasingLeverage = amountUsdToDcaIn > 0 || state.liqUtilizationRateBps < targetRateBps;
92
92
  let adjustmentFeeBps = 0;
93
93
  if (increasingLeverage) {
94
- adjustmentFeeBps = (0, numberUtils_1.getSolautoFeesBps)(false, settings === undefined, (0, numberUtils_1.fromBaseUnit)(state.netWorth.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS)).total;
94
+ adjustmentFeeBps = (0, numberUtils_1.getSolautoFeesBps)(false, feeType, (0, numberUtils_1.fromBaseUnit)(state.netWorth.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS)).total;
95
95
  }
96
96
  const supplyUsd = (0, numberUtils_1.fromBaseUnit)(state.supply.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS) +
97
97
  amountUsdToDcaIn;
@@ -14,7 +14,7 @@ async function addBanks() {
14
14
  const accounts = MARGINFI_ACCOUNTS[key];
15
15
  await updateLookupTable(
16
16
  [
17
- accounts.mint,
17
+ key,
18
18
  accounts.bank,
19
19
  accounts.liquidityVault,
20
20
  accounts.vaultAuthority,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.69",
3
+ "version": "1.0.71",
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",
@@ -16,6 +16,7 @@ import { SolautoClient, SolautoClientArgs } from "./solautoClient";
16
16
  import { MarginfiAssetAccounts } from "../types/accounts";
17
17
  import {
18
18
  DEFAULT_MARGINFI_GROUP,
19
+ MARGINFI_ACCOUNTS,
19
20
  MARGINFI_ACCOUNTS_LOOKUP_TABLE,
20
21
  } from "../constants/marginfiAccounts";
21
22
  import {
@@ -108,12 +109,9 @@ export class SolautoMarginfiClient extends SolautoClient {
108
109
  ? toWeb3JsPublicKey(marginfiAccountData.group)
109
110
  : args.marginfiGroup ?? new PublicKey(DEFAULT_MARGINFI_GROUP);
110
111
 
111
- this.marginfiSupplyAccounts = findMarginfiAccounts({
112
- mint: this.supplyMint.toString(),
113
- })!;
114
- this.marginfiDebtAccounts = findMarginfiAccounts({
115
- mint: this.debtMint.toString(),
116
- })!;
112
+ this.marginfiSupplyAccounts =
113
+ MARGINFI_ACCOUNTS[this.supplyMint.toString()]!;
114
+ this.marginfiDebtAccounts = MARGINFI_ACCOUNTS[this.debtMint.toString()]!;
117
115
 
118
116
  if (!this.initialized) {
119
117
  await this.setIntermediaryMarginfiDetails();
@@ -171,7 +169,9 @@ export class SolautoMarginfiClient extends SolautoClient {
171
169
  return [
172
170
  ...super.lutAccountsToAdd(),
173
171
  this.marginfiAccountPk,
174
- ...(this.signer.publicKey.toString() === this.authority.toString() ? [this.intermediaryMarginfiAccountPk] : []),
172
+ ...(this.signer.publicKey.toString() === this.authority.toString()
173
+ ? [this.intermediaryMarginfiAccountPk]
174
+ : []),
175
175
  ];
176
176
  }
177
177
 
@@ -358,17 +358,13 @@ export class SolautoMarginfiClient extends SolautoClient {
358
358
  : this.positionDebtTa
359
359
  );
360
360
  vaultDebtTa = publicKey(this.marginfiDebtAccounts.liquidityVault);
361
- debtVaultAuthority = publicKey(
362
- this.marginfiDebtAccounts.vaultAuthority
363
- );
361
+ debtVaultAuthority = publicKey(this.marginfiDebtAccounts.vaultAuthority);
364
362
  }
365
363
 
366
364
  let supplyPriceOracle: UmiPublicKey | undefined = undefined;
367
365
  let debtPriceOracle: UmiPublicKey | undefined = undefined;
368
366
  if (args.__kind === "Withdraw" || args.__kind === "Borrow") {
369
- supplyPriceOracle = publicKey(
370
- this.marginfiSupplyAccounts.priceOracle
371
- );
367
+ supplyPriceOracle = publicKey(this.marginfiSupplyAccounts.priceOracle);
372
368
  debtPriceOracle = publicKey(this.marginfiDebtAccounts.priceOracle);
373
369
  }
374
370
 
@@ -512,8 +508,7 @@ export class SolautoMarginfiClient extends SolautoClient {
512
508
  },
513
509
  {
514
510
  pubkey: publicKey(
515
- findMarginfiAccounts({ bank: x.bankPk.toString() })
516
- .priceOracle
511
+ findMarginfiAccounts(toWeb3JsPublicKey(x.bankPk)).priceOracle
517
512
  ),
518
513
  isSigner: false,
519
514
  isWritable: false,
@@ -1,23 +1,33 @@
1
1
  import { NATIVE_MINT } from "@solana/spl-token";
2
- import { USDC_MINT } from "./tokenConstants";
2
+ import { B_SOL, JUP, USDC_MINT } from "./tokenConstants";
3
3
  import { MarginfiAssetAccounts } from "../types/accounts";
4
4
 
5
5
  export const DEFAULT_MARGINFI_GROUP = "4qp6Fx6tnZkY5Wropq9wUYgtFxXKwE6viZxFHg3rdAG8";
6
6
 
7
7
  export const MARGINFI_ACCOUNTS: { [key: string]: MarginfiAssetAccounts } = {
8
- SOL: {
9
- mint: NATIVE_MINT.toString(),
8
+ [NATIVE_MINT.toString()]: {
10
9
  bank: "CCKtUs6Cgwo4aaQUmBPmyoApH2gUDErxNZCAntD6LYGh",
11
10
  liquidityVault: "2eicbpitfJXDwqCuFAmPgDP7t2oUotnAzbGzRKLMgSLe",
12
11
  vaultAuthority: "DD3AeAssFvjqTvRTrRAtpfjkBF8FpVKnFuwnMLN9haXD",
13
12
  priceOracle: "7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE"
14
13
  },
15
- USDC: {
16
- mint: USDC_MINT,
14
+ [USDC_MINT]: {
17
15
  bank: "2s37akK2eyBbp8DZgCm7RtsaEz8eJP3Nxd4urLHQv7yB",
18
16
  liquidityVault: "7jaiZR5Sk8hdYN9MxTpczTcwbWpb5WEoxSANuUwveuat",
19
17
  vaultAuthority: "3uxNepDbmkDNq6JhRja5Z8QwbTrfmkKP8AKZV5chYDGG",
20
18
  priceOracle: "Dpw1EAVrSB1ibxiDQyTAW6Zip3J4Btk2x4SgApQCeFbX"
19
+ },
20
+ [B_SOL]: {
21
+ bank: "6hS9i46WyTq1KXcoa2Chas2Txh9TJAVr6n1t3tnrE23K",
22
+ liquidityVault: "2WMipeKDB2CENxbzdmnVrRbsxCA2LY6kCtBe6AAqDP9p",
23
+ vaultAuthority: "8RcZHucpVHkHWRRdMhJZsxBK9mqKSYnMKGqtF84U8YEo",
24
+ priceOracle: "5cN76Xm2Dtx9MnrQqBDeZZRsWruTTcw37UruznAdSvvE",
25
+ },
26
+ [JUP]: {
27
+ bank: "Guu5uBc8k1WK1U2ihGosNaCy57LSgCkpWAabtzQqrQf8",
28
+ liquidityVault: "4w49W4fNDn778wsBa6TNq9hvebZKU17ymsptrEZ8zrsm",
29
+ vaultAuthority: "2MBwwAhL3c73Jy7HkWd9ofzh1bU39JBabrZCFQR2tUof",
30
+ priceOracle: "7dbob1psH1iZBS7qPsm3Kwbf5DzSXK8Jyg31CTgTnxH5",
21
31
  }
22
32
  };
23
33
 
@@ -1,5 +1,5 @@
1
1
  import { NATIVE_MINT } from "@solana/spl-token";
2
- import { USDC_MINT } from "./tokenConstants";
2
+ import { B_SOL, JUP, USDC_MINT } from "./tokenConstants";
3
3
 
4
4
  // https://pyth.network/developers/price-feed-ids#solana-stable
5
5
  export const PYTH_PRICE_FEED_IDS = {
@@ -7,4 +7,6 @@ export const PYTH_PRICE_FEED_IDS = {
7
7
  "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
8
8
  [USDC_MINT]:
9
9
  "0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
10
- };
10
+ [B_SOL]: "0x89875379e70f8fbadc17aef315adf3a8d5d160b811435537e03c97e8aac97d9c",
11
+ [JUP]: "0x0a0408d619e9380abad35060f9192039ed5042fa6f82301d0e48bb52be830996",
12
+ };
@@ -1,19 +1,37 @@
1
1
  import { NATIVE_MINT } from "@solana/spl-token";
2
2
 
3
- // When adding token ensure a price feed is provided in pythConstants.ts & the token is added to the necessary lists below
3
+ // When adding token ensure a price feed is provided in pythConstants.ts & the token is in TOKEN_INFO
4
4
  export const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
5
+ export const B_SOL = "bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1";
6
+ export const JUP = "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN";
5
7
 
6
8
 
7
9
  export const ALL_SUPPORTED_TOKENS = [
8
10
  NATIVE_MINT.toString(),
9
11
  USDC_MINT,
12
+ B_SOL,
13
+ JUP,
10
14
  ];
11
15
 
12
- export const TOKEN_DECIMALS = {
13
- [NATIVE_MINT.toString()]: 9,
14
- [USDC_MINT]: 6
15
- };
16
+ interface TokenInfo {
17
+ decimals: number;
18
+ isStableCoin?: boolean;
19
+ isLST?: boolean;
20
+ }
16
21
 
17
- export const STABLECOINS = [
18
- USDC_MINT
19
- ];
22
+ export const TOKEN_INFO: { [key: string]: TokenInfo } = {
23
+ [NATIVE_MINT.toString()]: {
24
+ decimals: 9,
25
+ },
26
+ [USDC_MINT]: {
27
+ decimals: 6,
28
+ isStableCoin: true
29
+ },
30
+ [B_SOL]: {
31
+ decimals: 9,
32
+ isLST: true
33
+ },
34
+ [JUP]: {
35
+ decimals: 6
36
+ }
37
+ };
@@ -28,6 +28,8 @@ import {
28
28
  u8,
29
29
  } from '@metaplex-foundation/umi/serializers';
30
30
  import {
31
+ FeeType,
32
+ FeeTypeArgs,
31
33
  PodBool,
32
34
  PodBoolArgs,
33
35
  PositionData,
@@ -36,6 +38,7 @@ import {
36
38
  PositionStateArgs,
37
39
  RebalanceData,
38
40
  RebalanceDataArgs,
41
+ getFeeTypeSerializer,
39
42
  getPodBoolSerializer,
40
43
  getPositionDataSerializer,
41
44
  getPositionStateSerializer,
@@ -53,6 +56,8 @@ export type SolautoPositionAccountData = {
53
56
  position: PositionData;
54
57
  state: PositionState;
55
58
  rebalance: RebalanceData;
59
+ feeType: FeeType;
60
+ padding2: Array<number>;
56
61
  padding: Array<number>;
57
62
  };
58
63
 
@@ -65,6 +70,8 @@ export type SolautoPositionAccountDataArgs = {
65
70
  position: PositionDataArgs;
66
71
  state: PositionStateArgs;
67
72
  rebalance: RebalanceDataArgs;
73
+ feeType: FeeTypeArgs;
74
+ padding2: Array<number>;
68
75
  padding: Array<number>;
69
76
  };
70
77
 
@@ -82,7 +89,9 @@ export function getSolautoPositionAccountDataSerializer(): Serializer<
82
89
  ['position', getPositionDataSerializer()],
83
90
  ['state', getPositionStateSerializer()],
84
91
  ['rebalance', getRebalanceDataSerializer()],
85
- ['padding', array(u32(), { size: 32 })],
92
+ ['feeType', getFeeTypeSerializer()],
93
+ ['padding2', array(u8(), { size: 7 })],
94
+ ['padding', array(u32(), { size: 30 })],
86
95
  ],
87
96
  { description: 'SolautoPositionAccountData' }
88
97
  ) as Serializer<SolautoPositionAccountDataArgs, SolautoPositionAccountData>;
@@ -170,6 +179,8 @@ export function getSolautoPositionGpaBuilder(
170
179
  position: PositionDataArgs;
171
180
  state: PositionStateArgs;
172
181
  rebalance: RebalanceDataArgs;
182
+ feeType: FeeTypeArgs;
183
+ padding2: Array<number>;
173
184
  padding: Array<number>;
174
185
  }>({
175
186
  bump: [0, array(u8(), { size: 1 })],
@@ -180,7 +191,9 @@ export function getSolautoPositionGpaBuilder(
180
191
  position: [40, getPositionDataSerializer()],
181
192
  state: [360, getPositionStateSerializer()],
182
193
  rebalance: [648, getRebalanceDataSerializer()],
183
- padding: [704, array(u32(), { size: 32 })],
194
+ feeType: [704, getFeeTypeSerializer()],
195
+ padding2: [705, array(u8(), { size: 7 })],
196
+ padding: [712, array(u32(), { size: 30 })],
184
197
  })
185
198
  .deserializeUsing<SolautoPosition>((account) =>
186
199
  deserializeSolautoPosition(account)
@@ -0,0 +1,23 @@
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 FeeType {
12
+ Small,
13
+ Default,
14
+ }
15
+
16
+ export type FeeTypeArgs = FeeType;
17
+
18
+ export function getFeeTypeSerializer(): Serializer<FeeTypeArgs, FeeType> {
19
+ return scalarEnum<FeeType>(FeeType, { description: 'FeeType' }) as Serializer<
20
+ FeeTypeArgs,
21
+ FeeType
22
+ >;
23
+ }
@@ -10,6 +10,7 @@ export * from './automationSettings';
10
10
  export * from './automationSettingsInp';
11
11
  export * from './dCASettings';
12
12
  export * from './dCASettingsInp';
13
+ export * from './feeType';
13
14
  export * from './lendingPlatform';
14
15
  export * from './podBool';
15
16
  export * from './positionData';
@@ -580,6 +580,7 @@ export async function buildSolautoRebalanceTransaction(
580
580
  client.solautoPositionState!,
581
581
  client.solautoPositionSettings(),
582
582
  client.solautoPositionActiveDca(),
583
+ client.solautoPositionData!.feeType,
583
584
  currentUnixSeconds(),
584
585
  PRICES[client.supplyMint.toString()].price,
585
586
  PRICES[client.debtMint.toString()].price,
@@ -1,5 +1,4 @@
1
1
  export interface MarginfiAssetAccounts {
2
- mint: string;
3
2
  bank: string;
4
3
  liquidityVault: string;
5
4
  vaultAuthority: string;
@@ -23,23 +23,16 @@ import { USD_DECIMALS } from "../constants/generalAccounts";
23
23
  import { LivePositionUpdates } from "./solauto/generalUtils";
24
24
  import { currentUnixSecondsSolana } from "./solanaUtils";
25
25
 
26
- export function findMarginfiAccounts({
27
- mint,
28
- bank,
29
- }: {
30
- mint?: string;
31
- bank?: string;
32
- }): MarginfiAssetAccounts {
26
+ export function findMarginfiAccounts(bank: PublicKey): MarginfiAssetAccounts {
33
27
  for (const key in MARGINFI_ACCOUNTS) {
34
28
  const account = MARGINFI_ACCOUNTS[key];
35
- if (mint && account.mint.toString().toLowerCase() === mint.toLowerCase()) {
36
- return account;
37
- }
38
- if (bank && account.bank.toString().toLowerCase() === bank.toLowerCase()) {
29
+ if (
30
+ account.bank.toString().toLowerCase() === bank.toString().toLowerCase()
31
+ ) {
39
32
  return account;
40
33
  }
41
34
  }
42
- throw new Error(`Marginfi accounts not found by the mint: ${mint}`);
35
+ throw new Error(`Marginfi accounts not found by the bank: ${bank}`);
43
36
  }
44
37
 
45
38
  export async function getMaxLtvAndLiqThreshold(
@@ -57,21 +50,18 @@ export async function getMaxLtvAndLiqThreshold(
57
50
  if (!supply.bank || supply.bank === null) {
58
51
  supply.bank = await safeFetchBank(
59
52
  umi,
60
- publicKey(
61
- findMarginfiAccounts({
62
- mint: supply.mint.toString(),
63
- }).bank
64
- )
53
+ publicKey(MARGINFI_ACCOUNTS[supply.mint.toString()].bank)
65
54
  );
66
55
  }
67
56
 
68
- if ((!debt.bank || debt.bank === null) && !debt.mint.equals(PublicKey.default)) {
57
+ if (
58
+ (!debt.bank || debt.bank === null) &&
59
+ !debt.mint.equals(PublicKey.default)
60
+ ) {
69
61
  debt.bank = await safeFetchBank(
70
62
  umi,
71
63
  publicKey(
72
- findMarginfiAccounts({
73
- mint: debt.mint.toString(),
74
- }).bank
64
+ MARGINFI_ACCOUNTS[debt.mint.toString()].bank
75
65
  )
76
66
  );
77
67
  }
@@ -248,14 +238,14 @@ export async function getMarginfiAccountPositionState(
248
238
  supplyMint && supplyMint !== PublicKey.default
249
239
  ? await safeFetchBank(
250
240
  umi,
251
- publicKey(findMarginfiAccounts({ mint: supplyMint.toString() }).bank)
241
+ publicKey(MARGINFI_ACCOUNTS[supplyMint.toString()].bank)
252
242
  )
253
243
  : null;
254
244
  let debtBank: Bank | null =
255
245
  debtMint && debtMint !== PublicKey.default
256
246
  ? await safeFetchBank(
257
247
  umi,
258
- publicKey(findMarginfiAccounts({ mint: debtMint.toString() }).bank)
248
+ publicKey(MARGINFI_ACCOUNTS[debtMint.toString()].bank)
259
249
  )
260
250
  : null;
261
251
 
@@ -1,4 +1,5 @@
1
1
  import { MAX_REPAY_GAP_BPS } from "../constants";
2
+ import { FeeType } from "../generated";
2
3
 
3
4
  export function getLiqUtilzationRateBps(
4
5
  supplyUsd: number,
@@ -88,7 +89,7 @@ export function getDebtAdjustmentUsd(
88
89
 
89
90
  export function getSolautoFeesBps(
90
91
  isReferred: boolean,
91
- selfManaged: boolean,
92
+ feeType: FeeType,
92
93
  positionNetWorthUsd: number
93
94
  ): {
94
95
  solauto: number;
@@ -101,7 +102,7 @@ export function getSolautoFeesBps(
101
102
  const minFeeBps = 100; // Fee in basis points for maxSize (1%)
102
103
 
103
104
  let feeBps: number = 0;
104
- if (selfManaged) {
105
+ if (feeType === FeeType.Small) {
105
106
  feeBps = 100;
106
107
  } else if (positionNetWorthUsd <= minSize) {
107
108
  feeBps = maxFeeBps;
@@ -23,7 +23,7 @@ import { getReferralState } from "../accountUtils";
23
23
  import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
24
24
  import {
25
25
  ALL_SUPPORTED_TOKENS,
26
- TOKEN_DECIMALS,
26
+ TOKEN_INFO,
27
27
  USD_DECIMALS,
28
28
  } from "../../constants";
29
29
  import {
@@ -368,8 +368,8 @@ export function createFakePositionState(
368
368
  maxLtvBps: number,
369
369
  liqThresholdBps: number
370
370
  ): PositionState {
371
- const supplyDecimals = TOKEN_DECIMALS[supply.mint.toString()];
372
- const debtDecimals = TOKEN_DECIMALS[debt.mint.toString()];
371
+ const supplyDecimals = TOKEN_INFO[supply.mint.toString()].decimals;
372
+ const debtDecimals = TOKEN_INFO[debt.mint.toString()].decimals;
373
373
 
374
374
  const supplyUsd = supply.amountUsed * supply.price;
375
375
  const debtUsd = debt.amountUsed * debt.price;
@@ -2,6 +2,7 @@ import { PublicKey } from "@solana/web3.js";
2
2
  import { SolautoClient } from "../../clients/solautoClient";
3
3
  import {
4
4
  DCASettings,
5
+ FeeType,
5
6
  PositionState,
6
7
  PositionTokenUsage,
7
8
  SolautoSettingsParameters,
@@ -170,6 +171,7 @@ export function getRebalanceValues(
170
171
  state: PositionState,
171
172
  settings: SolautoSettingsParameters | undefined,
172
173
  dca: DCASettings | undefined,
174
+ feeType: FeeType,
173
175
  currentUnixTime: number,
174
176
  supplyPrice: number,
175
177
  debtPrice: number,
@@ -204,7 +206,7 @@ export function getRebalanceValues(
204
206
  if (increasingLeverage) {
205
207
  adjustmentFeeBps = getSolautoFeesBps(
206
208
  false,
207
- settings === undefined,
209
+ feeType,
208
210
  fromBaseUnit(state.netWorth.baseAmountUsdValue, USD_DECIMALS)
209
211
  ).total;
210
212
  }
@@ -5,12 +5,11 @@ import {
5
5
  SolautoMarginfiClient,
6
6
  } from "../../src/clients/solautoMarginfiClient";
7
7
  import {
8
- LendingPlatform,
9
8
  solautoAction,
10
9
  SolautoSettingsParametersInpArgs,
11
10
  } from "../../src/generated";
12
11
  import { buildSolautoRebalanceTransaction } from "../../src/transactions/transactionUtils";
13
- import { getMaxLiqUtilizationRateBps, toBaseUnit } from "../../src/utils/numberUtils";
12
+ import { maxBoostToBps, maxRepayFromBps, maxRepayToBps, toBaseUnit } from "../../src/utils/numberUtils";
14
13
  import { NATIVE_MINT } from "@solana/spl-token";
15
14
  import { getTokenPrices } from "../../src/utils/generalUtils";
16
15
  import {
@@ -21,12 +20,12 @@ import { PublicKey } from "@solana/web3.js";
21
20
  import { USDC_MINT } from "../../src/constants";
22
21
 
23
22
  describe("Solauto Marginfi tests", async () => {
24
- // const signer = setupTest();
25
- const signer = setupTest("solauto-manager");
23
+ const signer = setupTest();
24
+ // const signer = setupTest("solauto-manager");
26
25
 
27
26
  const payForTransactions = false;
28
27
  const useJitoBundle = false;
29
- const positionId = 1;
28
+ const positionId = 2;
30
29
 
31
30
  it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
32
31
  const client = new SolautoMarginfiClient(process.env.HELIUS_API_KEY!, true);
@@ -67,22 +66,26 @@ describe("Solauto Marginfi tests", async () => {
67
66
  // }, "open position")
68
67
  // );
69
68
 
70
- // const initialSupplyUsd = 50;
71
- // transactionItems.push(
72
- // new TransactionItem(async () => {
73
- // const [supplyPrice] = await getTokenPrices([supply]);
74
- // return {
75
- // tx: client.protocolInteraction(
76
- // solautoAction("Deposit", [
77
- // toBaseUnit(initialSupplyUsd / supplyPrice, supplyDecimals),
78
- // ])
79
- // ),
80
- // };
81
- // }, "deposit")
82
- // );
69
+ // const initialSupplyUsd = 150;
70
+ // transactionItems.push(
71
+ // new TransactionItem(async () => {
72
+ // const [supplyPrice] = await getTokenPrices([supply]);
73
+ // return {
74
+ // tx: client.protocolInteraction(
75
+ // solautoAction("Deposit", [
76
+ // toBaseUnit(initialSupplyUsd / supplyPrice, supplyDecimals),
77
+ // ])
78
+ // ),
79
+ // };
80
+ // }, "deposit")
81
+ // );
83
82
  // }
84
83
 
85
- // const maxLiqRate = getMaxLiqUtilizationRateBps(client.solautoPositionState!.maxLtvBps, client.solautoPositionState!.liqThresholdBps);
84
+ // const maxLtvBps = client.solautoPositionState!.maxLtvBps;
85
+ // const liqThresholdBps = client.solautoPositionState!.liqThresholdBps;
86
+ // const maxRepayFrom = maxRepayFromBps(maxLtvBps, liqThresholdBps);
87
+ // const maxRepayTo = maxRepayToBps(maxLtvBps, liqThresholdBps);
88
+ // const maxBoostTo = maxBoostToBps(maxLtvBps, liqThresholdBps);
86
89
  // transactionItems.push(
87
90
  // new TransactionItem(
88
91
  // async () => ({
@@ -90,10 +93,10 @@ describe("Solauto Marginfi tests", async () => {
90
93
  // positionId: client.positionId,
91
94
  // settingParams: some({
92
95
  // ...settingParams,
96
+ // boostToBps: maxBoostTo,
93
97
  // boostGap: 50,
94
- // boostToBps: maxLiqRate,
95
- // repayGap: 100,
96
- // repayToBps: maxLiqRate
98
+ // repayToBps: maxRepayTo,
99
+ // repayGap: maxRepayFrom - maxRepayTo
97
100
  // }),
98
101
  // dca: null,
99
102
  // }),
@@ -9,6 +9,7 @@ import { publicKey } from "@metaplex-foundation/umi";
9
9
  import { SolautoClient } from "../../src/clients/solautoClient";
10
10
  import {
11
11
  DCASettings,
12
+ FeeType,
12
13
  LendingPlatform,
13
14
  SolautoRebalanceType,
14
15
  SolautoSettingsParameters,
@@ -48,6 +49,7 @@ function assertAccurateRebalance(
48
49
  client.solautoPositionState!,
49
50
  client.solautoPositionSettings(),
50
51
  client.solautoPositionActiveDca(),
52
+ client.solautoPositionData!.feeType,
51
53
  currentUnixSeconds(),
52
54
  PRICES[client.supplyMint.toString()].price,
53
55
  PRICES[client.debtMint.toString()].price,
@@ -58,7 +60,7 @@ function assertAccurateRebalance(
58
60
  if (increasingLeverage) {
59
61
  adjustmentFeeBps = getSolautoFeesBps(
60
62
  client.referredByState !== undefined,
61
- client.selfManaged,
63
+ client.solautoPositionData!.feeType,
62
64
  fromBaseUnit(
63
65
  client.solautoPositionState?.netWorth.baseAmountUsdValue ?? BigInt(0),
64
66
  USD_DECIMALS
@@ -178,7 +180,9 @@ async function getFakePosition(
178
180
  padding2: [],
179
181
  padding: new Uint8Array([]),
180
182
  },
183
+ feeType: FeeType.Default,
181
184
  padding1: [],
185
+ padding2: [],
182
186
  padding: [],
183
187
  publicKey: publicKey(PublicKey.default),
184
188
  header: {