@haven-fi/solauto-sdk 1.0.228 → 1.0.230

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/dist/clients/referralStateManager.d.ts +0 -2
  2. package/dist/clients/referralStateManager.d.ts.map +1 -1
  3. package/dist/clients/referralStateManager.js +2 -11
  4. package/dist/clients/solautoClient.d.ts.map +1 -1
  5. package/dist/clients/solautoClient.js +1 -1
  6. package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
  7. package/dist/clients/solautoMarginfiClient.js +1 -1
  8. package/dist/clients/txHandler.d.ts +4 -3
  9. package/dist/clients/txHandler.d.ts.map +1 -1
  10. package/dist/clients/txHandler.js +4 -2
  11. package/dist/constants/solautoConstants.d.ts +3 -0
  12. package/dist/constants/solautoConstants.d.ts.map +1 -1
  13. package/dist/constants/solautoConstants.js +18 -16
  14. package/dist/transactions/transactionUtils.d.ts +2 -2
  15. package/dist/transactions/transactionUtils.d.ts.map +1 -1
  16. package/dist/transactions/transactionUtils.js +8 -8
  17. package/dist/transactions/transactionsManager.js +1 -1
  18. package/dist/utils/accountUtils.d.ts +3 -3
  19. package/dist/utils/accountUtils.d.ts.map +1 -1
  20. package/dist/utils/accountUtils.js +6 -7
  21. package/dist/utils/solanaUtils.d.ts +1 -1
  22. package/dist/utils/solanaUtils.d.ts.map +1 -1
  23. package/dist/utils/solanaUtils.js +8 -2
  24. package/dist/utils/solauto/generalUtils.d.ts +2 -1
  25. package/dist/utils/solauto/generalUtils.d.ts.map +1 -1
  26. package/dist/utils/solauto/generalUtils.js +21 -4
  27. package/package.json +1 -1
  28. package/src/clients/referralStateManager.ts +3 -15
  29. package/src/clients/solautoClient.ts +2 -1
  30. package/src/clients/solautoMarginfiClient.ts +2 -2
  31. package/src/clients/txHandler.ts +10 -7
  32. package/src/constants/solautoConstants.ts +24 -18
  33. package/src/transactions/transactionUtils.ts +9 -13
  34. package/src/transactions/transactionsManager.ts +1 -1
  35. package/src/utils/accountUtils.ts +8 -7
  36. package/src/utils/solanaUtils.ts +9 -2
  37. package/src/utils/solauto/generalUtils.ts +24 -6
  38. package/tests/transactions/solautoMarginfi.ts +7 -6
@@ -11,7 +11,6 @@ export interface ReferralStateManagerArgs {
11
11
  referredByAuthority?: PublicKey;
12
12
  }
