@optimex-xyz/market-maker-sdk 0.1.0 → 0.2.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 +1 -28
- package/dist/index.d.ts +1 -28
- package/dist/index.js +4 -104
- package/dist/index.mjs +4 -96
- package/package.json +1 -1
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;
|
|
@@ -17,7 +16,6 @@ declare class Config {
|
|
|
17
16
|
private readonly config;
|
|
18
17
|
constructor();
|
|
19
18
|
get(): AppConfig;
|
|
20
|
-
getSolverUrl(): string;
|
|
21
19
|
getBackendUrl(): string;
|
|
22
20
|
getRpcUrl(): string;
|
|
23
21
|
getRouterAddress(): string;
|
|
@@ -4644,23 +4642,6 @@ declare class SolverService {
|
|
|
4644
4642
|
* @throws Error if the request fails or validation fails
|
|
4645
4643
|
*/
|
|
4646
4644
|
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
4645
|
}
|
|
4665
4646
|
declare const solverService: SolverService;
|
|
4666
4647
|
|
|
@@ -4735,16 +4716,8 @@ declare class TokenService {
|
|
|
4735
4716
|
}
|
|
4736
4717
|
declare const tokenService: TokenService;
|
|
4737
4718
|
|
|
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
4719
|
declare function getTradeIdsHash(tradeIds: BytesLike[]): string;
|
|
4743
4720
|
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
4721
|
declare function getCommitInfoHash(pmmId: BytesLike, pmmRecvAddr: BytesLike, toChain: BytesLike, toToken: BytesLike, amountOut: bigint, expiry: bigint): string;
|
|
4749
4722
|
|
|
4750
4723
|
declare enum SignatureType {
|
|
@@ -4810,4 +4783,4 @@ declare function camelToSnakeCase(str: string): string;
|
|
|
4810
4783
|
declare const ensureHexPrefix: (value: string) => string;
|
|
4811
4784
|
declare const removeHexPrefix: (value: string) => string;
|
|
4812
4785
|
|
|
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,
|
|
4786
|
+
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, getCommitInfoHash, getMakePaymentHash, getSignature, getSigner, getTradeIdsHash, makePaymentType, presignType, removeHexPrefix, rfqAuthenticationTypes, routerService, 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;
|
|
@@ -17,7 +16,6 @@ declare class Config {
|
|
|
17
16
|
private readonly config;
|
|
18
17
|
constructor();
|
|
19
18
|
get(): AppConfig;
|
|
20
|
-
getSolverUrl(): string;
|
|
21
19
|
getBackendUrl(): string;
|
|
22
20
|
getRpcUrl(): string;
|
|
23
21
|
getRouterAddress(): string;
|
|
@@ -4644,23 +4642,6 @@ declare class SolverService {
|
|
|
4644
4642
|
* @throws Error if the request fails or validation fails
|
|
4645
4643
|
*/
|
|
4646
4644
|
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
4645
|
}
|
|
4665
4646
|
declare const solverService: SolverService;
|
|
4666
4647
|
|
|
@@ -4735,16 +4716,8 @@ declare class TokenService {
|
|
|
4735
4716
|
}
|
|
4736
4717
|
declare const tokenService: TokenService;
|
|
4737
4718
|
|
|
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
4719
|
declare function getTradeIdsHash(tradeIds: BytesLike[]): string;
|
|
4743
4720
|
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
4721
|
declare function getCommitInfoHash(pmmId: BytesLike, pmmRecvAddr: BytesLike, toChain: BytesLike, toToken: BytesLike, amountOut: bigint, expiry: bigint): string;
|
|
4749
4722
|
|
|
4750
4723
|
declare enum SignatureType {
|
|
@@ -4810,4 +4783,4 @@ declare function camelToSnakeCase(str: string): string;
|
|
|
4810
4783
|
declare const ensureHexPrefix: (value: string) => string;
|
|
4811
4784
|
declare const removeHexPrefix: (value: string) => string;
|
|
4812
4785
|
|
|
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,
|
|
4786
|
+
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, getCommitInfoHash, getMakePaymentHash, getSignature, getSigner, getTradeIdsHash, makePaymentType, presignType, removeHexPrefix, rfqAuthenticationTypes, routerService, selectionType, signerService, snakeToCamelCase, solverService, tokenService };
|
package/dist/index.js
CHANGED
|
@@ -49,16 +49,8 @@ __export(index_exports, {
|
|
|
49
49
|
convertToSnakeCase: () => convertToSnakeCase,
|
|
50
50
|
ensureHexPrefix: () => ensureHexPrefix,
|
|
51
51
|
factories: () => factories_exports,
|
|
52
|
-
getBTCEVMConfirmPaymentHash: () => getBTCEVMConfirmPaymentHash,
|
|
53
|
-
getBTCEVMConfirmSettlementHash: () => getBTCEVMConfirmSettlementHash,
|
|
54
52
|
getCommitInfoHash: () => getCommitInfoHash,
|
|
55
|
-
getDepositConfirmationHash: () => getDepositConfirmationHash,
|
|
56
|
-
getEVMBTCConfirmPaymentHash: () => getEVMBTCConfirmPaymentHash,
|
|
57
|
-
getEVMBTCConfirmSettlementHash: () => getEVMBTCConfirmSettlementHash,
|
|
58
53
|
getMakePaymentHash: () => getMakePaymentHash,
|
|
59
|
-
getPresignHash: () => getPresignHash,
|
|
60
|
-
getRFQHash: () => getRFQHash,
|
|
61
|
-
getSelectPMMHash: () => getSelectPMMHash,
|
|
62
54
|
getSignature: () => getSignature,
|
|
63
55
|
getSigner: () => getSigner,
|
|
64
56
|
getTradeIdsHash: () => getTradeIdsHash,
|
|
@@ -78,7 +70,6 @@ module.exports = __toCommonJS(index_exports);
|
|
|
78
70
|
// src/config/config.ts
|
|
79
71
|
var environments = {
|
|
80
72
|
dev: {
|
|
81
|
-
solverUrl: "https://pre-bitfi-solver.kyberengineering.io",
|
|
82
73
|
backendUrl: "https://api-stg.bitdex.xyz",
|
|
83
74
|
rpcUrl: "https://rpc-bitfi-p00c4t1rul.t.conduit.xyz",
|
|
84
75
|
routerAddress: "0xc0B01A53B15bacAF6f81aF1F6B001E8c8130256e",
|
|
@@ -87,12 +78,11 @@ var environments = {
|
|
|
87
78
|
}
|
|
88
79
|
},
|
|
89
80
|
production: {
|
|
90
|
-
solverUrl: "https://bitfi-solver.kyberengineering.io",
|
|
91
81
|
backendUrl: "https://api.petafi.xyz",
|
|
92
82
|
rpcUrl: "https://bitfi-ledger-testnet.alt.technology",
|
|
93
|
-
routerAddress: "
|
|
83
|
+
routerAddress: "0x272599CE3602A49B580A5C4a4d3C1067E30248D2",
|
|
94
84
|
paymentAddressMap: {
|
|
95
|
-
ethereum: "
|
|
85
|
+
ethereum: "x0A497AC4261E37FA4062762C23Cf3cB642C839b8"
|
|
96
86
|
}
|
|
97
87
|
}
|
|
98
88
|
};
|
|
@@ -110,9 +100,6 @@ var Config = class {
|
|
|
110
100
|
...this.config
|
|
111
101
|
};
|
|
112
102
|
}
|
|
113
|
-
getSolverUrl() {
|
|
114
|
-
return this.config.solverUrl;
|
|
115
|
-
}
|
|
116
103
|
getBackendUrl() {
|
|
117
104
|
return this.config.backendUrl;
|
|
118
105
|
}
|
|
@@ -3621,7 +3608,7 @@ var SubmitSettlementResponseSchema = import_zod.z.object({
|
|
|
3621
3608
|
});
|
|
3622
3609
|
var SolverService = class {
|
|
3623
3610
|
constructor() {
|
|
3624
|
-
this.baseURL = config.
|
|
3611
|
+
this.baseURL = config.getBackendUrl();
|
|
3625
3612
|
}
|
|
3626
3613
|
/**
|
|
3627
3614
|
* Submits a settlement transaction to the solver backend
|
|
@@ -3634,7 +3621,7 @@ var SolverService = class {
|
|
|
3634
3621
|
SubmitSettlementRequestSchema.parse(params);
|
|
3635
3622
|
const snakeCaseParams = convertToSnakeCase(params);
|
|
3636
3623
|
const response = await import_axios.default.post(
|
|
3637
|
-
`${this.baseURL}/submit-settlement-tx`,
|
|
3624
|
+
`${this.baseURL}/solver/submit-settlement-tx`,
|
|
3638
3625
|
snakeCaseParams,
|
|
3639
3626
|
{
|
|
3640
3627
|
headers: {
|
|
@@ -3654,41 +3641,6 @@ var SolverService = class {
|
|
|
3654
3641
|
throw error;
|
|
3655
3642
|
}
|
|
3656
3643
|
}
|
|
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
3644
|
};
|
|
3693
3645
|
var solverService = new SolverService();
|
|
3694
3646
|
|
|
@@ -3812,30 +3764,6 @@ async function defaultDomain(signerHelper, provider) {
|
|
|
3812
3764
|
// src/signatures/getInfoHash.ts
|
|
3813
3765
|
var import_ethers7 = require("ethers");
|
|
3814
3766
|
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
3767
|
function getTradeIdsHash(tradeIds) {
|
|
3840
3768
|
return (0, import_ethers7.keccak256)(abiCoder.encode(["bytes32[]"], [tradeIds]));
|
|
3841
3769
|
}
|
|
@@ -3846,26 +3774,6 @@ function getMakePaymentHash(tradeIds, signedAt, startIdx, paymentTxId) {
|
|
|
3846
3774
|
);
|
|
3847
3775
|
return infoHash;
|
|
3848
3776
|
}
|
|
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
3777
|
function getCommitInfoHash(pmmId, pmmRecvAddr, toChain, toToken, amountOut, expiry) {
|
|
3870
3778
|
const infoHash = (0, import_ethers7.keccak256)(
|
|
3871
3779
|
abiCoder.encode(
|
|
@@ -3974,16 +3882,8 @@ async function getSignature(Signer2, provider, signerHelper, tradeId, infoHash,
|
|
|
3974
3882
|
convertToSnakeCase,
|
|
3975
3883
|
ensureHexPrefix,
|
|
3976
3884
|
factories,
|
|
3977
|
-
getBTCEVMConfirmPaymentHash,
|
|
3978
|
-
getBTCEVMConfirmSettlementHash,
|
|
3979
3885
|
getCommitInfoHash,
|
|
3980
|
-
getDepositConfirmationHash,
|
|
3981
|
-
getEVMBTCConfirmPaymentHash,
|
|
3982
|
-
getEVMBTCConfirmSettlementHash,
|
|
3983
3886
|
getMakePaymentHash,
|
|
3984
|
-
getPresignHash,
|
|
3985
|
-
getRFQHash,
|
|
3986
|
-
getSelectPMMHash,
|
|
3987
3887
|
getSignature,
|
|
3988
3888
|
getSigner,
|
|
3989
3889
|
getTradeIdsHash,
|
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,12 +15,11 @@ 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: "
|
|
20
|
+
routerAddress: "0x272599CE3602A49B580A5C4a4d3C1067E30248D2",
|
|
23
21
|
paymentAddressMap: {
|
|
24
|
-
ethereum: "
|
|
22
|
+
ethereum: "x0A497AC4261E37FA4062762C23Cf3cB642C839b8"
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
};
|
|
@@ -39,9 +37,6 @@ var Config = class {
|
|
|
39
37
|
...this.config
|
|
40
38
|
};
|
|
41
39
|
}
|
|
42
|
-
getSolverUrl() {
|
|
43
|
-
return this.config.solverUrl;
|
|
44
|
-
}
|
|
45
40
|
getBackendUrl() {
|
|
46
41
|
return this.config.backendUrl;
|
|
47
42
|
}
|
|
@@ -3550,7 +3545,7 @@ var SubmitSettlementResponseSchema = z.object({
|
|
|
3550
3545
|
});
|
|
3551
3546
|
var SolverService = class {
|
|
3552
3547
|
constructor() {
|
|
3553
|
-
this.baseURL = config.
|
|
3548
|
+
this.baseURL = config.getBackendUrl();
|
|
3554
3549
|
}
|
|
3555
3550
|
/**
|
|
3556
3551
|
* Submits a settlement transaction to the solver backend
|
|
@@ -3563,7 +3558,7 @@ var SolverService = class {
|
|
|
3563
3558
|
SubmitSettlementRequestSchema.parse(params);
|
|
3564
3559
|
const snakeCaseParams = convertToSnakeCase(params);
|
|
3565
3560
|
const response = await axios.post(
|
|
3566
|
-
`${this.baseURL}/submit-settlement-tx`,
|
|
3561
|
+
`${this.baseURL}/solver/submit-settlement-tx`,
|
|
3567
3562
|
snakeCaseParams,
|
|
3568
3563
|
{
|
|
3569
3564
|
headers: {
|
|
@@ -3583,41 +3578,6 @@ var SolverService = class {
|
|
|
3583
3578
|
throw error;
|
|
3584
3579
|
}
|
|
3585
3580
|
}
|
|
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
3581
|
};
|
|
3622
3582
|
var solverService = new SolverService();
|
|
3623
3583
|
|
|
@@ -3741,30 +3701,6 @@ async function defaultDomain(signerHelper, provider) {
|
|
|
3741
3701
|
// src/signatures/getInfoHash.ts
|
|
3742
3702
|
import { AbiCoder, keccak256 } from "ethers";
|
|
3743
3703
|
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
3704
|
function getTradeIdsHash(tradeIds) {
|
|
3769
3705
|
return keccak256(abiCoder.encode(["bytes32[]"], [tradeIds]));
|
|
3770
3706
|
}
|
|
@@ -3775,26 +3711,6 @@ function getMakePaymentHash(tradeIds, signedAt, startIdx, paymentTxId) {
|
|
|
3775
3711
|
);
|
|
3776
3712
|
return infoHash;
|
|
3777
3713
|
}
|
|
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
3714
|
function getCommitInfoHash(pmmId, pmmRecvAddr, toChain, toToken, amountOut, expiry) {
|
|
3799
3715
|
const infoHash = keccak256(
|
|
3800
3716
|
abiCoder.encode(
|
|
@@ -3902,16 +3818,8 @@ export {
|
|
|
3902
3818
|
convertToSnakeCase,
|
|
3903
3819
|
ensureHexPrefix,
|
|
3904
3820
|
factories_exports as factories,
|
|
3905
|
-
getBTCEVMConfirmPaymentHash,
|
|
3906
|
-
getBTCEVMConfirmSettlementHash,
|
|
3907
3821
|
getCommitInfoHash,
|
|
3908
|
-
getDepositConfirmationHash,
|
|
3909
|
-
getEVMBTCConfirmPaymentHash,
|
|
3910
|
-
getEVMBTCConfirmSettlementHash,
|
|
3911
3822
|
getMakePaymentHash,
|
|
3912
|
-
getPresignHash,
|
|
3913
|
-
getRFQHash,
|
|
3914
|
-
getSelectPMMHash,
|
|
3915
3823
|
getSignature,
|
|
3916
3824
|
getSigner,
|
|
3917
3825
|
getTradeIdsHash,
|