@optimex-xyz/market-maker-sdk 0.1.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -3,7 +3,6 @@ import { z } from 'zod';
3
3
 
4
4
  type Environment = 'dev' | 'production';
5
5
  interface EnvironmentConfig {
6
- solverUrl: string;
7
6
  backendUrl: string;
8
7
  rpcUrl: string;
9
8
  routerAddress: string;
@@ -13,11 +12,16 @@ interface AppConfig extends EnvironmentConfig {
13
12
  env: Environment;
14
13
  }
15
14
  declare class Config {
16
- private readonly env;
17
- private readonly config;
15
+ private env;
16
+ private config;
18
17
  constructor();
18
+ /**
19
+ * Set the environment for the SDK
20
+ * @param env The environment to use ('dev' or 'production')
21
+ */
22
+ setEnvironment(env: Environment): void;
23
+ private validateAndGetConfig;
19
24
  get(): AppConfig;
20
- getSolverUrl(): string;
21
25
  getBackendUrl(): string;
22
26
  getRpcUrl(): string;
23
27
  getRouterAddress(): string;
@@ -25,6 +29,15 @@ declare class Config {
25
29
  }
26
30
  declare const config: Config;
27
31
 
32
+ declare class SDK {
33
+ /**
34
+ * Initialize the SDK with a specific environment
35
+ * @param env The environment to use ('dev' or 'production')
36
+ */
37
+ setEnvironment(env: Environment): void;
38
+ }
39
+ declare const sdk: SDK;
40
+
28
41
  interface TypedDeferredTopicFilter<_TCEvent extends TypedContractEvent> extends DeferredTopicFilter {
29
42
  }
30
43
  interface TypedContractEvent<InputTuple extends Array<any> = any, OutputTuple extends Array<any> = any, OutputObject = any> {
@@ -4644,23 +4657,6 @@ declare class SolverService {
4644
4657
  * @throws Error if the request fails or validation fails
4645
4658
  */
4646
4659
  submitSettlementTx(params: SubmitSettlementRequest): Promise<SubmitSettlementResponse>;
4647
- /**
4648
- * Helper function to format and submit a single trade settlement
4649
- * @param tradeId The ID of the trade to settle
4650
- * @param pmmId The PMM's identifier
4651
- * @param settlementTx The settlement transaction data
4652
- * @param signature The PMM's signature
4653
- */
4654
- submitSingleSettlement(tradeId: string, pmmId: string, settlementTx: string, signature: string, signedAt: number): Promise<SubmitSettlementResponse>;
4655
- /**
4656
- * Helper function to submit multiple trade settlements in one transaction
4657
- * @param tradeIds Array of trade IDs to settle
4658
- * @param pmmId The PMM's identifier
4659
- * @param settlementTx The settlement transaction data
4660
- * @param signature The PMM's signature
4661
- * @param startIndex Starting index for batch processing
4662
- */
4663
- submitBatchSettlement(tradeIds: string[], pmmId: string, settlementTx: string, signature: string, signedAt: number, startIndex?: number): Promise<SubmitSettlementResponse>;
4664
4660
  }
4665
4661
  declare const solverService: SolverService;
4666
4662
 
@@ -4735,16 +4731,8 @@ declare class TokenService {
4735
4731
  }
4736
4732
  declare const tokenService: TokenService;
4737
4733
 
4738
- declare function getPresignHash(pmmRecvAddress: AddressLike, amountIn: bigint): string;
4739
- declare function getDepositConfirmationHash(amountIn: bigint, fromChain: [BytesLike, BytesLike, BytesLike], depositTxId: BytesLike, depositFromList: BytesLike[]): string;
4740
- declare function getSelectPMMHash(pmmId: BytesLike, pmmRecvAddress: BytesLike, toChain: BytesLike, toToken: BytesLike, amountOut: bigint, expiry: bigint): string;
4741
- declare function getRFQHash(minAmountOut: bigint, tradeTimeout: bigint): string;
4742
4734
  declare function getTradeIdsHash(tradeIds: BytesLike[]): string;
4743
4735
  declare function getMakePaymentHash(tradeIds: BytesLike[], signedAt: bigint, startIdx: bigint, paymentTxId: BytesLike): string;
4744
- declare function getBTCEVMConfirmPaymentHash(protocolFee: bigint, paymentAmount: bigint, toChain: [BytesLike, BytesLike, BytesLike], paymentTxId: BytesLike): string;
4745
- declare function getEVMBTCConfirmPaymentHash(paymentAmount: bigint, toChain: [BytesLike, BytesLike, BytesLike], paymentTxId: BytesLike): string;
4746
- declare function getBTCEVMConfirmSettlementHash(releaseTxId: BytesLike): string;
4747
- declare function getEVMBTCConfirmSettlementHash(protocolFee: bigint, releaseTxId: BytesLike): string;
4748
4736
  declare function getCommitInfoHash(pmmId: BytesLike, pmmRecvAddr: BytesLike, toChain: BytesLike, toToken: BytesLike, amountOut: bigint, expiry: bigint): string;
4749
4737
 
4750
4738
  declare enum SignatureType {
@@ -4810,4 +4798,4 @@ declare function camelToSnakeCase(str: string): string;
4810
4798
  declare const ensureHexPrefix: (value: string) => string;
4811
4799
  declare const removeHexPrefix: (value: string) => string;
4812
4800
 
4813
- export { type AppConfig, type ERC20, ERC20__factory, type Environment, type EnvironmentConfig, ITypes, type Payment, Payment__factory, type Router, RouterService, Router__factory, SignatureType, type Signer, SignerService, Signer__factory, SolverService, type Token, TokenSchema, TokenService, camelToSnakeCase, config, confirmDepositType, confirmPaymentType, confirmSettlementType, convertToCamelCase, convertToSnakeCase, ensureHexPrefix, index as factories, getBTCEVMConfirmPaymentHash, getBTCEVMConfirmSettlementHash, getCommitInfoHash, getDepositConfirmationHash, getEVMBTCConfirmPaymentHash, getEVMBTCConfirmSettlementHash, getMakePaymentHash, getPresignHash, getRFQHash, getSelectPMMHash, getSignature, getSigner, getTradeIdsHash, makePaymentType, presignType, removeHexPrefix, rfqAuthenticationTypes, routerService, selectionType, signerService, snakeToCamelCase, solverService, tokenService };
4801
+ export { type AppConfig, type ERC20, ERC20__factory, type Environment, type EnvironmentConfig, ITypes, type Payment, Payment__factory, type Router, RouterService, Router__factory, SDK, SignatureType, type Signer, SignerService, Signer__factory, SolverService, type Token, TokenSchema, TokenService, camelToSnakeCase, config, confirmDepositType, confirmPaymentType, confirmSettlementType, convertToCamelCase, convertToSnakeCase, ensureHexPrefix, index as factories, getCommitInfoHash, getMakePaymentHash, getSignature, getSigner, getTradeIdsHash, makePaymentType, presignType, removeHexPrefix, rfqAuthenticationTypes, routerService, sdk, selectionType, signerService, snakeToCamelCase, solverService, tokenService };
package/dist/index.d.ts CHANGED
@@ -3,7 +3,6 @@ import { z } from 'zod';
3
3
 
4
4
  type Environment = 'dev' | 'production';
5
5
  interface EnvironmentConfig {
6
- solverUrl: string;
7
6
  backendUrl: string;
8
7
  rpcUrl: string;
9
8
  routerAddress: string;
@@ -13,11 +12,16 @@ interface AppConfig extends EnvironmentConfig {
13
12
  env: Environment;
14
13
  }
15
14
  declare class Config {
16
- private readonly env;
17
- private readonly config;
15
+ private env;
16
+ private config;
18
17
  constructor();
18
+ /**
19
+ * Set the environment for the SDK
20
+ * @param env The environment to use ('dev' or 'production')
21
+ */
22
+ setEnvironment(env: Environment): void;
23
+ private validateAndGetConfig;
19
24
  get(): AppConfig;
20
- getSolverUrl(): string;
21
25
  getBackendUrl(): string;
22
26
  getRpcUrl(): string;
23
27
  getRouterAddress(): string;
@@ -25,6 +29,15 @@ declare class Config {
25
29
  }
26
30
  declare const config: Config;
27
31
 
32
+ declare class SDK {
33
+ /**
34
+ * Initialize the SDK with a specific environment
35
+ * @param env The environment to use ('dev' or 'production')
36
+ */
37
+ setEnvironment(env: Environment): void;
38
+ }
39
+ declare const sdk: SDK;
40
+
28
41
  interface TypedDeferredTopicFilter<_TCEvent extends TypedContractEvent> extends DeferredTopicFilter {
29
42
  }
30
43
  interface TypedContractEvent<InputTuple extends Array<any> = any, OutputTuple extends Array<any> = any, OutputObject = any> {
@@ -4644,23 +4657,6 @@ declare class SolverService {
4644
4657
  * @throws Error if the request fails or validation fails
4645
4658
  */
4646
4659
  submitSettlementTx(params: SubmitSettlementRequest): Promise<SubmitSettlementResponse>;
4647
- /**
4648
- * Helper function to format and submit a single trade settlement
4649
- * @param tradeId The ID of the trade to settle
4650
- * @param pmmId The PMM's identifier
4651
- * @param settlementTx The settlement transaction data
4652
- * @param signature The PMM's signature
4653
- */
4654
- submitSingleSettlement(tradeId: string, pmmId: string, settlementTx: string, signature: string, signedAt: number): Promise<SubmitSettlementResponse>;
4655
- /**
4656
- * Helper function to submit multiple trade settlements in one transaction
4657
- * @param tradeIds Array of trade IDs to settle
4658
- * @param pmmId The PMM's identifier
4659
- * @param settlementTx The settlement transaction data
4660
- * @param signature The PMM's signature
4661
- * @param startIndex Starting index for batch processing
4662
- */
4663
- submitBatchSettlement(tradeIds: string[], pmmId: string, settlementTx: string, signature: string, signedAt: number, startIndex?: number): Promise<SubmitSettlementResponse>;
4664
4660
  }
4665
4661
  declare const solverService: SolverService;
4666
4662
 
@@ -4735,16 +4731,8 @@ declare class TokenService {
4735
4731
  }
4736
4732
  declare const tokenService: TokenService;
4737
4733
 
4738
- declare function getPresignHash(pmmRecvAddress: AddressLike, amountIn: bigint): string;
4739
- declare function getDepositConfirmationHash(amountIn: bigint, fromChain: [BytesLike, BytesLike, BytesLike], depositTxId: BytesLike, depositFromList: BytesLike[]): string;
4740
- declare function getSelectPMMHash(pmmId: BytesLike, pmmRecvAddress: BytesLike, toChain: BytesLike, toToken: BytesLike, amountOut: bigint, expiry: bigint): string;
4741
- declare function getRFQHash(minAmountOut: bigint, tradeTimeout: bigint): string;
4742
4734
  declare function getTradeIdsHash(tradeIds: BytesLike[]): string;
4743
4735
  declare function getMakePaymentHash(tradeIds: BytesLike[], signedAt: bigint, startIdx: bigint, paymentTxId: BytesLike): string;
4744
- declare function getBTCEVMConfirmPaymentHash(protocolFee: bigint, paymentAmount: bigint, toChain: [BytesLike, BytesLike, BytesLike], paymentTxId: BytesLike): string;
4745
- declare function getEVMBTCConfirmPaymentHash(paymentAmount: bigint, toChain: [BytesLike, BytesLike, BytesLike], paymentTxId: BytesLike): string;
4746
- declare function getBTCEVMConfirmSettlementHash(releaseTxId: BytesLike): string;
4747
- declare function getEVMBTCConfirmSettlementHash(protocolFee: bigint, releaseTxId: BytesLike): string;
4748
4736
  declare function getCommitInfoHash(pmmId: BytesLike, pmmRecvAddr: BytesLike, toChain: BytesLike, toToken: BytesLike, amountOut: bigint, expiry: bigint): string;
4749
4737
 
4750
4738
  declare enum SignatureType {
@@ -4810,4 +4798,4 @@ declare function camelToSnakeCase(str: string): string;
4810
4798
  declare const ensureHexPrefix: (value: string) => string;
4811
4799
  declare const removeHexPrefix: (value: string) => string;
4812
4800
 
4813
- export { type AppConfig, type ERC20, ERC20__factory, type Environment, type EnvironmentConfig, ITypes, type Payment, Payment__factory, type Router, RouterService, Router__factory, SignatureType, type Signer, SignerService, Signer__factory, SolverService, type Token, TokenSchema, TokenService, camelToSnakeCase, config, confirmDepositType, confirmPaymentType, confirmSettlementType, convertToCamelCase, convertToSnakeCase, ensureHexPrefix, index as factories, getBTCEVMConfirmPaymentHash, getBTCEVMConfirmSettlementHash, getCommitInfoHash, getDepositConfirmationHash, getEVMBTCConfirmPaymentHash, getEVMBTCConfirmSettlementHash, getMakePaymentHash, getPresignHash, getRFQHash, getSelectPMMHash, getSignature, getSigner, getTradeIdsHash, makePaymentType, presignType, removeHexPrefix, rfqAuthenticationTypes, routerService, selectionType, signerService, snakeToCamelCase, solverService, tokenService };
4801
+ export { type AppConfig, type ERC20, ERC20__factory, type Environment, type EnvironmentConfig, ITypes, type Payment, Payment__factory, type Router, RouterService, Router__factory, SDK, SignatureType, type Signer, SignerService, Signer__factory, SolverService, type Token, TokenSchema, TokenService, camelToSnakeCase, config, confirmDepositType, confirmPaymentType, confirmSettlementType, convertToCamelCase, convertToSnakeCase, ensureHexPrefix, index as factories, getCommitInfoHash, getMakePaymentHash, getSignature, getSigner, getTradeIdsHash, makePaymentType, presignType, removeHexPrefix, rfqAuthenticationTypes, routerService, sdk, selectionType, signerService, snakeToCamelCase, solverService, tokenService };
package/dist/index.js CHANGED
@@ -34,6 +34,7 @@ __export(index_exports, {
34
34
  Payment__factory: () => Payment__factory,
35
35
  RouterService: () => RouterService,
36
36
  Router__factory: () => Router__factory,
37
+ SDK: () => SDK,
37
38
  SignatureType: () => SignatureType,
38
39
  SignerService: () => SignerService,
39
40
  Signer__factory: () => Signer__factory,
@@ -49,16 +50,8 @@ __export(index_exports, {
49
50
  convertToSnakeCase: () => convertToSnakeCase,
50
51
  ensureHexPrefix: () => ensureHexPrefix,
51
52
  factories: () => factories_exports,
52
- getBTCEVMConfirmPaymentHash: () => getBTCEVMConfirmPaymentHash,
53
- getBTCEVMConfirmSettlementHash: () => getBTCEVMConfirmSettlementHash,
54
53
  getCommitInfoHash: () => getCommitInfoHash,
55
- getDepositConfirmationHash: () => getDepositConfirmationHash,
56
- getEVMBTCConfirmPaymentHash: () => getEVMBTCConfirmPaymentHash,
57
- getEVMBTCConfirmSettlementHash: () => getEVMBTCConfirmSettlementHash,
58
54
  getMakePaymentHash: () => getMakePaymentHash,
59
- getPresignHash: () => getPresignHash,
60
- getRFQHash: () => getRFQHash,
61
- getSelectPMMHash: () => getSelectPMMHash,
62
55
  getSignature: () => getSignature,
63
56
  getSigner: () => getSigner,
64
57
  getTradeIdsHash: () => getTradeIdsHash,
@@ -67,6 +60,7 @@ __export(index_exports, {
67
60
  removeHexPrefix: () => removeHexPrefix,
68
61
  rfqAuthenticationTypes: () => rfqAuthenticationTypes,
69
62
  routerService: () => routerService,
63
+ sdk: () => sdk,
70
64
  selectionType: () => selectionType,
71
65
  signerService: () => signerService,
72
66
  snakeToCamelCase: () => snakeToCamelCase,
@@ -78,7 +72,6 @@ module.exports = __toCommonJS(index_exports);
78
72
  // src/config/config.ts
79
73
  var environments = {
80
74
  dev: {
81
- solverUrl: "https://pre-bitfi-solver.kyberengineering.io",
82
75
  backendUrl: "https://api-stg.bitdex.xyz",
83
76
  rpcUrl: "https://rpc-bitfi-p00c4t1rul.t.conduit.xyz",
84
77
  routerAddress: "0xc0B01A53B15bacAF6f81aF1F6B001E8c8130256e",
@@ -87,22 +80,35 @@ var environments = {
87
80
  }
88
81
  },
89
82
  production: {
90
- solverUrl: "https://bitfi-solver.kyberengineering.io",
91
83
  backendUrl: "https://api.petafi.xyz",
92
84
  rpcUrl: "https://bitfi-ledger-testnet.alt.technology",
93
- routerAddress: "0x07468dF194817257e73cA71E938C1ef977Be032F",
85
+ routerAddress: "0x272599CE3602A49B580A5C4a4d3C1067E30248D2",
94
86
  paymentAddressMap: {
95
- ethereum: "0x05d60d78ec4896c041268b68fcef2294b16123c3"
87
+ ethereum: "x0A497AC4261E37FA4062762C23Cf3cB642C839b8"
96
88
  }
97
89
  }
98
90
  };
99
91
  var Config = class {
100
92
  constructor() {
101
93
  this.env = process.env.SDK_ENV || "production";
102
- if (!environments[this.env]) {
103
- throw new Error(`Unsupported environment: ${this.env}`);
94
+ this.config = this.validateAndGetConfig(this.env);
95
+ }
96
+ /**
97
+ * Set the environment for the SDK
98
+ * @param env The environment to use ('dev' or 'production')
99
+ */
100
+ setEnvironment(env) {
101
+ if (!environments[env]) {
102
+ throw new Error(`Unsupported environment: ${env}`);
103
+ }
104
+ this.env = env;
105
+ this.config = environments[env];
106
+ }
107
+ validateAndGetConfig(env) {
108
+ if (!environments[env]) {
109
+ throw new Error(`Unsupported environment: ${env}`);
104
110
  }
105
- this.config = environments[this.env];
111
+ return environments[env];
106
112
  }
107
113
  get() {
108
114
  return {
@@ -110,9 +116,6 @@ var Config = class {
110
116
  ...this.config
111
117
  };
112
118
  }
113
- getSolverUrl() {
114
- return this.config.solverUrl;
115
- }
116
119
  getBackendUrl() {
117
120
  return this.config.backendUrl;
118
121
  }
@@ -128,6 +131,18 @@ var Config = class {
128
131
  };
129
132
  var config = new Config();
130
133
 
134
+ // src/config/sdk.ts
135
+ var SDK = class {
136
+ /**
137
+ * Initialize the SDK with a specific environment
138
+ * @param env The environment to use ('dev' or 'production')
139
+ */
140
+ setEnvironment(env) {
141
+ config.setEnvironment(env);
142
+ }
143
+ };
144
+ var sdk = new SDK();
145
+
131
146
  // src/contracts/contract/factories/index.ts
132
147
  var factories_exports = {};
133
148
  __export(factories_exports, {
@@ -3621,7 +3636,7 @@ var SubmitSettlementResponseSchema = import_zod.z.object({
3621
3636
  });
3622
3637
  var SolverService = class {
3623
3638
  constructor() {
3624
- this.baseURL = config.getSolverUrl();
3639
+ this.baseURL = config.getBackendUrl();
3625
3640
  }
3626
3641
  /**
3627
3642
  * Submits a settlement transaction to the solver backend
@@ -3634,7 +3649,7 @@ var SolverService = class {
3634
3649
  SubmitSettlementRequestSchema.parse(params);
3635
3650
  const snakeCaseParams = convertToSnakeCase(params);
3636
3651
  const response = await import_axios.default.post(
3637
- `${this.baseURL}/submit-settlement-tx`,
3652
+ `${this.baseURL}/solver/submit-settlement-tx`,
3638
3653
  snakeCaseParams,
3639
3654
  {
3640
3655
  headers: {
@@ -3654,41 +3669,6 @@ var SolverService = class {
3654
3669
  throw error;
3655
3670
  }
3656
3671
  }
3657
- /**
3658
- * Helper function to format and submit a single trade settlement
3659
- * @param tradeId The ID of the trade to settle
3660
- * @param pmmId The PMM's identifier
3661
- * @param settlementTx The settlement transaction data
3662
- * @param signature The PMM's signature
3663
- */
3664
- async submitSingleSettlement(tradeId, pmmId, settlementTx, signature, signedAt) {
3665
- return this.submitSettlementTx({
3666
- tradeIds: [tradeId],
3667
- pmmId,
3668
- settlementTx,
3669
- signature,
3670
- startIndex: 0,
3671
- signedAt
3672
- });
3673
- }
3674
- /**
3675
- * Helper function to submit multiple trade settlements in one transaction
3676
- * @param tradeIds Array of trade IDs to settle
3677
- * @param pmmId The PMM's identifier
3678
- * @param settlementTx The settlement transaction data
3679
- * @param signature The PMM's signature
3680
- * @param startIndex Starting index for batch processing
3681
- */
3682
- async submitBatchSettlement(tradeIds, pmmId, settlementTx, signature, signedAt, startIndex = 0) {
3683
- return this.submitSettlementTx({
3684
- tradeIds,
3685
- pmmId,
3686
- settlementTx,
3687
- signature,
3688
- startIndex,
3689
- signedAt
3690
- });
3691
- }
3692
3672
  };
3693
3673
  var solverService = new SolverService();
3694
3674
 
@@ -3812,30 +3792,6 @@ async function defaultDomain(signerHelper, provider) {
3812
3792
  // src/signatures/getInfoHash.ts
3813
3793
  var import_ethers7 = require("ethers");
3814
3794
  var abiCoder = import_ethers7.AbiCoder.defaultAbiCoder();
3815
- function getPresignHash(pmmRecvAddress, amountIn) {
3816
- const infoHash = (0, import_ethers7.keccak256)(abiCoder.encode(["address", "uint256"], [pmmRecvAddress, amountIn]));
3817
- return infoHash;
3818
- }
3819
- function getDepositConfirmationHash(amountIn, fromChain, depositTxId, depositFromList) {
3820
- const depositHash = (0, import_ethers7.keccak256)(
3821
- abiCoder.encode(["uint256", "bytes[3]", "bytes[]"], [amountIn, fromChain, depositFromList])
3822
- );
3823
- const infoHash = (0, import_ethers7.keccak256)(abiCoder.encode(["bytes32", "bytes"], [depositHash, depositTxId]));
3824
- return infoHash;
3825
- }
3826
- function getSelectPMMHash(pmmId, pmmRecvAddress, toChain, toToken, amountOut, expiry) {
3827
- const infoHash = (0, import_ethers7.keccak256)(
3828
- abiCoder.encode(
3829
- ["bytes32", "bytes", "bytes", "bytes", "uint256", "uint256"],
3830
- [pmmId, pmmRecvAddress, toChain, toToken, amountOut, expiry]
3831
- )
3832
- );
3833
- return infoHash;
3834
- }
3835
- function getRFQHash(minAmountOut, tradeTimeout) {
3836
- const infoHash = (0, import_ethers7.keccak256)(abiCoder.encode(["uint256", "uint256"], [minAmountOut, tradeTimeout]));
3837
- return infoHash;
3838
- }
3839
3795
  function getTradeIdsHash(tradeIds) {
3840
3796
  return (0, import_ethers7.keccak256)(abiCoder.encode(["bytes32[]"], [tradeIds]));
3841
3797
  }
@@ -3846,26 +3802,6 @@ function getMakePaymentHash(tradeIds, signedAt, startIdx, paymentTxId) {
3846
3802
  );
3847
3803
  return infoHash;
3848
3804
  }
3849
- function getBTCEVMConfirmPaymentHash(protocolFee, paymentAmount, toChain, paymentTxId) {
3850
- const paymentHash = (0, import_ethers7.keccak256)(
3851
- abiCoder.encode(["uint256", "uint256", "bytes[3]"], [protocolFee, paymentAmount, toChain])
3852
- );
3853
- const infoHash = (0, import_ethers7.keccak256)(abiCoder.encode(["bytes32", "bytes"], [paymentHash, paymentTxId]));
3854
- return infoHash;
3855
- }
3856
- function getEVMBTCConfirmPaymentHash(paymentAmount, toChain, paymentTxId) {
3857
- const paymentHash = (0, import_ethers7.keccak256)(abiCoder.encode(["uint256", "bytes[3]"], [paymentAmount, toChain]));
3858
- const infoHash = (0, import_ethers7.keccak256)(abiCoder.encode(["bytes32", "bytes"], [paymentHash, paymentTxId]));
3859
- return infoHash;
3860
- }
3861
- function getBTCEVMConfirmSettlementHash(releaseTxId) {
3862
- const infoHash = (0, import_ethers7.keccak256)(releaseTxId);
3863
- return infoHash;
3864
- }
3865
- function getEVMBTCConfirmSettlementHash(protocolFee, releaseTxId) {
3866
- const infoHash = (0, import_ethers7.keccak256)(abiCoder.encode(["uint256", "bytes"], [protocolFee, releaseTxId]));
3867
- return infoHash;
3868
- }
3869
3805
  function getCommitInfoHash(pmmId, pmmRecvAddr, toChain, toToken, amountOut, expiry) {
3870
3806
  const infoHash = (0, import_ethers7.keccak256)(
3871
3807
  abiCoder.encode(
@@ -3959,6 +3895,7 @@ async function getSignature(Signer2, provider, signerHelper, tradeId, infoHash,
3959
3895
  Payment__factory,
3960
3896
  RouterService,
3961
3897
  Router__factory,
3898
+ SDK,
3962
3899
  SignatureType,
3963
3900
  SignerService,
3964
3901
  Signer__factory,
@@ -3974,16 +3911,8 @@ async function getSignature(Signer2, provider, signerHelper, tradeId, infoHash,
3974
3911
  convertToSnakeCase,
3975
3912
  ensureHexPrefix,
3976
3913
  factories,
3977
- getBTCEVMConfirmPaymentHash,
3978
- getBTCEVMConfirmSettlementHash,
3979
3914
  getCommitInfoHash,
3980
- getDepositConfirmationHash,
3981
- getEVMBTCConfirmPaymentHash,
3982
- getEVMBTCConfirmSettlementHash,
3983
3915
  getMakePaymentHash,
3984
- getPresignHash,
3985
- getRFQHash,
3986
- getSelectPMMHash,
3987
3916
  getSignature,
3988
3917
  getSigner,
3989
3918
  getTradeIdsHash,
@@ -3992,6 +3921,7 @@ async function getSignature(Signer2, provider, signerHelper, tradeId, infoHash,
3992
3921
  removeHexPrefix,
3993
3922
  rfqAuthenticationTypes,
3994
3923
  routerService,
3924
+ sdk,
3995
3925
  selectionType,
3996
3926
  signerService,
3997
3927
  snakeToCamelCase,
package/dist/index.mjs CHANGED
@@ -7,7 +7,6 @@ var __export = (target, all) => {
7
7
  // src/config/config.ts
8
8
  var environments = {
9
9
  dev: {
10
- solverUrl: "https://pre-bitfi-solver.kyberengineering.io",
11
10
  backendUrl: "https://api-stg.bitdex.xyz",
12
11
  rpcUrl: "https://rpc-bitfi-p00c4t1rul.t.conduit.xyz",
13
12
  routerAddress: "0xc0B01A53B15bacAF6f81aF1F6B001E8c8130256e",
@@ -16,22 +15,35 @@ var environments = {
16
15
  }
17
16
  },
18
17
  production: {
19
- solverUrl: "https://bitfi-solver.kyberengineering.io",
20
18
  backendUrl: "https://api.petafi.xyz",
21
19
  rpcUrl: "https://bitfi-ledger-testnet.alt.technology",
22
- routerAddress: "0x07468dF194817257e73cA71E938C1ef977Be032F",
20
+ routerAddress: "0x272599CE3602A49B580A5C4a4d3C1067E30248D2",
23
21
  paymentAddressMap: {
24
- ethereum: "0x05d60d78ec4896c041268b68fcef2294b16123c3"
22
+ ethereum: "x0A497AC4261E37FA4062762C23Cf3cB642C839b8"
25
23
  }
26
24
  }
27
25
  };
28
26
  var Config = class {
29
27
  constructor() {
30
28
  this.env = process.env.SDK_ENV || "production";
31
- if (!environments[this.env]) {
32
- throw new Error(`Unsupported environment: ${this.env}`);
29
+ this.config = this.validateAndGetConfig(this.env);
30
+ }
31
+ /**
32
+ * Set the environment for the SDK
33
+ * @param env The environment to use ('dev' or 'production')
34
+ */
35
+ setEnvironment(env) {
36
+ if (!environments[env]) {
37
+ throw new Error(`Unsupported environment: ${env}`);
38
+ }
39
+ this.env = env;
40
+ this.config = environments[env];
41
+ }
42
+ validateAndGetConfig(env) {
43
+ if (!environments[env]) {
44
+ throw new Error(`Unsupported environment: ${env}`);
33
45
  }
34
- this.config = environments[this.env];
46
+ return environments[env];
35
47
  }
36
48
  get() {
37
49
  return {
@@ -39,9 +51,6 @@ var Config = class {
39
51
  ...this.config
40
52
  };
41
53
  }
42
- getSolverUrl() {
43
- return this.config.solverUrl;
44
- }
45
54
  getBackendUrl() {
46
55
  return this.config.backendUrl;
47
56
  }
@@ -57,6 +66,18 @@ var Config = class {
57
66
  };
58
67
  var config = new Config();
59
68
 
69
+ // src/config/sdk.ts
70
+ var SDK = class {
71
+ /**
72
+ * Initialize the SDK with a specific environment
73
+ * @param env The environment to use ('dev' or 'production')
74
+ */
75
+ setEnvironment(env) {
76
+ config.setEnvironment(env);
77
+ }
78
+ };
79
+ var sdk = new SDK();
80
+
60
81
  // src/contracts/contract/factories/index.ts
61
82
  var factories_exports = {};
62
83
  __export(factories_exports, {
@@ -3550,7 +3571,7 @@ var SubmitSettlementResponseSchema = z.object({
3550
3571
  });
3551
3572
  var SolverService = class {
3552
3573
  constructor() {
3553
- this.baseURL = config.getSolverUrl();
3574
+ this.baseURL = config.getBackendUrl();
3554
3575
  }
3555
3576
  /**
3556
3577
  * Submits a settlement transaction to the solver backend
@@ -3563,7 +3584,7 @@ var SolverService = class {
3563
3584
  SubmitSettlementRequestSchema.parse(params);
3564
3585
  const snakeCaseParams = convertToSnakeCase(params);
3565
3586
  const response = await axios.post(
3566
- `${this.baseURL}/submit-settlement-tx`,
3587
+ `${this.baseURL}/solver/submit-settlement-tx`,
3567
3588
  snakeCaseParams,
3568
3589
  {
3569
3590
  headers: {
@@ -3583,41 +3604,6 @@ var SolverService = class {
3583
3604
  throw error;
3584
3605
  }
3585
3606
  }
3586
- /**
3587
- * Helper function to format and submit a single trade settlement
3588
- * @param tradeId The ID of the trade to settle
3589
- * @param pmmId The PMM's identifier
3590
- * @param settlementTx The settlement transaction data
3591
- * @param signature The PMM's signature
3592
- */
3593
- async submitSingleSettlement(tradeId, pmmId, settlementTx, signature, signedAt) {
3594
- return this.submitSettlementTx({
3595
- tradeIds: [tradeId],
3596
- pmmId,
3597
- settlementTx,
3598
- signature,
3599
- startIndex: 0,
3600
- signedAt
3601
- });
3602
- }
3603
- /**
3604
- * Helper function to submit multiple trade settlements in one transaction
3605
- * @param tradeIds Array of trade IDs to settle
3606
- * @param pmmId The PMM's identifier
3607
- * @param settlementTx The settlement transaction data
3608
- * @param signature The PMM's signature
3609
- * @param startIndex Starting index for batch processing
3610
- */
3611
- async submitBatchSettlement(tradeIds, pmmId, settlementTx, signature, signedAt, startIndex = 0) {
3612
- return this.submitSettlementTx({
3613
- tradeIds,
3614
- pmmId,
3615
- settlementTx,
3616
- signature,
3617
- startIndex,
3618
- signedAt
3619
- });
3620
- }
3621
3607
  };
3622
3608
  var solverService = new SolverService();
3623
3609
 
@@ -3741,30 +3727,6 @@ async function defaultDomain(signerHelper, provider) {
3741
3727
  // src/signatures/getInfoHash.ts
3742
3728
  import { AbiCoder, keccak256 } from "ethers";
3743
3729
  var abiCoder = AbiCoder.defaultAbiCoder();
3744
- function getPresignHash(pmmRecvAddress, amountIn) {
3745
- const infoHash = keccak256(abiCoder.encode(["address", "uint256"], [pmmRecvAddress, amountIn]));
3746
- return infoHash;
3747
- }
3748
- function getDepositConfirmationHash(amountIn, fromChain, depositTxId, depositFromList) {
3749
- const depositHash = keccak256(
3750
- abiCoder.encode(["uint256", "bytes[3]", "bytes[]"], [amountIn, fromChain, depositFromList])
3751
- );
3752
- const infoHash = keccak256(abiCoder.encode(["bytes32", "bytes"], [depositHash, depositTxId]));
3753
- return infoHash;
3754
- }
3755
- function getSelectPMMHash(pmmId, pmmRecvAddress, toChain, toToken, amountOut, expiry) {
3756
- const infoHash = keccak256(
3757
- abiCoder.encode(
3758
- ["bytes32", "bytes", "bytes", "bytes", "uint256", "uint256"],
3759
- [pmmId, pmmRecvAddress, toChain, toToken, amountOut, expiry]
3760
- )
3761
- );
3762
- return infoHash;
3763
- }
3764
- function getRFQHash(minAmountOut, tradeTimeout) {
3765
- const infoHash = keccak256(abiCoder.encode(["uint256", "uint256"], [minAmountOut, tradeTimeout]));
3766
- return infoHash;
3767
- }
3768
3730
  function getTradeIdsHash(tradeIds) {
3769
3731
  return keccak256(abiCoder.encode(["bytes32[]"], [tradeIds]));
3770
3732
  }
@@ -3775,26 +3737,6 @@ function getMakePaymentHash(tradeIds, signedAt, startIdx, paymentTxId) {
3775
3737
  );
3776
3738
  return infoHash;
3777
3739
  }
3778
- function getBTCEVMConfirmPaymentHash(protocolFee, paymentAmount, toChain, paymentTxId) {
3779
- const paymentHash = keccak256(
3780
- abiCoder.encode(["uint256", "uint256", "bytes[3]"], [protocolFee, paymentAmount, toChain])
3781
- );
3782
- const infoHash = keccak256(abiCoder.encode(["bytes32", "bytes"], [paymentHash, paymentTxId]));
3783
- return infoHash;
3784
- }
3785
- function getEVMBTCConfirmPaymentHash(paymentAmount, toChain, paymentTxId) {
3786
- const paymentHash = keccak256(abiCoder.encode(["uint256", "bytes[3]"], [paymentAmount, toChain]));
3787
- const infoHash = keccak256(abiCoder.encode(["bytes32", "bytes"], [paymentHash, paymentTxId]));
3788
- return infoHash;
3789
- }
3790
- function getBTCEVMConfirmSettlementHash(releaseTxId) {
3791
- const infoHash = keccak256(releaseTxId);
3792
- return infoHash;
3793
- }
3794
- function getEVMBTCConfirmSettlementHash(protocolFee, releaseTxId) {
3795
- const infoHash = keccak256(abiCoder.encode(["uint256", "bytes"], [protocolFee, releaseTxId]));
3796
- return infoHash;
3797
- }
3798
3740
  function getCommitInfoHash(pmmId, pmmRecvAddr, toChain, toToken, amountOut, expiry) {
3799
3741
  const infoHash = keccak256(
3800
3742
  abiCoder.encode(
@@ -3887,6 +3829,7 @@ export {
3887
3829
  Payment__factory,
3888
3830
  RouterService,
3889
3831
  Router__factory,
3832
+ SDK,
3890
3833
  SignatureType,
3891
3834
  SignerService,
3892
3835
  Signer__factory,
@@ -3902,16 +3845,8 @@ export {
3902
3845
  convertToSnakeCase,
3903
3846
  ensureHexPrefix,
3904
3847
  factories_exports as factories,
3905
- getBTCEVMConfirmPaymentHash,
3906
- getBTCEVMConfirmSettlementHash,
3907
3848
  getCommitInfoHash,
3908
- getDepositConfirmationHash,
3909
- getEVMBTCConfirmPaymentHash,
3910
- getEVMBTCConfirmSettlementHash,
3911
3849
  getMakePaymentHash,
3912
- getPresignHash,
3913
- getRFQHash,
3914
- getSelectPMMHash,
3915
3850
  getSignature,
3916
3851
  getSigner,
3917
3852
  getTradeIdsHash,
@@ -3920,6 +3855,7 @@ export {
3920
3855
  removeHexPrefix,
3921
3856
  rfqAuthenticationTypes,
3922
3857
  routerService,
3858
+ sdk,
3923
3859
  selectionType,
3924
3860
  signerService,
3925
3861
  snakeToCamelCase,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimex-xyz/market-maker-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.4.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"