13
13
  export declare class ReferralStateManager extends TxHandler {
14
- localTest?: boolean | undefined;
15
14
  umi: Umi;
16
15
  signer: Signer;
17
16
  referralState: PublicKey;
@@ -19,7 +18,6 @@ export declare class ReferralStateManager extends TxHandler {
19
18
  authority: PublicKey;
20
19
  referredBy?: PublicKey;
21
20
  referredByState?: PublicKey;
22
- constructor(rpcUrl: string, localTest?: boolean | undefined);
23
21
  initialize(args: ReferralStateManagerArgs): Promise<void>;
24
22
  defaultLookupTables(): string[];
25
23
  setReferredBy(referredBy?: PublicKey): void;
@@ -1 +1 @@
1
- {"version":3,"file":"referralStateManager.d.ts","sourceRoot":"","sources":["../../src/clients/referralStateManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAEL,MAAM,EAEN,kBAAkB,EAClB,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAGL,aAAa,EAGd,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,mBAAmB,CAAC,EAAE,SAAS,CAAC;CACjC;AAED,qBAAa,oBAAqB,SAAQ,SAAS;IAaxC,SAAS,CAAC,EAAE,OAAO;IAZrB,GAAG,EAAG,GAAG,CAAC;IACV,MAAM,EAAG,MAAM,CAAC;IAEhB,aAAa,EAAG,SAAS,CAAC;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AC;IAC1B,iBAAiB,EAAG,aAAa,GAAG,IAAI,CAAC;IACzC,SAAS,EAAG,SAAS,CAAC;IAEtB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,eAAe,CAAC,EAAE,SAAS,CAAC;IAE7B,UAAU,CAAC,IAAI,EAAE,wBAAwB;IA6B/C,mBAAmB,IAAI,MAAM,EAAE;IAS/B,aAAa,CAAC,UAAU,CAAC,EAAE,SAAS;IAmBpC,sBAAsB,CACpB,YAAY,CAAC,EAAE,SAAS,EACxB,WAAW,CAAC,EAAE,SAAS,GACtB,kBAAkB;IAerB,mBAAmB,IAAI,kBAAkB;IA+BnC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC3D"}
@@ -11,15 +11,6 @@ const utils_1 = require("../utils");
11
11
  const txHandler_1 = require("./txHandler");
12
12
  const constants_1 = require("../constants");
13
13
  class ReferralStateManager extends txHandler_1.TxHandler {
14
- constructor(rpcUrl, localTest) {
15
- super(rpcUrl, localTest);
16
- this.localTest = localTest;
17
- this.umi = this.umi.use({
18
- install(umi) {
19
- umi.programs.add((0, generated_1.createSolautoProgram)(), false);
20
- },
21
- });
22
- }
23
14
  async initialize(args) {
24
15
  if (!args.signer && !args.wallet) {
25
16
  throw new Error("Signer or wallet must be provided");
@@ -30,7 +21,7 @@ class ReferralStateManager extends txHandler_1.TxHandler {
30
21
  this.signer = this.umi.identity;
31
22
  this.referralState = args.referralState
32
23
  ? args.referralState
33
- : (0, utils_1.getReferralState)(args.authority ?? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey));
24
+ : (0, utils_1.getReferralState)(args.authority ?? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.programId);
34
25
  this.referralStateData = await (0, generated_1.safeFetchReferralState)(this.umi, (0, umi_1.publicKey)(this.referralState), { commitment: "confirmed" });
35
26
  this.authority = this.referralStateData
36
27
  ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.referralStateData.authority)
@@ -53,7 +44,7 @@ class ReferralStateManager extends txHandler_1.TxHandler {
53
44
  : undefined;
54
45
  this.referredBy = finalReferredBy;
55
46
  this.referredByState = finalReferredBy
56
- ? (0, utils_1.getReferralState)(finalReferredBy)
47
+ ? (0, utils_1.getReferralState)(finalReferredBy, this.programId)
57
48
  : this.referralStateData
58
49
  ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.referralStateData.referredByState)
59
50
  : undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAA6B,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAEhC,sBAAsB,EAKvB,MAAM,cAAc,CAAC;AAUtB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAMpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,8BAAsB,aAAc,SAAQ,oBAAoB;IACvD,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC,SAAS,EAAG,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extends referralStateManager_1.ReferralStateManager {
22
22
  await super.initialize(args);
23
23
  this.positionId = args.positionId ?? 0;
24
24
  this.selfManaged = this.positionId === 0;
25
- this.solautoPosition = (0, accountUtils_1.getSolautoPositionAccount)(this.authority, this.positionId);
25
+ this.solautoPosition = (0, accountUtils_1.getSolautoPositionAccount)(this.authority, this.positionId, this.programId);
26
26
  this.solautoPositionData = !args.new
27
27
  ? await (0, generated_1.safeFetchSolautoPosition)(this.umi, (0, umi_1.publicKey)(this.solautoPosition), { commitment: "confirmed" })
28
28
  : null;
@@ -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,EAGb,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EAKjC,MAAM,cAAc,CAAC;AAOtB,OAAO,EAEL,eAAe,EAUhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,eAAe,EAChB,MAAM,iCAAiC,CAAC;AAQzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,eAAe,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,qBAAa,qBAAsB,SAAQ,aAAa;IACtD,OAAO,CAAC,WAAW,CAAkB;IAE9B,eAAe,EAAG,SAAS,CAAC;IAE5B,sB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Account = this.solautoPositionData
32
32
  ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.solautoPositionData.position.protocolAccount)
33
- : (0, accountUtils_1.getMarginfiAccountPDA)(this.solautoPosition, this.marginfiAccountSeedIdx);
33
+ : (0, accountUtils_1.getMarginfiAccountPDA)(this.solautoPosition, this.marginfiAccountSeedIdx, this.programId);
34
34
  }
35
35
  this.marginfiAccountPk =
36
36
  "publicKey" in this.marginfiAccount
@@ -1,10 +1,11 @@
1
1
  import { Umi } from "@metaplex-foundation/umi";
2
- import { Connection } from "@solana/web3.js";
2
+ import { Connection, PublicKey } from "@solana/web3.js";
3
3
  export declare abstract class TxHandler {
4
4
  rpcUrl: string;
5
- umi: Umi;
5
+ programId: PublicKey;
6
6
  connection: Connection;
7
- constructor(rpcUrl: string, localTest?: boolean);
7
+ umi: Umi;
8
+ constructor(rpcUrl: string, localTest?: boolean, programId?: PublicKey);
8
9
  log(...args: any[]): void;
9
10
  abstract defaultLookupTables(): string[];
10
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,EAAa,MAAM,iBAAiB,CAAC;AAGxD,8BAAsB,SAAS;IACtB,MAAM,EAAG,MAAM,CAAC;IAChB,GAAG,EAAG,GAAG,CAAC;IACV,UAAU,EAAG,UAAU,CAAC;gBAG7B,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,OAAO;IAYrB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAIzB,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,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAOxD,8BAAsB,SAAS;IAKpB,MAAM,EAAE,MAAM;IAEd,SAAS,EAAE,SAAS;IANtB,UAAU,EAAG,UAAU,CAAC;IACxB,GAAG,EAAG,GAAG,CAAC;gBAGR,MAAM,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,OAAO,EACZ,SAAS,GAAE,SAAgC;IAWpD,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAIzB,QAAQ,CAAC,mBAAmB,IAAI,MAAM,EAAE;IAExC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAC9D"}
@@ -2,10 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TxHandler = void 0;
4
4
  const utils_1 = require("../utils");
5
+ const constants_1 = require("../constants");
5
6
  class TxHandler {
6
- constructor(rpcUrl, localTest) {
7
+ constructor(rpcUrl, localTest, programId = constants_1.SOLAUTO_PROD_PROGRAM) {
7
8
  this.rpcUrl = rpcUrl;
8
- const [connection, umi] = (0, utils_1.getSolanaRpcConnection)(this.rpcUrl);
9
+ this.programId = programId;
10
+ const [connection, umi] = (0, utils_1.getSolanaRpcConnection)(this.rpcUrl, this.programId);
9
11
  this.connection = connection;
10
12
  this.umi = umi;
11
13
  if (!globalThis.LOCAL_TEST && localTest) {
@@ -1,3 +1,6 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ export declare const SOLAUTO_PROD_PROGRAM: PublicKey;
3
+ export declare const SOLAUTO_TEST_PROGRAM: PublicKey;
1
4
  export declare const BASIS_POINTS = 10000;
2
5
  export declare const MIN_POSITION_STATE_FRESHNESS_SECS = 5;
3
6
  export declare const MIN_REPAY_GAP_BPS = 50;
@@ -1 +1 @@
1
- {"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAQpC,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;KAAE,CAAA;CAAO,CAAC;AAE9E,eAAO,MAAM,WAAW,iDAAiD,CAAC;AAE1E,eAAO,MAAM,qBAAqB,UAWjC,CAAC"}
1
+ {"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EACV,MAAM,iBAAiB,CAAC;AASzB,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AACF,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AAIF,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAO,CAAC;AAE7E,eAAO,MAAM,WAAW,iDAAiD,CAAC;AAC1E,eAAO,MAAM,qBAAqB,UAYR,CAAC"}
@@ -1,33 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STANDARD_LUT_ACCOUNTS = exports.SOLAUTO_LUT = exports.PRICES = exports.MIN_BOOST_GAP_BPS = exports.MIN_REPAY_GAP_BPS = exports.MIN_POSITION_STATE_FRESHNESS_SECS = exports.BASIS_POINTS = void 0;
3
+ exports.STANDARD_LUT_ACCOUNTS = exports.SOLAUTO_LUT = exports.PRICES = exports.MIN_BOOST_GAP_BPS = exports.MIN_REPAY_GAP_BPS = exports.MIN_POSITION_STATE_FRESHNESS_SECS = exports.BASIS_POINTS = exports.SOLAUTO_TEST_PROGRAM = exports.SOLAUTO_PROD_PROGRAM = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  const spl_token_1 = require("@solana/spl-token");
6
6
  // import { JitoRpcConnection } from "jito-ts";
7
- const generated_1 = require("../generated");
8
7
  const generalAccounts_1 = require("./generalAccounts");
9
8
  const jupiter_sdk_1 = require("../jupiter-sdk");
9
+ exports.SOLAUTO_PROD_PROGRAM = new web3_js_1.PublicKey("AutoyKBRaHSBHy9RsmXCZMy6nNFAg5FYijrvZyQcNLV");
10
+ exports.SOLAUTO_TEST_PROGRAM = new web3_js_1.PublicKey("TesTjfQ6TbXv96Tv6fqr95XTZ1LYPxtkafmShN9PjBp");
10
11
  globalThis.LOCAL_TEST = false;
11
12
  exports.BASIS_POINTS = 10000;
12
13
  exports.MIN_POSITION_STATE_FRESHNESS_SECS = 5;
13
14
  exports.MIN_REPAY_GAP_BPS = 50;
14
15
  exports.MIN_BOOST_GAP_BPS = 50;
16
+ exports.PRICES = {};
17
+ exports.SOLAUTO_LUT = "9D4xwZwDf46n9ft5gQxZzq3rBbdRXsXojKQLZbBdskPY";
18
+ exports.STANDARD_LUT_ACCOUNTS = [
19
+ web3_js_1.PublicKey.default,
20
+ exports.SOLAUTO_PROD_PROGRAM,
21
+ exports.SOLAUTO_TEST_PROGRAM,
22
+ generalAccounts_1.SOLAUTO_MANAGER,
23
+ web3_js_1.SystemProgram.programId,
24
+ spl_token_1.TOKEN_PROGRAM_ID,
25
+ spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
26
+ web3_js_1.SYSVAR_CLOCK_PUBKEY,
27
+ web3_js_1.SYSVAR_RENT_PUBKEY,
28
+ web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
29
+ jupiter_sdk_1.JUPITER_PROGRAM_ID,
30
+ ].map((x) => x.toString());
15
31
  // export const JITO_BLOCK_ENGINE = "ny.mainnet.block-engine.jito.wtf";
16
32
  // export const JITO_CONNECTION = new JitoRpcConnection(
17
33
  // `https://${JITO_BLOCK_ENGINE}`,
18
34
  // "finalized"
19
35
  // );
20
- exports.PRICES = {};
21
- exports.SOLAUTO_LUT = "9D4xwZwDf46n9ft5gQxZzq3rBbdRXsXojKQLZbBdskPY";
22
- exports.STANDARD_LUT_ACCOUNTS = [
23
- web3_js_1.PublicKey.default.toString(),
24
- generated_1.SOLAUTO_PROGRAM_ID,
25
- generalAccounts_1.SOLAUTO_MANAGER.toString(),
26
- web3_js_1.SystemProgram.programId.toString(),
27
- spl_token_1.TOKEN_PROGRAM_ID.toString(),
28
- spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID.toString(),
29
- web3_js_1.SYSVAR_CLOCK_PUBKEY.toString(),
30
- web3_js_1.SYSVAR_RENT_PUBKEY.toString(),
31
- web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY.toString(),
32
- jupiter_sdk_1.JUPITER_PROGRAM_ID
33
- ];
@@ -1,4 +1,4 @@
1
- import { TransactionBuilder } from "@metaplex-foundation/umi";
1
+ import { TransactionBuilder, Umi } from "@metaplex-foundation/umi";
2
2
  import { PublicKey } from "@solana/web3.js";
3
3
  import { SolautoClient } from "../clients/solautoClient";
4
4
  import { ReferralStateManager } from "../clients";
@@ -8,7 +8,7 @@ export declare function getTransactionChores(client: SolautoClient, tx: Transact
8
8
  export declare function requiresRefreshBeforeRebalance(client: SolautoClient): Promise<boolean>;
9
9
  export declare function buildSolautoRebalanceTransaction(client: SolautoClient, targetLiqUtilizationRateBps?: number, attemptNum?: number): Promise<TransactionItemInputs | undefined>;
10
10
  export declare function convertReferralFeesToDestination(referralManager: ReferralStateManager, tokenAccount: PublicKey, destinationMint: PublicKey): Promise<TransactionItemInputs | undefined>;
11
- export declare function getErrorInfo(tx: TransactionBuilder, error: any): {
11
+ export declare function getErrorInfo(umi: Umi, tx: TransactionBuilder, error: any): {
12
12
  errorName: string | undefined;
13
13
  errorInfo: undefined;
14
14
  canBeIgnored: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAInB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAuBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAwCzD,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAO7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAqLjD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAkH7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,aAAa,oBA2CzE;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsH5C;AAED,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,GACzB,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AE,GAAG;;;;EAwCxE"}
@@ -119,7 +119,7 @@ async function transactionChoresBefore(client, accountsGettingCreated, solautoAc
119
119
  return chores;
120
120
  }
121
121
  async function rebalanceChoresBefore(client, tx, accountsGettingCreated) {
122
- const rebalanceInstructions = getRebalanceInstructions(tx);
122
+ const rebalanceInstructions = getRebalanceInstructions(client.umi, tx);
123
123
  if (rebalanceInstructions.length === 0) {
124
124
  return (0, umi_1.transactionBuilder)();
125
125
  }
@@ -184,9 +184,9 @@ function transactionChoresAfter(client, solautoActions, cancellingDcaIn) {
184
184
  }
185
185
  return chores;
186
186
  }
187
- function getRebalanceInstructions(tx) {
187
+ function getRebalanceInstructions(umi, tx) {
188
188
  return tx.getInstructions().filter((x) => {
189
- if (x.programId === generated_1.SOLAUTO_PROGRAM_ID) {
189
+ if (x.programId.toString() === umi.programs.get("solauto").publicKey.toString()) {
190
190
  try {
191
191
  const serializer = (0, generated_1.getMarginfiRebalanceInstructionDataSerializer)();
192
192
  const discriminator = serializer.serialize({
@@ -204,10 +204,10 @@ function getRebalanceInstructions(tx) {
204
204
  }
205
205
  });
206
206
  }
207
- function getSolautoActions(tx) {
207
+ function getSolautoActions(umi, tx) {
208
208
  let solautoActions = [];
209
209
  tx.getInstructions().forEach((x) => {
210
- if (x.programId === generated_1.SOLAUTO_PROGRAM_ID) {
210
+ if (x.programId.toString() === umi.programs.get("solauto").publicKey.toString()) {
211
211
  try {
212
212
  const serializer = (0, generated_1.getMarginfiProtocolInteractionInstructionDataSerializer)();
213
213
  const discriminator = serializer.serialize({
@@ -318,7 +318,7 @@ async function getTransactionChores(client, tx) {
318
318
  let choresBefore = (0, umi_1.transactionBuilder)();
319
319
  let choresAfter = (0, umi_1.transactionBuilder)();
320
320
  const accountsGettingCreated = [];
321
- const solautoActions = getSolautoActions(tx);
321
+ const solautoActions = getSolautoActions(client.umi, tx);
322
322
  choresBefore = choresBefore.add([
323
323
  await transactionChoresBefore(client, accountsGettingCreated, solautoActions, client.livePositionUpdates.dcaInBalance),
324
324
  await rebalanceChoresBefore(client, tx, accountsGettingCreated),
@@ -429,7 +429,7 @@ async function convertReferralFeesToDestination(referralManager, tokenAccount, d
429
429
  .add(swapIx);
430
430
  return { tx, lookupTableAddresses };
431
431
  }
432
- function getErrorInfo(tx, error) {
432
+ function getErrorInfo(umi, tx, error) {
433
433
  let canBeIgnored = false;
434
434
  let errorName = undefined;
435
435
  let errorInfo = undefined;
@@ -439,7 +439,7 @@ function getErrorInfo(tx, error) {
439
439
  const err = error["InstructionError"];
440
440
  const errIx = tx.getInstructions()[Math.max(0, err[0] - 2)];
441
441
  const errCode = err[1]["Custom"];
442
- if (errIx.programId === generated_1.SOLAUTO_PROGRAM_ID) {
442
+ if (errIx.programId.toString() === umi.programs.get("solauto").publicKey.toString()) {
443
443
  programError = (0, generated_1.getSolautoErrorFromCode)(errCode, (0, generated_1.createSolautoProgram)());
444
444
  if (programError?.name ===
445
445
  new generated_1.InvalidRebalanceConditionError((0, generated_1.createSolautoProgram)()).name) {
@@ -334,7 +334,7 @@ class TransactionsManager {
334
334
  this.updateStatus(txName, TransactionStatus.Successful, attemptNum, txSig ? bs58_1.default.encode(txSig) : undefined);
335
335
  }
336
336
  catch (e) {
337
- const errorDetails = (0, transactionUtils_1.getErrorInfo)(tx, e);
337
+ const errorDetails = (0, transactionUtils_1.getErrorInfo)(this.txHandler.umi, tx, e);
338
338
  this.updateStatus(txName, errorDetails.canBeIgnored
339
339
  ? TransactionStatus.Skipped
340
340
  : TransactionStatus.Failed, attemptNum, undefined, undefined, errorDetails.errorInfo ?? errorDetails.errorName ?? "Unknown error");
@@ -5,7 +5,7 @@ export declare function bufferFromU64(num: bigint): Buffer;
5
5
  export declare function getTokenAccount(wallet: PublicKey, tokenMint: PublicKey): PublicKey;
6
6
  export declare function getTokenAccounts(wallet: PublicKey, tokenMints: PublicKey[]): PublicKey[];
7
7
  export declare function getTokenAccountData(umi: Umi, tokenAccount: PublicKey): Promise<import("@solana/spl-token").RawAccount | undefined>;
8
- export declare function getSolautoPositionAccount(signer: PublicKey, positionId: number): PublicKey;
9
- export declare function getReferralState(authority: PublicKey): PublicKey;
10
- export declare function getMarginfiAccountPDA(solautoPositionAccount: PublicKey, marginfiAccountSeedIdx: bigint): PublicKey;
8
+ export declare function getSolautoPositionAccount(signer: PublicKey, positionId: number, programId: PublicKey): PublicKey;
9
+ export declare function getReferralState(authority: PublicKey, programId: PublicKey): PublicKey;
10
+ export declare function getMarginfiAccountPDA(solautoPositionAccount: PublicKey, marginfiAccountSeedIdx: bigint, programId: PublicKey): PublicKey;
11
11
  //# sourceMappingURL=accountUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"accountUtils.d.ts","sourceRoot":"","sources":["../../src/utils/accountUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIjD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,CAMlF;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAExF;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,+DAO1E;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,MAAM,aAQnB;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,aAUpD;AAED,wBAAgB,qBAAqB,CACnC,sBAAsB,EAAE,SAAS,EACjC,sBAAsB,EAAE,MAAM,aAa/B"}
1
+ {"version":3,"file":"accountUtils.d.ts","sourceRoot":"","sources":["../../src/utils/accountUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIjD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,CAMlF;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAExF;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,+DAO1E;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,SAAS,aAQrB;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,aAU1E;AAED,wBAAgB,qBAAqB,CACnC,sBAAsB,EAAE,SAAS,EACjC,sBAAsB,EAAE,MAAM,EAC9B,SAAS,EAAE,SAAS,aAarB"}
@@ -10,7 +10,6 @@ exports.getReferralState = getReferralState;
10
10
  exports.getMarginfiAccountPDA = getMarginfiAccountPDA;
11
11
  const web3_js_1 = require("@solana/web3.js");
12
12
  const spl_token_1 = require("@solana/spl-token");
13
- const generated_1 = require("../generated");
14
13
  const umi_1 = require("@metaplex-foundation/umi");
15
14
  function bufferFromU8(num) {
16
15
  const buffer = Buffer.alloc(1);
@@ -37,21 +36,21 @@ async function getTokenAccountData(umi, tokenAccount) {
37
36
  return undefined;
38
37
  }
39
38
  }
40
- function getSolautoPositionAccount(signer, positionId) {
41
- const [positionAccount, _] = web3_js_1.PublicKey.findProgramAddressSync([bufferFromU8(positionId), signer.toBuffer()], new web3_js_1.PublicKey(generated_1.SOLAUTO_PROGRAM_ID));
39
+ function getSolautoPositionAccount(signer, positionId, programId) {
40
+ const [positionAccount, _] = web3_js_1.PublicKey.findProgramAddressSync([bufferFromU8(positionId), signer.toBuffer()], programId);
42
41
  return positionAccount;
43
42
  }
44
- function getReferralState(authority) {
43
+ function getReferralState(authority, programId) {
45
44
  const str = "referral_state";
46
45
  const strBuffer = Buffer.from(str, "utf-8");
47
- const [ReferralState, _] = web3_js_1.PublicKey.findProgramAddressSync([strBuffer, authority.toBuffer()], new web3_js_1.PublicKey(generated_1.SOLAUTO_PROGRAM_ID));
46
+ const [ReferralState, _] = web3_js_1.PublicKey.findProgramAddressSync([strBuffer, authority.toBuffer()], programId);
48
47
  return ReferralState;
49
48
  }
50
- function getMarginfiAccountPDA(solautoPositionAccount, marginfiAccountSeedIdx) {
49
+ function getMarginfiAccountPDA(solautoPositionAccount, marginfiAccountSeedIdx, programId) {
51
50
  const seeds = [
52
51
  solautoPositionAccount.toBuffer(),
53
52
  bufferFromU64(marginfiAccountSeedIdx),
54
53
  ];
55
- const [marginfiAccount, _] = web3_js_1.PublicKey.findProgramAddressSync(seeds, new web3_js_1.PublicKey(generated_1.SOLAUTO_PROGRAM_ID));
54
+ const [marginfiAccount, _] = web3_js_1.PublicKey.findProgramAddressSync(seeds, programId);
56
55
  return marginfiAccount;
57
56
  }
@@ -3,7 +3,7 @@ import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
3
3
  import { PriorityFeeSetting, TransactionRunType } from "../types";
4
4
  export declare function buildHeliusApiUrl(heliusApiKey: string): string;
5
5
  export declare function buildIronforgeApiUrl(ironforgeApiKey: string): string;
6
- export declare function getSolanaRpcConnection(rpcUrl: string): [Connection, Umi];
6
+ export declare function getSolanaRpcConnection(rpcUrl: string, programId?: PublicKey): [Connection, Umi];
7
7
  export declare function getWrappedInstruction(signer: Signer, ix: TransactionInstruction): WrappedInstruction;
8
8
  export declare function setComputeUnitLimitUmiIx(signer: Signer, maxComputeUnits: number): WrappedInstruction;
9
9
  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,iBAAiB,CAAC,YAAY,EAAE,MAAM,UAErD;AAED,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,MAAM,UAE3D;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,GACb,CAAC,UAAU,EAAE,GAAG,CAAC,CAInB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,sBAAsB,GACzB,kBAAkB,CAMpB;AAED,wBAAgB,wBAAwB,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,EAAE,SAAS,EACvB,SAAS,EAAE,SAAS,GACnB,k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,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,kBAAkB,EACtB,eAAe,EAAE,kBAAkB,GAClC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAsB7B;AAED,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,kBAAkB,EACtB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,UAAU,CAAC,EAAE,MAAM,EACnB,eAAe,GAAE,kBAA+C,EAChE,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAmEjC"}
@@ -27,15 +27,21 @@ const accountUtils_1 = require("./accountUtils");
27
27
  const generalUtils_1 = require("./generalUtils");
28
28
  const marginfi_sdk_1 = require("../marginfi-sdk");
29
29
  const types_1 = require("../types");
30
+ const solauto_1 = require("./solauto");
31
+ const constants_1 = require("../constants");
30
32
  function buildHeliusApiUrl(heliusApiKey) {
31
33
  return `https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`;
32
34
  }
33
35
  function buildIronforgeApiUrl(ironforgeApiKey) {
34
36
  return `https://rpc.ironforge.network/mainnet?apiKey=${ironforgeApiKey}`;
35
37
  }
36
- function getSolanaRpcConnection(rpcUrl) {
38
+ function getSolanaRpcConnection(rpcUrl, programId = constants_1.SOLAUTO_PROD_PROGRAM) {
37
39
  const connection = new web3_js_1.Connection(rpcUrl, "confirmed");
38
- const umi = (0, umi_bundle_defaults_1.createUmi)(connection);
40
+ const umi = (0, umi_bundle_defaults_1.createUmi)(connection).use({
41
+ install(umi) {
42
+ umi.programs.add((0, solauto_1.createDynamicSolautoProgram)(programId), false);
43
+ },
44
+ });
39
45
  return [connection, umi];
40
46
  }
41
47
  function getWrappedInstruction(signer, ix) {
@@ -1,7 +1,8 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
- import { Umi } from "@metaplex-foundation/umi";
2
+ import { Program, Umi } from "@metaplex-foundation/umi";
3
3
  import { AutomationSettings, DCASettings, DCASettingsInpArgs, PositionState, PositionType, SolautoSettingsParameters, SolautoSettingsParametersInpArgs, TokenType } from "../../generated";
4
4
  import { RebalanceAction, SolautoPositionDetails } from "../../types/solauto";
5
+ export declare function createDynamicSolautoProgram(programId: PublicKey): Program;
5
6
  export declare function nextAutomationPeriodTimestamp(automation: AutomationSettings): number;
6
7
  export declare function eligibleForNextAutomationPeriod(automation: AutomationSettings, currentUnixTime: number): boolean;
7
8
  export declare function getUpdatedValueFromAutomation(currValue: number, targetValue: number, automation: AutomationSettings, currentUnixTimestamp: number): number;
@@ -1 +1 @@
1
- {"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAA+B,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAElB,aAAa,EACb,YAAY,EAEZ,yBAAyB,EACzB,gCAAgC,EAChC,SAAS,EAIV,MAAM,iBAAiB,CAAC;AAezB,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAgB9E,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,kBAAkB,GAC7B,MAAM,CAKR;AAED,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,kBAAkB,EAC9B,eAAe,EAAE,MAAM,GACtB,OAAO,CAET;AAED,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,kBAAkB,EAC9B,oBAAoB,EAAE,MAAM,UAY7B;AAED,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,yBAAyB,EACnC,eAAe,EAAE,MAAM,GACtB,yBAAyB,CAgB3B;AAED,wBAAgB,oBAAoB,CAClC,aAAa,EAA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AAyB,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"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LivePositionUpdates = void 0;
4
+ exports.createDynamicSolautoProgram = createDynamicSolautoProgram;
4
5
  exports.nextAutomationPeriodTimestamp = nextAutomationPeriodTimestamp;
5
6
  exports.eligibleForNextAutomationPeriod = eligibleForNextAutomationPeriod;
6
7
  exports.getUpdatedValueFromAutomation = getUpdatedValueFromAutomation;
@@ -23,6 +24,21 @@ const accountUtils_1 = require("../accountUtils");
23
24
  const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
24
25
  const constants_1 = require("../../constants");
25
26
  const marginfiUtils_1 = require("../marginfiUtils");
27
+ function createDynamicSolautoProgram(programId) {
28
+ return {
29
+ name: 'solauto',
30
+ publicKey: (0, umi_1.publicKey)(programId),
31
+ getErrorFromCode(code, cause) {
32
+ return (0, generated_1.getSolautoErrorFromCode)(code, this, cause);
33
+ },
34
+ getErrorFromName(name, cause) {
35
+ return (0, generated_1.getSolautoErrorFromName)(name, this, cause);
36
+ },
37
+ isOnCluster() {
38
+ return true;
39
+ },
40
+ };
41
+ }
26
42
  function newPeriodsPassed(automation, currentUnixTimestamp) {
27
43
  return Math.min(automation.targetPeriods, automation.periodsPassed +
28
44
  Math.floor((currentUnixTimestamp - Number(automation.unixStartDate)) /
@@ -99,7 +115,7 @@ async function getSolautoManagedPositions(umi, authority, positionTypeFilter) {
99
115
  // protocol account: pubkey
100
116
  // supply mint: pubkey
101
117
  // debt mint: pubkey
102
- const accounts = await umi.rpc.getProgramAccounts(generated_1.SOLAUTO_PROGRAM_ID, {
118
+ const accounts = await umi.rpc.getProgramAccounts(umi.programs.get("solauto").publicKey, {
103
119
  commitment: "confirmed",
104
120
  dataSlice: {
105
121
  offset: 0,
@@ -153,7 +169,7 @@ async function getSolautoManagedPositions(umi, authority, positionTypeFilter) {
153
169
  });
154
170
  }
155
171
  async function getAllReferralStates(umi) {
156
- const accounts = await umi.rpc.getProgramAccounts(generated_1.SOLAUTO_PROGRAM_ID, {
172
+ const accounts = await umi.rpc.getProgramAccounts(umi.programs.get("solauto").publicKey, {
157
173
  commitment: "confirmed",
158
174
  dataSlice: {
159
175
  offset: 0,
@@ -172,8 +188,9 @@ async function getReferralsByUser(umi, user) {
172
188
  // padding: [u8; 7],
173
189
  // authority: Pubkey,
174
190
  // referred_by_state: Pubkey,
175
- const userReferralState = (0, accountUtils_1.getReferralState)(user);
176
- const accounts = await umi.rpc.getProgramAccounts(generated_1.SOLAUTO_PROGRAM_ID, {
191
+ const programId = umi.programs.get("solauto").publicKey;
192
+ const userReferralState = (0, accountUtils_1.getReferralState)(user, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(programId));
193
+ const accounts = await umi.rpc.getProgramAccounts(programId, {
177
194
  commitment: "confirmed",
178
195
  dataSlice: {
179
196
  offset: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.228",
3
+ "version": "1.0.230",
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",
@@ -14,7 +14,6 @@ import {
14
14
  } from "@metaplex-foundation/umi-signer-wallet-adapters";
15
15
  import {
16
16
  claimReferralFees,
17
- createSolautoProgram,
18
17
  ReferralState,
19
18
  safeFetchReferralState,
20
19
  updateReferralStates,
@@ -42,18 +41,6 @@ export class ReferralStateManager extends TxHandler {
42
41
  public referredBy?: PublicKey;
43
42
  public referredByState?: PublicKey;
44
43
 
45
- constructor(
46
- rpcUrl: string,
47
- public localTest?: boolean
48
- ) {
49
- super(rpcUrl, localTest);
50
- this.umi = this.umi.use({
51
- install(umi) {
52
- umi.programs.add(createSolautoProgram(), false);
53
- },
54
- });
55
- }
56
-
57
44
  async initialize(args: ReferralStateManagerArgs) {
58
45
  if (!args.signer && !args.wallet) {
59
46
  throw new Error("Signer or wallet must be provided");
@@ -68,7 +55,8 @@ export class ReferralStateManager extends TxHandler {
68
55
  this.referralState = args.referralState
69
56
  ? args.referralState
70
57
  : getReferralState(
71
- args.authority ?? toWeb3JsPublicKey(this.signer.publicKey)
58
+ args.authority ?? toWeb3JsPublicKey(this.signer.publicKey),
59
+ this.programId
72
60
  );
73
61
  this.referralStateData = await safeFetchReferralState(
74
62
  this.umi,
@@ -104,7 +92,7 @@ export class ReferralStateManager extends TxHandler {
104
92
 
105
93
  this.referredBy = finalReferredBy;
106
94
  this.referredByState = finalReferredBy
107
- ? getReferralState(finalReferredBy)
95
+ ? getReferralState(finalReferredBy, this.programId)
108
96
  : this.referralStateData
109
97
  ? toWeb3JsPublicKey(this.referralStateData.referredByState)
110
98
  : undefined;
@@ -93,7 +93,8 @@ export abstract class SolautoClient extends ReferralStateManager {
93
93
  this.selfManaged = this.positionId === 0;
94
94
  this.solautoPosition = getSolautoPositionAccount(
95
95
  this.authority,
96
- this.positionId
96
+ this.positionId,
97
+ this.programId
97
98
  );
98
99
  this.solautoPositionData = !args.new
99
100
  ? await safeFetchSolautoPosition(
@@ -64,7 +64,6 @@ import {
64
64
  } from "../utils/marginfiUtils";
65
65
  import { bytesToI80F48, fromBaseUnit, toBps } from "../utils/numberUtils";
66
66
  import { QuoteResponse } from "@jup-ag/api";
67
- import { SOLAUTO_FEES_WALLET } from "../constants";
68
67
 
69
68
  export interface SolautoMarginfiClientArgs extends SolautoClientArgs {
70
69
  marginfiAccount?: PublicKey | Signer;
@@ -108,7 +107,8 @@ export class SolautoMarginfiClient extends SolautoClient {
108
107
  ? toWeb3JsPublicKey(this.solautoPositionData.position.protocolAccount)
109
108
  : getMarginfiAccountPDA(
110
109
  this.solautoPosition,
111
- this.marginfiAccountSeedIdx
110
+ this.marginfiAccountSeedIdx,
111
+ this.programId
112
112
  );
113
113
  }
114
114
  this.marginfiAccountPk =
@@ -1,18 +1,21 @@
1
1
  import { Umi } from "@metaplex-foundation/umi";
2
2
  import { Connection, PublicKey } from "@solana/web3.js";
3
- import { consoleLog, getSolanaRpcConnection } from "../utils";
3
+ import {
4
+ consoleLog,
5
+ getSolanaRpcConnection,
6
+ } from "../utils";
7
+ import { SOLAUTO_PROD_PROGRAM } from "../constants";
4
8
 
5
9
  export abstract class TxHandler {
6
- public rpcUrl!: string;
7
- public umi!: Umi;
8
10
  public connection!: Connection;
11
+ public umi!: Umi;
9
12
 
10
13
  constructor(
11
- rpcUrl: string,
12
- localTest?: boolean
14
+ public rpcUrl: string,
15
+ localTest?: boolean,
16
+ public programId: PublicKey = SOLAUTO_PROD_PROGRAM
13
17
  ) {
14
- this.rpcUrl = rpcUrl;
15
- const [connection, umi] = getSolanaRpcConnection(this.rpcUrl);
18
+ const [connection, umi] = getSolanaRpcConnection(this.rpcUrl, this.programId);
16
19
  this.connection = connection;
17
20
  this.umi = umi;
18
21
 
@@ -10,10 +10,16 @@ import {
10
10
  TOKEN_PROGRAM_ID,
11
11
  } from "@solana/spl-token";
12
12
  // import { JitoRpcConnection } from "jito-ts";
13
- import { SOLAUTO_PROGRAM_ID } from "../generated";
14
13
  import { SOLAUTO_MANAGER } from "./generalAccounts";
15
14
  import { JUPITER_PROGRAM_ID } from "../jupiter-sdk";
16
15
 
16
+ export const SOLAUTO_PROD_PROGRAM = new PublicKey(
17
+ "AutoyKBRaHSBHy9RsmXCZMy6nNFAg5FYijrvZyQcNLV"
18
+ );
19
+ export const SOLAUTO_TEST_PROGRAM = new PublicKey(
20
+ "TesTjfQ6TbXv96Tv6fqr95XTZ1LYPxtkafmShN9PjBp"
21
+ );
22
+
17
23
  (globalThis as any).LOCAL_TEST = false;
18
24
 
19
25
  export const BASIS_POINTS = 10000;
@@ -22,25 +28,25 @@ export const MIN_POSITION_STATE_FRESHNESS_SECS = 5;
22
28
  export const MIN_REPAY_GAP_BPS = 50;
23
29
  export const MIN_BOOST_GAP_BPS = 50;
24
30
 
31
+ export const PRICES: { [key: string]: { price: number; time: number } } = {};
32
+
33
+ export const SOLAUTO_LUT = "9D4xwZwDf46n9ft5gQxZzq3rBbdRXsXojKQLZbBdskPY";
34
+ export const STANDARD_LUT_ACCOUNTS = [
35
+ PublicKey.default,
36
+ SOLAUTO_PROD_PROGRAM,
37
+ SOLAUTO_TEST_PROGRAM,
38
+ SOLAUTO_MANAGER,
39
+ SystemProgram.programId,
40
+ TOKEN_PROGRAM_ID,
41
+ ASSOCIATED_TOKEN_PROGRAM_ID,
42
+ SYSVAR_CLOCK_PUBKEY,
43
+ SYSVAR_RENT_PUBKEY,
44
+ SYSVAR_INSTRUCTIONS_PUBKEY,
45
+ JUPITER_PROGRAM_ID,
46
+ ].map((x) => x.toString());
47
+
25
48
  // export const JITO_BLOCK_ENGINE = "ny.mainnet.block-engine.jito.wtf";
26
49
  // export const JITO_CONNECTION = new JitoRpcConnection(
27
50
  // `https://${JITO_BLOCK_ENGINE}`,
28
51
  // "finalized"
29
52
  // );
30
-
31
- export const PRICES: { [key: string]: { price: number; time: number; } } = {};
32
-
33
- export const SOLAUTO_LUT = "9D4xwZwDf46n9ft5gQxZzq3rBbdRXsXojKQLZbBdskPY";
34
-
35
- export const STANDARD_LUT_ACCOUNTS = [
36
- PublicKey.default.toString(),
37
- SOLAUTO_PROGRAM_ID,
38
- SOLAUTO_MANAGER.toString(),
39
- SystemProgram.programId.toString(),
40
- TOKEN_PROGRAM_ID.toString(),
41
- ASSOCIATED_TOKEN_PROGRAM_ID.toString(),
42
- SYSVAR_CLOCK_PUBKEY.toString(),
43
- SYSVAR_RENT_PUBKEY.toString(),
44
- SYSVAR_INSTRUCTIONS_PUBKEY.toString(),
45
- JUPITER_PROGRAM_ID
46
- ];
@@ -11,13 +11,10 @@ import { PublicKey, SYSVAR_INSTRUCTIONS_PUBKEY } from "@solana/web3.js";
11
11
  import {
12
12
  ACCOUNT_SIZE as TOKEN_ACCOUNT_SIZE,
13
13
  NATIVE_MINT,
14
- RawAccount,
15
14
  } from "@solana/spl-token";
16
15
  import {
17
16
  InvalidRebalanceConditionError,
18
17
  LendingPlatform,
19
- ReferralState,
20
- SOLAUTO_PROGRAM_ID,
21
18
  SolautoAction,
22
19
  SolautoRebalanceType,
23
20
  TokenType,
@@ -27,7 +24,6 @@ import {
27
24
  getMarginfiRebalanceInstructionDataSerializer,
28
25
  getSolautoErrorFromCode,
29
26
  isSolautoAction,
30
- safeFetchReferralState,
31
27
  solautoAction,
32
28
  } from "../generated";
33
29
  import { SolautoClient } from "../clients/solautoClient";
@@ -76,7 +72,7 @@ import {
76
72
  getJupiterErrorFromName,
77
73
  JUPITER_PROGRAM_ID,
78
74
  } from "../jupiter-sdk";
79
- import { PRICES, SOLAUTO_FEES_WALLET } from "../constants";
75
+ import { PRICES } from "../constants";
80
76
  import { TransactionItemInputs } from "../types";
81
77
 
82
78
  interface wSolTokenUsage {
@@ -263,7 +259,7 @@ export async function rebalanceChoresBefore(
263
259
  tx: TransactionBuilder,
264
260
  accountsGettingCreated: string[]
265
261
  ): Promise<TransactionBuilder> {
266
- const rebalanceInstructions = getRebalanceInstructions(tx);
262
+ const rebalanceInstructions = getRebalanceInstructions(client.umi, tx);
267
263
  if (rebalanceInstructions.length === 0) {
268
264
  return transactionBuilder();
269
265
  }
@@ -404,9 +400,9 @@ function transactionChoresAfter(
404
400
  return chores;
405
401
  }
406
402
 
407
- function getRebalanceInstructions(tx: TransactionBuilder): Instruction[] {
403
+ function getRebalanceInstructions(umi: Umi, tx: TransactionBuilder): Instruction[] {
408
404
  return tx.getInstructions().filter((x) => {
409
- if (x.programId === SOLAUTO_PROGRAM_ID) {
405
+ if (x.programId.toString() === umi.programs.get("solauto").publicKey.toString()) {
410
406
  try {
411
407
  const serializer = getMarginfiRebalanceInstructionDataSerializer();
412
408
  const discriminator = serializer.serialize({
@@ -424,11 +420,11 @@ function getRebalanceInstructions(tx: TransactionBuilder): Instruction[] {
424
420
  });
425
421
  }
426
422
 
427
- function getSolautoActions(tx: TransactionBuilder): SolautoAction[] {
423
+ function getSolautoActions(umi: Umi, tx: TransactionBuilder): SolautoAction[] {
428
424
  let solautoActions: SolautoAction[] = [];
429
425
 
430
426
  tx.getInstructions().forEach((x) => {
431
- if (x.programId === SOLAUTO_PROGRAM_ID) {
427
+ if (x.programId.toString() === umi.programs.get("solauto").publicKey.toString()) {
432
428
  try {
433
429
  const serializer =
434
430
  getMarginfiProtocolInteractionInstructionDataSerializer();
@@ -562,7 +558,7 @@ export async function getTransactionChores(
562
558
  let choresAfter = transactionBuilder();
563
559
  const accountsGettingCreated: string[] = [];
564
560
 
565
- const solautoActions = getSolautoActions(tx);
561
+ const solautoActions = getSolautoActions(client.umi, tx);
566
562
 
567
563
  choresBefore = choresBefore.add([
568
564
  await transactionChoresBefore(
@@ -798,7 +794,7 @@ export async function convertReferralFeesToDestination(
798
794
  return { tx, lookupTableAddresses };
799
795
  }
800
796
 
801
- export function getErrorInfo(tx: TransactionBuilder, error: any) {
797
+ export function getErrorInfo(umi: Umi, tx: TransactionBuilder, error: any) {
802
798
  let canBeIgnored = false;
803
799
  let errorName: string | undefined = undefined;
804
800
  let errorInfo: string | undefined = undefined;
@@ -811,7 +807,7 @@ export function getErrorInfo(tx: TransactionBuilder, error: any) {
811
807
  const errIx = tx.getInstructions()[Math.max(0, err[0] - 2)];
812
808
  const errCode = err[1]["Custom"];
813
809
 
814
- if (errIx.programId === SOLAUTO_PROGRAM_ID) {
810
+ if (errIx.programId.toString() === umi.programs.get("solauto").publicKey.toString()) {
815
811
  programError = getSolautoErrorFromCode(errCode, createSolautoProgram());
816
812
  if (
817
813
  programError?.name ===
@@ -526,7 +526,7 @@ export class TransactionsManager {
526
526
  txSig ? bs58.encode(txSig) : undefined
527
527
  );
528
528
  } catch (e: any) {
529
- const errorDetails = getErrorInfo(tx, e);
529
+ const errorDetails = getErrorInfo(this.txHandler.umi, tx, e);
530
530
 
531
531
  this.updateStatus(
532
532
  txName,
@@ -1,6 +1,5 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import { AccountLayout as SplTokenAccountLayout, getAssociatedTokenAddressSync } from "@solana/spl-token";
3
- import { SOLAUTO_PROGRAM_ID } from "../generated";
4
3
  import { publicKey, Umi } from "@metaplex-foundation/umi";
5
4
 
6
5
  export function bufferFromU8(num: number): Buffer {
@@ -38,23 +37,24 @@ export async function getTokenAccountData(umi: Umi, tokenAccount: PublicKey) {
38
37
 
39
38
  export function getSolautoPositionAccount(
40
39
  signer: PublicKey,
41
- positionId: number
40
+ positionId: number,
41
+ programId: PublicKey
42
42
  ) {
43
43
  const [positionAccount, _] = PublicKey.findProgramAddressSync(
44
44
  [bufferFromU8(positionId), signer.toBuffer()],
45
- new PublicKey(SOLAUTO_PROGRAM_ID)
45
+ programId
46
46
  );
47
47
 
48
48
  return positionAccount;
49
49
  }
50
50
 
51
- export function getReferralState(authority: PublicKey) {
51
+ export function getReferralState(authority: PublicKey, programId: PublicKey) {
52
52
  const str = "referral_state";
53
53
  const strBuffer = Buffer.from(str, "utf-8");
54
54
 
55
55
  const [ReferralState, _] = PublicKey.findProgramAddressSync(
56
56
  [strBuffer, authority.toBuffer()],
57
- new PublicKey(SOLAUTO_PROGRAM_ID)
57
+ programId
58
58
  );
59
59
 
60
60
  return ReferralState;
@@ -62,7 +62,8 @@ export function getReferralState(authority: PublicKey) {
62
62
 
63
63
  export function getMarginfiAccountPDA(
64
64
  solautoPositionAccount: PublicKey,
65
- marginfiAccountSeedIdx: bigint
65
+ marginfiAccountSeedIdx: bigint,
66
+ programId: PublicKey
66
67
  ) {
67
68
  const seeds = [
68
69
  solautoPositionAccount.toBuffer(),
@@ -71,7 +72,7 @@ export function getMarginfiAccountPDA(
71
72
 
72
73
  const [marginfiAccount, _] = PublicKey.findProgramAddressSync(
73
74
  seeds,
74
- new PublicKey(SOLAUTO_PROGRAM_ID)
75
+ programId
75
76
  );
76
77
 
77
78
  return marginfiAccount;
@@ -37,6 +37,8 @@ import {
37
37
  getLendingAccountStartFlashloanInstructionDataSerializer,
38
38
  } from "../marginfi-sdk";
39
39
  import { PriorityFeeSetting, TransactionRunType } from "../types";
40
+ import { createDynamicSolautoProgram } from "./solauto";
41
+ import { SOLAUTO_PROD_PROGRAM } from "../constants";
40
42
 
41
43
  export function buildHeliusApiUrl(heliusApiKey: string) {
42
44
  return `https://mainnet.helius-rpc.com/?api-key=${heliusApiKey}`;
@@ -47,10 +49,15 @@ export function buildIronforgeApiUrl(ironforgeApiKey: string) {
47
49
  }
48
50
 
49
51
  export function getSolanaRpcConnection(
50
- rpcUrl: string
52
+ rpcUrl: string,
53
+ programId: PublicKey = SOLAUTO_PROD_PROGRAM,
51
54
  ): [Connection, Umi] {
52
55
  const connection = new Connection(rpcUrl, "confirmed");
53
- const umi = createUmi(connection);
56
+ const umi = createUmi(connection).use({
57
+ install(umi) {
58
+ umi.programs.add(createDynamicSolautoProgram(programId), false);
59
+ },
60
+ });
54
61
  return [connection, umi];
55
62
  }
56
63
 
@@ -1,5 +1,5 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
- import { isOption, isSome, publicKey, Umi } from "@metaplex-foundation/umi";
2
+ import { isOption, isSome, Program, publicKey, Umi } from "@metaplex-foundation/umi";
3
3
  import {
4
4
  AutomationSettings,
5
5
  DCASettings,
@@ -7,11 +7,12 @@ import {
7
7
  LendingPlatform,
8
8
  PositionState,
9
9
  PositionType,
10
- SOLAUTO_PROGRAM_ID,
11
10
  SolautoSettingsParameters,
12
11
  SolautoSettingsParametersInpArgs,
13
12
  TokenType,
14
13
  getReferralStateSize,
14
+ getSolautoErrorFromCode,
15
+ getSolautoErrorFromName,
15
16
  getSolautoPositionAccountDataSerializer,
16
17
  getSolautoPositionSize,
17
18
  } from "../../generated";
@@ -31,6 +32,22 @@ import {
31
32
  import { getAllMarginfiAccountsByAuthority } from "../marginfiUtils";
32
33
  import { RebalanceAction, SolautoPositionDetails } from "../../types/solauto";
33
34
 
35
+ export function createDynamicSolautoProgram(programId: PublicKey): Program {
36
+ return {
37
+ name: 'solauto',
38
+ publicKey: publicKey(programId),
39
+ getErrorFromCode(code: number, cause?: Error) {
40
+ return getSolautoErrorFromCode(code, this, cause);
41
+ },
42
+ getErrorFromName(name: string, cause?: Error) {
43
+ return getSolautoErrorFromName(name, this, cause);
44
+ },
45
+ isOnCluster() {
46
+ return true;
47
+ },
48
+ };
49
+ }
50
+
34
51
  function newPeriodsPassed(
35
52
  automation: AutomationSettings,
36
53
  currentUnixTimestamp: number
@@ -176,7 +193,7 @@ export async function getSolautoManagedPositions(
176
193
  // supply mint: pubkey
177
194
  // debt mint: pubkey
178
195
 
179
- const accounts = await umi.rpc.getProgramAccounts(SOLAUTO_PROGRAM_ID, {
196
+ const accounts = await umi.rpc.getProgramAccounts(umi.programs.get("solauto").publicKey, {
180
197
  commitment: "confirmed",
181
198
  dataSlice: {
182
199
  offset: 0,
@@ -234,7 +251,7 @@ export async function getSolautoManagedPositions(
234
251
  }
235
252
 
236
253
  export async function getAllReferralStates(umi: Umi): Promise<PublicKey[]> {
237
- const accounts = await umi.rpc.getProgramAccounts(SOLAUTO_PROGRAM_ID, {
254
+ const accounts = await umi.rpc.getProgramAccounts(umi.programs.get("solauto").publicKey, {
238
255
  commitment: "confirmed",
239
256
  dataSlice: {
240
257
  offset: 0,
@@ -259,8 +276,9 @@ export async function getReferralsByUser(
259
276
  // authority: Pubkey,
260
277
  // referred_by_state: Pubkey,
261
278
 
262
- const userReferralState = getReferralState(user);
263
- const accounts = await umi.rpc.getProgramAccounts(SOLAUTO_PROGRAM_ID, {
279
+ const programId = umi.programs.get("solauto").publicKey;
280
+ const userReferralState = getReferralState(user, toWeb3JsPublicKey(programId));
281
+ const accounts = await umi.rpc.getProgramAccounts(programId, {
264
282
  commitment: "confirmed",
265
283
  dataSlice: {
266
284
  offset: 0,
@@ -20,22 +20,23 @@ import {
20
20
  TransactionsManager,
21
21
  } from "../../src/transactions/transactionsManager";
22
22
  import { PublicKey } from "@solana/web3.js";
23
- import { USDC } from "../../src/constants";
23
+ import { SOLAUTO_TEST_PROGRAM, USDC } from "../../src/constants";
24
24
  import { buildHeliusApiUrl } from "../../src/utils";
25
25
  import { PriorityFeeSetting } from "../../src/types";
26
26
 
27
27
  describe("Solauto Marginfi tests", async () => {
28
- // const signer = setupTest();
29
- const signer = setupTest("solauto-manager");
28
+ const signer = setupTest();
29
+ // const signer = setupTest("solauto-manager");
30
30
 
31
- const payForTransactions = true;
31
+ const payForTransactions = false;
32
32
  const useJitoBundle = false;
33
33
  const positionId = 1;
34
34
 
35
35
  it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
36
36
  const client = new SolautoMarginfiClient(
37
37
  buildHeliusApiUrl(process.env.HELIUS_API_KEY!),
38
- true
38
+ true,
39
+ SOLAUTO_TEST_PROGRAM
39
40
  );
40
41
 
41
42
  const supply = NATIVE_MINT;
@@ -128,7 +129,7 @@ describe("Solauto Marginfi tests", async () => {
128
129
  transactionItems.push(
129
130
  new TransactionItem(
130
131
  async (attemptNum) =>
131
- await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
132
+ await buildSolautoRebalanceTransaction(client, 7000, attemptNum),
132
133
  "rebalance"
133
134
  )
134
135
  );