@pyxisjs/core 0.2.2 → 0.2.4
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 +64 -3
- package/dist/index.d.ts +64 -3
- package/dist/index.js +87 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -387,6 +387,21 @@ var require_utc = __commonJS({
|
|
|
387
387
|
}
|
|
388
388
|
});
|
|
389
389
|
|
|
390
|
+
// ../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
391
|
+
var isProduction = process.env.NODE_ENV === "production";
|
|
392
|
+
var prefix = "Invariant failed";
|
|
393
|
+
function invariant(condition, message) {
|
|
394
|
+
if (condition) {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if (isProduction) {
|
|
398
|
+
throw new Error(prefix);
|
|
399
|
+
}
|
|
400
|
+
var provided = typeof message === "function" ? message() : message;
|
|
401
|
+
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
402
|
+
throw new Error(value);
|
|
403
|
+
}
|
|
404
|
+
|
|
390
405
|
// src/types/chain.ts
|
|
391
406
|
var NetworkType = /* @__PURE__ */ ((NetworkType2) => {
|
|
392
407
|
NetworkType2["MAINNET"] = "mainnet";
|
|
@@ -451,11 +466,43 @@ var CHAIN_CONFIGS = {
|
|
|
451
466
|
isTestnet: false
|
|
452
467
|
}
|
|
453
468
|
};
|
|
469
|
+
var LAYERZERO_ENDPOINT_IDS = {
|
|
470
|
+
["aptos_mainnet" /* APTOS_MAINNET */]: 30108,
|
|
471
|
+
["aptos_testnet" /* APTOS_TESTNET */]: 30103,
|
|
472
|
+
["ethereum_mainnet" /* ETHEREUM_MAINNET */]: 30101,
|
|
473
|
+
["ethereum_sepolia" /* ETHEREUM_SEPOLIA */]: 30111,
|
|
474
|
+
["arbitrum_one" /* ARBITRUM_ONE */]: 30110
|
|
475
|
+
};
|
|
476
|
+
function getLayerZeroEndpointId(chainId) {
|
|
477
|
+
const eid = LAYERZERO_ENDPOINT_IDS[chainId];
|
|
478
|
+
invariant(eid, `LayerZero endpoint ID not found for chain: ${chainId}`);
|
|
479
|
+
return eid;
|
|
480
|
+
}
|
|
481
|
+
var ESTIMATED_BRIDGE_TIME = {
|
|
482
|
+
[`${"aptos_mainnet" /* APTOS_MAINNET */}-${"arbitrum_one" /* ARBITRUM_ONE */}`]: 30,
|
|
483
|
+
[`${"arbitrum_one" /* ARBITRUM_ONE */}-${"aptos_mainnet" /* APTOS_MAINNET */}`]: 30,
|
|
484
|
+
[`${"aptos_mainnet" /* APTOS_MAINNET */}-${"ethereum_mainnet" /* ETHEREUM_MAINNET */}`]: 60,
|
|
485
|
+
[`${"ethereum_mainnet" /* ETHEREUM_MAINNET */}-${"aptos_mainnet" /* APTOS_MAINNET */}`]: 60
|
|
486
|
+
};
|
|
487
|
+
function getEstimatedBridgeTime(srcChainId, dstChainId) {
|
|
488
|
+
const time = ESTIMATED_BRIDGE_TIME[`${srcChainId}-${dstChainId}`];
|
|
489
|
+
return time ? time.toString() : "-";
|
|
490
|
+
}
|
|
491
|
+
var LAYERZERO_MESSAGE_GAS_LIMITS = {
|
|
492
|
+
[`${"aptos_mainnet" /* APTOS_MAINNET */}-${"arbitrum_one" /* ARBITRUM_ONE */}`]: 50000n,
|
|
493
|
+
[`${"aptos_mainnet" /* APTOS_MAINNET */}-${"ethereum_mainnet" /* ETHEREUM_MAINNET */}`]: 80000n,
|
|
494
|
+
[`${"arbitrum_one" /* ARBITRUM_ONE */}-${"aptos_mainnet" /* APTOS_MAINNET */}`]: 100000n,
|
|
495
|
+
[`${"ethereum_mainnet" /* ETHEREUM_MAINNET */}-${"aptos_mainnet" /* APTOS_MAINNET */}`]: 100000n
|
|
496
|
+
};
|
|
497
|
+
function getLayerZeroGasLimit(srcChainId, dstChainId) {
|
|
498
|
+
return LAYERZERO_MESSAGE_GAS_LIMITS[`${srcChainId}-${dstChainId}`] || 0n;
|
|
499
|
+
}
|
|
500
|
+
var BridgeMethod = {
|
|
501
|
+
LayerZero: "LayerZero"
|
|
502
|
+
};
|
|
454
503
|
function getChainConfig(chainId) {
|
|
455
504
|
const config2 = CHAIN_CONFIGS[chainId];
|
|
456
|
-
|
|
457
|
-
throw new Error(`Chain config not found for chainId: ${chainId}`);
|
|
458
|
-
}
|
|
505
|
+
invariant(config2, `Chain config not found for chainId: ${chainId}`);
|
|
459
506
|
return config2;
|
|
460
507
|
}
|
|
461
508
|
|
|
@@ -636,9 +683,29 @@ var BaseChainAdapter = class {
|
|
|
636
683
|
}
|
|
637
684
|
/**
|
|
638
685
|
* Get a specific contract address
|
|
686
|
+
* @throws Error if the contract address is not configured
|
|
639
687
|
*/
|
|
640
688
|
getContractAddress(contract) {
|
|
641
|
-
|
|
689
|
+
const addresses = this.getContractAddresses();
|
|
690
|
+
const address = addresses[contract];
|
|
691
|
+
invariant(
|
|
692
|
+
address,
|
|
693
|
+
`Contract address for '${contract}' is not configured for chain ${this.chain.id}`
|
|
694
|
+
);
|
|
695
|
+
return address;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Get the multi-chain LayerZero teller address for cross-chain bridging
|
|
699
|
+
* @throws Error if multiChainLzTeller is not configured
|
|
700
|
+
*/
|
|
701
|
+
getMultichainLzTellerAddress() {
|
|
702
|
+
const addresses = this.getContractAddresses();
|
|
703
|
+
const address = addresses.multiChainLzTeller;
|
|
704
|
+
invariant(
|
|
705
|
+
address,
|
|
706
|
+
`Multi-chain LayerZero teller address is not configured for chain ${this.chain.id}`
|
|
707
|
+
);
|
|
708
|
+
return address;
|
|
642
709
|
}
|
|
643
710
|
/**
|
|
644
711
|
* Get the chain type
|
|
@@ -669,21 +736,6 @@ __export(utils_exports, {
|
|
|
669
736
|
sampleEventsByDay: () => sampleEventsByDay
|
|
670
737
|
});
|
|
671
738
|
|
|
672
|
-
// ../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
673
|
-
var isProduction = process.env.NODE_ENV === "production";
|
|
674
|
-
var prefix = "Invariant failed";
|
|
675
|
-
function invariant(condition, message) {
|
|
676
|
-
if (condition) {
|
|
677
|
-
return;
|
|
678
|
-
}
|
|
679
|
-
if (isProduction) {
|
|
680
|
-
throw new Error(prefix);
|
|
681
|
-
}
|
|
682
|
-
var provided = typeof message === "function" ? message() : message;
|
|
683
|
-
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
684
|
-
throw new Error(value);
|
|
685
|
-
}
|
|
686
|
-
|
|
687
739
|
// src/utils/number.ts
|
|
688
740
|
var BIP_BASE = 10000n;
|
|
689
741
|
var amountWithSlippage = (rawAmount, slippageBips) => {
|
|
@@ -2975,10 +3027,10 @@ function mapOnchainToWithdrawalRequest(onchainRequest, updatedAt) {
|
|
|
2975
3027
|
deadline: onchainRequest.deadline,
|
|
2976
3028
|
flags: parseRequestFlags(onchainRequest.flags?.flag ?? 0),
|
|
2977
3029
|
offerAmount: onchainRequest.offer_amount,
|
|
2978
|
-
offerToken: onchainRequest.offer_token,
|
|
3030
|
+
offerToken: onchainRequest.offer_token.inner,
|
|
2979
3031
|
userAddress: onchainRequest.user_address,
|
|
2980
3032
|
wantAmount: onchainRequest.want_amount,
|
|
2981
|
-
wantToken: onchainRequest.want_token,
|
|
3033
|
+
wantToken: onchainRequest.want_token.inner,
|
|
2982
3034
|
updatedAt: updatedAt ?? ""
|
|
2983
3035
|
};
|
|
2984
3036
|
}
|
|
@@ -3070,13 +3122,16 @@ var sampleEventsByDay = (events, strategy = "start" /* START */) => {
|
|
|
3070
3122
|
};
|
|
3071
3123
|
export {
|
|
3072
3124
|
BaseChainAdapter,
|
|
3125
|
+
BridgeMethod,
|
|
3073
3126
|
CHAIN_CONFIGS,
|
|
3074
3127
|
ChainId,
|
|
3075
3128
|
ChainType,
|
|
3076
3129
|
ConfigError,
|
|
3077
3130
|
ContractError,
|
|
3131
|
+
ESTIMATED_BRIDGE_TIME,
|
|
3078
3132
|
ErrorCodes,
|
|
3079
3133
|
InsufficientFundsError,
|
|
3134
|
+
LAYERZERO_ENDPOINT_IDS,
|
|
3080
3135
|
NetworkError,
|
|
3081
3136
|
NetworkType,
|
|
3082
3137
|
PyxisError,
|
|
@@ -3088,7 +3143,10 @@ export {
|
|
|
3088
3143
|
VaultError,
|
|
3089
3144
|
WalletError,
|
|
3090
3145
|
createError,
|
|
3091
|
-
getChainConfig
|
|
3146
|
+
getChainConfig,
|
|
3147
|
+
getEstimatedBridgeTime,
|
|
3148
|
+
getLayerZeroEndpointId,
|
|
3149
|
+
getLayerZeroGasLimit
|
|
3092
3150
|
};
|
|
3093
3151
|
/*! Bundled license information:
|
|
3094
3152
|
|