@pyxisjs/chains 0.2.2 → 0.2.3
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 +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +83 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +84 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -6741,12 +6741,14 @@ var CONTRACTS = {
|
|
|
6741
6741
|
cancel_withdrawal_request: "{address}::atomic_queue::cancel_atomic_request"
|
|
6742
6742
|
},
|
|
6743
6743
|
[ChainType.EVM]: {
|
|
6744
|
-
get_minimum_request_age: "
|
|
6745
|
-
|
|
6746
|
-
reclaim_withdrawal_request: "reclaimWithdrawalRequest",
|
|
6744
|
+
get_minimum_request_age: "minimumRequestAge",
|
|
6745
|
+
cancel_atomic_request: "cancelAtomicRequest",
|
|
6747
6746
|
update_atomic_request: "updateAtomicRequest",
|
|
6748
6747
|
get_request_updated_at: "getRequestUpdatedAt",
|
|
6749
|
-
get_user_atomic_requests: "getUserAtomicRequests"
|
|
6748
|
+
get_user_atomic_requests: "getUserAtomicRequests",
|
|
6749
|
+
get_all_atomic_requests: "getAtomicRequests",
|
|
6750
|
+
// Private functions
|
|
6751
|
+
view_solve_metadata: "viewSolveMetaData"
|
|
6750
6752
|
}
|
|
6751
6753
|
}
|
|
6752
6754
|
},
|
|
@@ -7433,6 +7435,7 @@ var AptosAnalyticsClient = class {
|
|
|
7433
7435
|
import {
|
|
7434
7436
|
BaseChainAdapter as BaseChainAdapter3,
|
|
7435
7437
|
ChainId,
|
|
7438
|
+
PyxisUtils as PyxisUtils3,
|
|
7436
7439
|
getChainConfig as getChainConfig3
|
|
7437
7440
|
} from "@pyxisjs/core";
|
|
7438
7441
|
import {
|
|
@@ -7441,6 +7444,7 @@ import {
|
|
|
7441
7444
|
http
|
|
7442
7445
|
} from "viem";
|
|
7443
7446
|
import { arbitrum, mainnet, sepolia } from "viem/chains";
|
|
7447
|
+
var import_dayjs2 = __toESM(require_dayjs_min());
|
|
7444
7448
|
var viemChainMap = {
|
|
7445
7449
|
[ChainId.ETHEREUM_MAINNET]: mainnet,
|
|
7446
7450
|
[ChainId.ETHEREUM_SEPOLIA]: sepolia,
|
|
@@ -7707,11 +7711,18 @@ var EthereumChainAdapter = class extends BaseChainAdapter3 {
|
|
|
7707
7711
|
to: this.getContractAddress("atomicQueue"),
|
|
7708
7712
|
function: functionSignature,
|
|
7709
7713
|
arguments: [
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7714
|
+
[
|
|
7715
|
+
args.user,
|
|
7716
|
+
args.offerAsset,
|
|
7717
|
+
args.wantAsset,
|
|
7718
|
+
Number(args.deadline),
|
|
7719
|
+
Number(args.price),
|
|
7720
|
+
Number(args.offerAmount),
|
|
7721
|
+
false,
|
|
7722
|
+
// inSolve: Default false
|
|
7723
|
+
(0, import_dayjs2.default)().unix()
|
|
7724
|
+
// UpdatedAt: current unix timestamp
|
|
7725
|
+
]
|
|
7715
7726
|
],
|
|
7716
7727
|
abi
|
|
7717
7728
|
});
|
|
@@ -7719,7 +7730,7 @@ var EthereumChainAdapter = class extends BaseChainAdapter3 {
|
|
|
7719
7730
|
async buildReclaimWithdrawalRequestTx(args) {
|
|
7720
7731
|
const functionSignature = this.getFunctionSignature(
|
|
7721
7732
|
"atomicQueue",
|
|
7722
|
-
"
|
|
7733
|
+
"cancel_atomic_request"
|
|
7723
7734
|
);
|
|
7724
7735
|
const abi = this.getContractABI("atomicQueue");
|
|
7725
7736
|
return await this.buildPayload({
|
|
@@ -7732,7 +7743,7 @@ var EthereumChainAdapter = class extends BaseChainAdapter3 {
|
|
|
7732
7743
|
async buildCancelWithdrawalRequestTx(args) {
|
|
7733
7744
|
const functionSignature = this.getFunctionSignature(
|
|
7734
7745
|
"atomicQueue",
|
|
7735
|
-
"
|
|
7746
|
+
"cancel_atomic_request"
|
|
7736
7747
|
);
|
|
7737
7748
|
const abi = this.getContractABI("atomicQueue");
|
|
7738
7749
|
return await this.buildPayload({
|
|
@@ -7742,7 +7753,7 @@ var EthereumChainAdapter = class extends BaseChainAdapter3 {
|
|
|
7742
7753
|
abi
|
|
7743
7754
|
});
|
|
7744
7755
|
}
|
|
7745
|
-
async getMinimumRequestAge(
|
|
7756
|
+
async getMinimumRequestAge(_args) {
|
|
7746
7757
|
const functionSignature = this.getFunctionSignature(
|
|
7747
7758
|
"atomicQueue",
|
|
7748
7759
|
"get_minimum_request_age"
|
|
@@ -7750,13 +7761,71 @@ var EthereumChainAdapter = class extends BaseChainAdapter3 {
|
|
|
7750
7761
|
const result = await this.viewContract({
|
|
7751
7762
|
address: this.getContractAddress("atomicQueue"),
|
|
7752
7763
|
function: functionSignature,
|
|
7753
|
-
arguments: [
|
|
7764
|
+
arguments: [],
|
|
7754
7765
|
abi: this.getContractABI("atomicQueue")
|
|
7755
7766
|
});
|
|
7756
7767
|
return Number(result);
|
|
7757
7768
|
}
|
|
7758
|
-
async getUserWithdrawalRequests(
|
|
7759
|
-
|
|
7769
|
+
async getUserWithdrawalRequests({
|
|
7770
|
+
userAddress,
|
|
7771
|
+
flag,
|
|
7772
|
+
matchAll
|
|
7773
|
+
}) {
|
|
7774
|
+
const requestFlag = PyxisUtils3.buildRequestFlags(flag);
|
|
7775
|
+
const getAllWithdrawalRequestFn = this.getFunctionSignature(
|
|
7776
|
+
"atomicQueue",
|
|
7777
|
+
"get_all_atomic_requests"
|
|
7778
|
+
);
|
|
7779
|
+
const withdrawalRequests = await this.viewContract({
|
|
7780
|
+
address: this.getContractAddress("atomicQueue"),
|
|
7781
|
+
function: getAllWithdrawalRequestFn,
|
|
7782
|
+
arguments: [0, Number.MAX_SAFE_INTEGER, requestFlag, matchAll],
|
|
7783
|
+
abi: this.getContractABI("atomicQueue")
|
|
7784
|
+
});
|
|
7785
|
+
const userRequests = withdrawalRequests.filter(
|
|
7786
|
+
(request) => request.user === userAddress
|
|
7787
|
+
);
|
|
7788
|
+
return Promise.all(
|
|
7789
|
+
userRequests.map((request) => this.mapEVMWithdrawalRequest(request))
|
|
7790
|
+
);
|
|
7791
|
+
}
|
|
7792
|
+
async mapEVMWithdrawalRequest(request) {
|
|
7793
|
+
const solveData = await this.viewSolveData({
|
|
7794
|
+
offerAsset: request.offerToken,
|
|
7795
|
+
wantAsset: request.wantToken,
|
|
7796
|
+
user: request.user
|
|
7797
|
+
});
|
|
7798
|
+
return {
|
|
7799
|
+
atomicPrice: request.atomicPrice,
|
|
7800
|
+
deadline: request.deadline,
|
|
7801
|
+
flags: PyxisUtils3.parseRequestFlags(solveData.flags),
|
|
7802
|
+
offerAmount: request.offerAmount,
|
|
7803
|
+
offerToken: request.offerToken,
|
|
7804
|
+
userAddress: request.user,
|
|
7805
|
+
wantToken: request.wantToken,
|
|
7806
|
+
wantAmount: String(solveData.assetsForWant),
|
|
7807
|
+
updatedAt: request.updatedAt
|
|
7808
|
+
};
|
|
7809
|
+
}
|
|
7810
|
+
async viewSolveData({
|
|
7811
|
+
offerAsset,
|
|
7812
|
+
wantAsset,
|
|
7813
|
+
user
|
|
7814
|
+
}) {
|
|
7815
|
+
const functionSignature = this.getFunctionSignature(
|
|
7816
|
+
"atomicQueue",
|
|
7817
|
+
"view_solve_metadata"
|
|
7818
|
+
);
|
|
7819
|
+
const [requestMetadata] = await this.viewContract({
|
|
7820
|
+
address: this.getContractAddress("atomicQueue"),
|
|
7821
|
+
function: functionSignature,
|
|
7822
|
+
arguments: [offerAsset, wantAsset, [user]],
|
|
7823
|
+
abi: this.getContractABI("atomicQueue")
|
|
7824
|
+
});
|
|
7825
|
+
if (!requestMetadata[0]) {
|
|
7826
|
+
throw new Error("Solve metadata not found");
|
|
7827
|
+
}
|
|
7828
|
+
return requestMetadata[0];
|
|
7760
7829
|
}
|
|
7761
7830
|
};
|
|
7762
7831
|
export {
|