@sodax/sdk 2.0.0-rc.17 → 2.0.0-rc.18
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.cjs +1744 -875
- package/dist/index.d.cts +262 -9
- package/dist/index.d.ts +262 -9
- package/dist/index.mjs +1743 -876
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -4246,7 +4246,7 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
|
|
|
4246
4246
|
}
|
|
4247
4247
|
|
|
4248
4248
|
// ../types/dist/index.js
|
|
4249
|
-
var CONFIG_VERSION =
|
|
4249
|
+
var CONFIG_VERSION = 216;
|
|
4250
4250
|
function isEvmSpokeChainConfig(value) {
|
|
4251
4251
|
return typeof value === "object" && value !== null && value.chain.type === "EVM" && value.chain.key !== HUB_CHAIN_KEY;
|
|
4252
4252
|
}
|
|
@@ -10649,6 +10649,144 @@ var ProtocolIntentsAbi = [
|
|
|
10649
10649
|
}
|
|
10650
10650
|
],
|
|
10651
10651
|
stateMutability: "view"
|
|
10652
|
+
},
|
|
10653
|
+
{
|
|
10654
|
+
type: "function",
|
|
10655
|
+
name: "cancelIntent",
|
|
10656
|
+
inputs: [
|
|
10657
|
+
{
|
|
10658
|
+
name: "fromToken",
|
|
10659
|
+
type: "address",
|
|
10660
|
+
internalType: "address"
|
|
10661
|
+
},
|
|
10662
|
+
{
|
|
10663
|
+
name: "toToken",
|
|
10664
|
+
type: "address",
|
|
10665
|
+
internalType: "address"
|
|
10666
|
+
}
|
|
10667
|
+
],
|
|
10668
|
+
outputs: [],
|
|
10669
|
+
stateMutability: "nonpayable"
|
|
10670
|
+
},
|
|
10671
|
+
{
|
|
10672
|
+
type: "function",
|
|
10673
|
+
name: "getUserIntent",
|
|
10674
|
+
inputs: [
|
|
10675
|
+
{
|
|
10676
|
+
name: "user",
|
|
10677
|
+
type: "address",
|
|
10678
|
+
internalType: "address"
|
|
10679
|
+
},
|
|
10680
|
+
{
|
|
10681
|
+
name: "fromToken",
|
|
10682
|
+
type: "address",
|
|
10683
|
+
internalType: "address"
|
|
10684
|
+
},
|
|
10685
|
+
{
|
|
10686
|
+
name: "toToken",
|
|
10687
|
+
type: "address",
|
|
10688
|
+
internalType: "address"
|
|
10689
|
+
}
|
|
10690
|
+
],
|
|
10691
|
+
outputs: [
|
|
10692
|
+
{
|
|
10693
|
+
name: "intentHash",
|
|
10694
|
+
type: "bytes32",
|
|
10695
|
+
internalType: "bytes32"
|
|
10696
|
+
}
|
|
10697
|
+
],
|
|
10698
|
+
stateMutability: "view"
|
|
10699
|
+
},
|
|
10700
|
+
{
|
|
10701
|
+
type: "function",
|
|
10702
|
+
name: "getIntentDetails",
|
|
10703
|
+
inputs: [
|
|
10704
|
+
{
|
|
10705
|
+
name: "intentHash",
|
|
10706
|
+
type: "bytes32",
|
|
10707
|
+
internalType: "bytes32"
|
|
10708
|
+
}
|
|
10709
|
+
],
|
|
10710
|
+
outputs: [
|
|
10711
|
+
{
|
|
10712
|
+
name: "intent",
|
|
10713
|
+
type: "tuple",
|
|
10714
|
+
internalType: "struct Intents.Intent",
|
|
10715
|
+
components: [
|
|
10716
|
+
{
|
|
10717
|
+
name: "intentId",
|
|
10718
|
+
type: "uint256",
|
|
10719
|
+
internalType: "uint256"
|
|
10720
|
+
},
|
|
10721
|
+
{
|
|
10722
|
+
name: "creator",
|
|
10723
|
+
type: "address",
|
|
10724
|
+
internalType: "address"
|
|
10725
|
+
},
|
|
10726
|
+
{
|
|
10727
|
+
name: "inputToken",
|
|
10728
|
+
type: "address",
|
|
10729
|
+
internalType: "address"
|
|
10730
|
+
},
|
|
10731
|
+
{
|
|
10732
|
+
name: "outputToken",
|
|
10733
|
+
type: "address",
|
|
10734
|
+
internalType: "address"
|
|
10735
|
+
},
|
|
10736
|
+
{
|
|
10737
|
+
name: "inputAmount",
|
|
10738
|
+
type: "uint256",
|
|
10739
|
+
internalType: "uint256"
|
|
10740
|
+
},
|
|
10741
|
+
{
|
|
10742
|
+
name: "minOutputAmount",
|
|
10743
|
+
type: "uint256",
|
|
10744
|
+
internalType: "uint256"
|
|
10745
|
+
},
|
|
10746
|
+
{
|
|
10747
|
+
name: "deadline",
|
|
10748
|
+
type: "uint256",
|
|
10749
|
+
internalType: "uint256"
|
|
10750
|
+
},
|
|
10751
|
+
{
|
|
10752
|
+
name: "allowPartialFill",
|
|
10753
|
+
type: "bool",
|
|
10754
|
+
internalType: "bool"
|
|
10755
|
+
},
|
|
10756
|
+
{
|
|
10757
|
+
name: "srcChain",
|
|
10758
|
+
type: "uint256",
|
|
10759
|
+
internalType: "uint256"
|
|
10760
|
+
},
|
|
10761
|
+
{
|
|
10762
|
+
name: "dstChain",
|
|
10763
|
+
type: "uint256",
|
|
10764
|
+
internalType: "uint256"
|
|
10765
|
+
},
|
|
10766
|
+
{
|
|
10767
|
+
name: "srcAddress",
|
|
10768
|
+
type: "bytes",
|
|
10769
|
+
internalType: "bytes"
|
|
10770
|
+
},
|
|
10771
|
+
{
|
|
10772
|
+
name: "dstAddress",
|
|
10773
|
+
type: "bytes",
|
|
10774
|
+
internalType: "bytes"
|
|
10775
|
+
},
|
|
10776
|
+
{
|
|
10777
|
+
name: "solver",
|
|
10778
|
+
type: "address",
|
|
10779
|
+
internalType: "address"
|
|
10780
|
+
},
|
|
10781
|
+
{
|
|
10782
|
+
name: "data",
|
|
10783
|
+
type: "bytes",
|
|
10784
|
+
internalType: "bytes"
|
|
10785
|
+
}
|
|
10786
|
+
]
|
|
10787
|
+
}
|
|
10788
|
+
],
|
|
10789
|
+
stateMutability: "view"
|
|
10652
10790
|
}
|
|
10653
10791
|
];
|
|
10654
10792
|
|
|
@@ -13556,6 +13694,68 @@ function resolveLogger(option) {
|
|
|
13556
13694
|
return option;
|
|
13557
13695
|
}
|
|
13558
13696
|
|
|
13697
|
+
// src/shared/analytics.ts
|
|
13698
|
+
var noopAnalytics = {
|
|
13699
|
+
isEnabled: () => false,
|
|
13700
|
+
emit: () => {
|
|
13701
|
+
},
|
|
13702
|
+
trackResult: (_feature, _action, run) => run()
|
|
13703
|
+
};
|
|
13704
|
+
var LEVEL_RANK = { basic: 0, detailed: 1 };
|
|
13705
|
+
function normalizeFeatures(features) {
|
|
13706
|
+
if (features === void 0) return null;
|
|
13707
|
+
const map = /* @__PURE__ */ new Map();
|
|
13708
|
+
if (Array.isArray(features)) {
|
|
13709
|
+
for (const feature of features) map.set(feature, true);
|
|
13710
|
+
} else {
|
|
13711
|
+
for (const [feature, scope] of Object.entries(features)) {
|
|
13712
|
+
if (scope === true) map.set(feature, true);
|
|
13713
|
+
else if (scope) map.set(feature, new Set(scope.actions));
|
|
13714
|
+
}
|
|
13715
|
+
}
|
|
13716
|
+
return map;
|
|
13717
|
+
}
|
|
13718
|
+
function resolveAnalytics(option) {
|
|
13719
|
+
if (!option) return noopAnalytics;
|
|
13720
|
+
const { tracker, level: configuredLevel = "basic", features } = option;
|
|
13721
|
+
const maxRank = LEVEL_RANK[configuredLevel];
|
|
13722
|
+
const allow = normalizeFeatures(features);
|
|
13723
|
+
const isEnabled = (feature, action, level = "basic") => {
|
|
13724
|
+
if (LEVEL_RANK[level] > maxRank) return false;
|
|
13725
|
+
if (allow === null) return true;
|
|
13726
|
+
const scope = allow.get(feature);
|
|
13727
|
+
if (scope === void 0) return false;
|
|
13728
|
+
if (scope === true) return true;
|
|
13729
|
+
if (action === void 0) return scope.size > 0;
|
|
13730
|
+
return scope.has(action);
|
|
13731
|
+
};
|
|
13732
|
+
const emit = (feature, action, phase, build, level = "basic") => {
|
|
13733
|
+
if (!isEnabled(feature, action, level)) return;
|
|
13734
|
+
try {
|
|
13735
|
+
tracker({ feature, action, phase, level, data: build?.() });
|
|
13736
|
+
} catch {
|
|
13737
|
+
}
|
|
13738
|
+
};
|
|
13739
|
+
const trackResult = async (feature, action, run, data) => {
|
|
13740
|
+
emit(feature, action, "start", data?.start);
|
|
13741
|
+
try {
|
|
13742
|
+
const result = await run();
|
|
13743
|
+
if (result.ok) {
|
|
13744
|
+
const build = data?.success;
|
|
13745
|
+
emit(feature, action, "success", build ? () => build(result.value) : void 0);
|
|
13746
|
+
} else {
|
|
13747
|
+
const build = data?.failure;
|
|
13748
|
+
emit(feature, action, "failure", build ? () => build(result.error) : void 0);
|
|
13749
|
+
}
|
|
13750
|
+
return result;
|
|
13751
|
+
} catch (error) {
|
|
13752
|
+
emit(feature, action, "failure", () => ({ error: error instanceof Error ? error.message : String(error) }));
|
|
13753
|
+
throw error;
|
|
13754
|
+
}
|
|
13755
|
+
};
|
|
13756
|
+
return { isEnabled, emit, trackResult };
|
|
13757
|
+
}
|
|
13758
|
+
|
|
13559
13759
|
// src/shared/config/ConfigService.ts
|
|
13560
13760
|
var ConfigService = class {
|
|
13561
13761
|
sodax;
|
|
@@ -13566,6 +13766,12 @@ var ConfigService = class {
|
|
|
13566
13766
|
* {@link initialize}'s dynamic-config swap never clobbers it. Read by services via `config.logger`.
|
|
13567
13767
|
*/
|
|
13568
13768
|
logger;
|
|
13769
|
+
/**
|
|
13770
|
+
* Analytics emitter. Resolved once at construction and kept independent of {@link sodax} so that
|
|
13771
|
+
* {@link initialize}'s dynamic-config swap never clobbers it. Read by services via `config.analytics`;
|
|
13772
|
+
* disabled (no-op) unless the consumer passed an `analytics` config to `new Sodax(...)`.
|
|
13773
|
+
*/
|
|
13774
|
+
analytics;
|
|
13569
13775
|
/**
|
|
13570
13776
|
* Global partner fee. Resolved once at construction and kept independent of {@link sodax} so that
|
|
13571
13777
|
* {@link initialize}'s dynamic-config swap never clobbers it. The backend never supplies it — it is
|
|
@@ -13583,11 +13789,12 @@ var ConfigService = class {
|
|
|
13583
13789
|
stakedATokenAddressesSet;
|
|
13584
13790
|
chainToSupportedTokenAddressMap;
|
|
13585
13791
|
hubAssetToXTokenMap;
|
|
13586
|
-
constructor({ api, config, userConfig, logger, fee }) {
|
|
13792
|
+
constructor({ api, config, userConfig, logger, analytics, fee }) {
|
|
13587
13793
|
this.api = api;
|
|
13588
13794
|
this.sodax = config;
|
|
13589
13795
|
this.userConfig = userConfig;
|
|
13590
13796
|
this.logger = logger ?? resolveLogger(void 0);
|
|
13797
|
+
this.analytics = analytics ?? noopAnalytics;
|
|
13591
13798
|
this.fee = fee;
|
|
13592
13799
|
this.loadSodaxConfigDataStructures(config);
|
|
13593
13800
|
}
|
|
@@ -13638,6 +13845,16 @@ var ConfigService = class {
|
|
|
13638
13845
|
getOriginalAssetAddress(chainId, hubAsset) {
|
|
13639
13846
|
return this.hubAssetToXTokenMap.get(hubAsset.toLowerCase())?.address;
|
|
13640
13847
|
}
|
|
13848
|
+
/**
|
|
13849
|
+
* Resolves the {@link XToken} descriptor (hub asset, vault, decimals) for a hub-asset address.
|
|
13850
|
+
*
|
|
13851
|
+
* Useful when a caller holds a hub asset directly on Sonic that has no spoke-token entry under
|
|
13852
|
+
* the hub chain — e.g. a partner BTC fee held as the BTC hub asset, which only exists as a spoke
|
|
13853
|
+
* token on Bitcoin. Returns `undefined` when the address is not a known hub asset.
|
|
13854
|
+
*/
|
|
13855
|
+
getXTokenFromHubAsset(hubAsset) {
|
|
13856
|
+
return this.hubAssetToXTokenMap.get(hubAsset.toLowerCase());
|
|
13857
|
+
}
|
|
13641
13858
|
getSpokeTokenFromOriginalAssetAddress(chainId, originalAssetAddress) {
|
|
13642
13859
|
return this.supportedTokensPerChain.get(chainId)?.find((token) => token.address.toLowerCase() === originalAssetAddress.toLowerCase());
|
|
13643
13860
|
}
|
|
@@ -26425,64 +26642,88 @@ var SwapService = class {
|
|
|
26425
26642
|
const { params } = _params;
|
|
26426
26643
|
const srcChainKey = params.srcChainKey;
|
|
26427
26644
|
const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey };
|
|
26428
|
-
|
|
26429
|
-
|
|
26430
|
-
|
|
26431
|
-
|
|
26432
|
-
|
|
26433
|
-
|
|
26434
|
-
|
|
26435
|
-
|
|
26436
|
-
|
|
26437
|
-
|
|
26438
|
-
|
|
26439
|
-
|
|
26440
|
-
|
|
26441
|
-
|
|
26442
|
-
|
|
26443
|
-
|
|
26444
|
-
|
|
26445
|
-
|
|
26446
|
-
|
|
26447
|
-
|
|
26448
|
-
|
|
26449
|
-
|
|
26450
|
-
|
|
26451
|
-
|
|
26452
|
-
|
|
26453
|
-
|
|
26454
|
-
|
|
26455
|
-
|
|
26456
|
-
|
|
26457
|
-
|
|
26458
|
-
|
|
26459
|
-
|
|
26460
|
-
|
|
26461
|
-
|
|
26462
|
-
|
|
26463
|
-
|
|
26464
|
-
|
|
26465
|
-
|
|
26466
|
-
|
|
26467
|
-
|
|
26468
|
-
|
|
26469
|
-
|
|
26470
|
-
srcChainKey,
|
|
26471
|
-
srcTxHash: spokeTxHash,
|
|
26472
|
-
srcAddress: params.srcAddress,
|
|
26473
|
-
dstChainKey: params.dstChainKey,
|
|
26474
|
-
dstTxHash: dstIntentTxHash,
|
|
26475
|
-
dstAddress: params.dstAddress
|
|
26645
|
+
return this.config.analytics.trackResult(
|
|
26646
|
+
"swap",
|
|
26647
|
+
"swap",
|
|
26648
|
+
async () => {
|
|
26649
|
+
try {
|
|
26650
|
+
const timeout = _params.timeout;
|
|
26651
|
+
const createIntentResult = await this.createIntent(_params);
|
|
26652
|
+
if (!createIntentResult.ok) {
|
|
26653
|
+
return { ok: false, error: createIntentResult.error };
|
|
26654
|
+
}
|
|
26655
|
+
const { tx: spokeTxHash, intent, relayData } = createIntentResult.value;
|
|
26656
|
+
const verifyTxHashResult = await this.spoke.verifyTxHash({
|
|
26657
|
+
txHash: spokeTxHash,
|
|
26658
|
+
chainKey: srcChainKey
|
|
26659
|
+
});
|
|
26660
|
+
if (!verifyTxHashResult.ok) {
|
|
26661
|
+
return { ok: false, error: verifyFailed("swap", verifyTxHashResult.error, { ...baseCtx, action: "swap" }) };
|
|
26662
|
+
}
|
|
26663
|
+
let dstIntentTxHash;
|
|
26664
|
+
if (isHubChainKeyType(srcChainKey)) {
|
|
26665
|
+
dstIntentTxHash = spokeTxHash;
|
|
26666
|
+
} else {
|
|
26667
|
+
const packet = await relayTxAndWaitPacket({
|
|
26668
|
+
srcTxHash: spokeTxHash,
|
|
26669
|
+
data: relayData,
|
|
26670
|
+
chainKey: srcChainKey,
|
|
26671
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
26672
|
+
timeout
|
|
26673
|
+
});
|
|
26674
|
+
if (!packet.ok) {
|
|
26675
|
+
return {
|
|
26676
|
+
ok: false,
|
|
26677
|
+
error: mapRelayFailure(packet.error, { feature: "swap", action: "swap", ...baseCtx })
|
|
26678
|
+
};
|
|
26679
|
+
}
|
|
26680
|
+
dstIntentTxHash = packet.value.dst_tx_hash;
|
|
26681
|
+
}
|
|
26682
|
+
const postExecResult = await this.postExecution({
|
|
26683
|
+
intent_tx_hash: dstIntentTxHash
|
|
26684
|
+
});
|
|
26685
|
+
if (!postExecResult.ok) {
|
|
26686
|
+
return { ok: false, error: postExecResult.error };
|
|
26476
26687
|
}
|
|
26688
|
+
return {
|
|
26689
|
+
ok: true,
|
|
26690
|
+
value: {
|
|
26691
|
+
solverExecutionResponse: postExecResult.value,
|
|
26692
|
+
intent,
|
|
26693
|
+
intentDeliveryInfo: {
|
|
26694
|
+
srcChainKey,
|
|
26695
|
+
srcTxHash: spokeTxHash,
|
|
26696
|
+
srcAddress: params.srcAddress,
|
|
26697
|
+
dstChainKey: params.dstChainKey,
|
|
26698
|
+
dstTxHash: dstIntentTxHash,
|
|
26699
|
+
dstAddress: params.dstAddress
|
|
26700
|
+
}
|
|
26701
|
+
}
|
|
26702
|
+
};
|
|
26703
|
+
} catch (error) {
|
|
26704
|
+
if (isSwapError(error)) return { ok: false, error };
|
|
26705
|
+
return {
|
|
26706
|
+
ok: false,
|
|
26707
|
+
error: unknownFailed("swap", error, { ...baseCtx, action: "swap" })
|
|
26708
|
+
};
|
|
26477
26709
|
}
|
|
26478
|
-
}
|
|
26479
|
-
|
|
26480
|
-
|
|
26481
|
-
|
|
26482
|
-
|
|
26483
|
-
|
|
26484
|
-
|
|
26485
|
-
|
|
26710
|
+
},
|
|
26711
|
+
{
|
|
26712
|
+
start: () => ({
|
|
26713
|
+
srcChainKey,
|
|
26714
|
+
dstChainKey: params.dstChainKey,
|
|
26715
|
+
srcAddress: params.srcAddress,
|
|
26716
|
+
dstAddress: params.dstAddress
|
|
26717
|
+
}),
|
|
26718
|
+
success: (value) => ({
|
|
26719
|
+
srcChainKey,
|
|
26720
|
+
dstChainKey: params.dstChainKey,
|
|
26721
|
+
srcTxHash: value.intentDeliveryInfo.srcTxHash,
|
|
26722
|
+
dstTxHash: value.intentDeliveryInfo.dstTxHash
|
|
26723
|
+
}),
|
|
26724
|
+
failure: (error) => ({ code: error.code })
|
|
26725
|
+
}
|
|
26726
|
+
);
|
|
26486
26727
|
}
|
|
26487
26728
|
/**
|
|
26488
26729
|
* Checks whether the relevant spender contract is already approved to spend the input token amount.
|
|
@@ -28528,72 +28769,94 @@ var MigrationService = class {
|
|
|
28528
28769
|
* }
|
|
28529
28770
|
*/
|
|
28530
28771
|
async migratebnUSD(_params) {
|
|
28531
|
-
|
|
28532
|
-
|
|
28533
|
-
|
|
28534
|
-
|
|
28535
|
-
|
|
28536
|
-
|
|
28537
|
-
|
|
28538
|
-
|
|
28539
|
-
|
|
28540
|
-
const { tx: spokeTxHash, relayData: extraData } = intentResult.value;
|
|
28541
|
-
const verifyTxHashResult = await this.spoke.verifyTxHash({
|
|
28542
|
-
txHash: spokeTxHash,
|
|
28543
|
-
chainKey: params.srcChainKey
|
|
28544
|
-
});
|
|
28545
|
-
if (!verifyTxHashResult.ok) {
|
|
28546
|
-
return {
|
|
28547
|
-
ok: false,
|
|
28548
|
-
error: verifyFailed("migration", verifyTxHashResult.error, baseCtx)
|
|
28549
|
-
};
|
|
28550
|
-
}
|
|
28551
|
-
const packetResult = await relayTxAndWaitPacket({
|
|
28552
|
-
srcTxHash: spokeTxHash,
|
|
28553
|
-
data: extraData,
|
|
28554
|
-
chainKey: params.srcChainKey,
|
|
28555
|
-
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
28556
|
-
timeout
|
|
28557
|
-
});
|
|
28558
|
-
if (!packetResult.ok) {
|
|
28559
|
-
return {
|
|
28560
|
-
ok: false,
|
|
28561
|
-
error: mapRelayFailure(packetResult.error, {
|
|
28562
|
-
feature: "migration",
|
|
28563
|
-
action: baseCtx.action,
|
|
28564
|
-
srcChainKey: baseCtx.srcChainKey,
|
|
28565
|
-
dstChainKey: baseCtx.dstChainKey
|
|
28566
|
-
})
|
|
28772
|
+
return this.config.analytics.trackResult(
|
|
28773
|
+
"migration",
|
|
28774
|
+
"migratebnUSD",
|
|
28775
|
+
async () => {
|
|
28776
|
+
const { params, timeout } = _params;
|
|
28777
|
+
const baseCtx = {
|
|
28778
|
+
srcChainKey: params.srcChainKey,
|
|
28779
|
+
dstChainKey: params.dstChainKey,
|
|
28780
|
+
action: "migratebnUSD"
|
|
28567
28781
|
};
|
|
28568
|
-
|
|
28569
|
-
|
|
28570
|
-
|
|
28571
|
-
|
|
28572
|
-
|
|
28573
|
-
|
|
28574
|
-
|
|
28575
|
-
|
|
28576
|
-
|
|
28782
|
+
try {
|
|
28783
|
+
const intentResult = await this.createMigratebnUSDIntent(_params);
|
|
28784
|
+
if (!intentResult.ok) return { ok: false, error: intentResult.error };
|
|
28785
|
+
const { tx: spokeTxHash, relayData: extraData } = intentResult.value;
|
|
28786
|
+
const verifyTxHashResult = await this.spoke.verifyTxHash({
|
|
28787
|
+
txHash: spokeTxHash,
|
|
28788
|
+
chainKey: params.srcChainKey
|
|
28789
|
+
});
|
|
28790
|
+
if (!verifyTxHashResult.ok) {
|
|
28791
|
+
return {
|
|
28792
|
+
ok: false,
|
|
28793
|
+
error: verifyFailed("migration", verifyTxHashResult.error, baseCtx)
|
|
28794
|
+
};
|
|
28795
|
+
}
|
|
28796
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
28797
|
+
srcTxHash: spokeTxHash,
|
|
28798
|
+
data: extraData,
|
|
28799
|
+
chainKey: params.srcChainKey,
|
|
28800
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
28801
|
+
timeout
|
|
28802
|
+
});
|
|
28803
|
+
if (!packetResult.ok) {
|
|
28804
|
+
return {
|
|
28805
|
+
ok: false,
|
|
28806
|
+
error: mapRelayFailure(packetResult.error, {
|
|
28807
|
+
feature: "migration",
|
|
28808
|
+
action: baseCtx.action,
|
|
28809
|
+
srcChainKey: baseCtx.srcChainKey,
|
|
28810
|
+
dstChainKey: baseCtx.dstChainKey
|
|
28811
|
+
})
|
|
28812
|
+
};
|
|
28813
|
+
}
|
|
28814
|
+
if (!(params.srcChainKey === ChainKeys.SONIC_MAINNET || params.dstChainKey === ChainKeys.SONIC_MAINNET)) {
|
|
28815
|
+
const execResult = await waitUntilIntentExecuted({
|
|
28816
|
+
intentRelayChainId: getIntentRelayChainId(ChainKeys.SONIC_MAINNET).toString(),
|
|
28817
|
+
srcTxHash: packetResult.value.dst_tx_hash,
|
|
28818
|
+
timeout,
|
|
28819
|
+
apiUrl: this.relayerApiEndpoint
|
|
28820
|
+
});
|
|
28821
|
+
if (!execResult.ok) {
|
|
28822
|
+
return {
|
|
28823
|
+
ok: false,
|
|
28824
|
+
error: mapRelayFailure(execResult.error, {
|
|
28825
|
+
feature: "migration",
|
|
28826
|
+
action: baseCtx.action,
|
|
28827
|
+
srcChainKey: baseCtx.srcChainKey,
|
|
28828
|
+
dstChainKey: baseCtx.dstChainKey,
|
|
28829
|
+
phase: "destinationExecution"
|
|
28830
|
+
})
|
|
28831
|
+
};
|
|
28832
|
+
}
|
|
28833
|
+
}
|
|
28834
|
+
return { ok: true, value: { srcChainTxHash: spokeTxHash, dstChainTxHash: packetResult.value.dst_tx_hash } };
|
|
28835
|
+
} catch (error) {
|
|
28836
|
+
if (isMigrateOrchestrationError(error)) return { ok: false, error };
|
|
28577
28837
|
return {
|
|
28578
28838
|
ok: false,
|
|
28579
|
-
error:
|
|
28580
|
-
feature: "migration",
|
|
28581
|
-
action: baseCtx.action,
|
|
28582
|
-
srcChainKey: baseCtx.srcChainKey,
|
|
28583
|
-
dstChainKey: baseCtx.dstChainKey,
|
|
28584
|
-
phase: "destinationExecution"
|
|
28585
|
-
})
|
|
28839
|
+
error: executionFailed("migration", error, baseCtx)
|
|
28586
28840
|
};
|
|
28587
28841
|
}
|
|
28842
|
+
},
|
|
28843
|
+
{
|
|
28844
|
+
start: () => ({
|
|
28845
|
+
srcChainKey: _params.params.srcChainKey,
|
|
28846
|
+
dstChainKey: _params.params.dstChainKey,
|
|
28847
|
+
srcAddress: _params.params.srcAddress,
|
|
28848
|
+
dstAddress: _params.params.dstAddress,
|
|
28849
|
+
srcbnUSD: _params.params.srcbnUSD,
|
|
28850
|
+
dstbnUSD: _params.params.dstbnUSD,
|
|
28851
|
+
amount: _params.params.amount
|
|
28852
|
+
}),
|
|
28853
|
+
success: (value) => ({
|
|
28854
|
+
srcChainTxHash: value.srcChainTxHash,
|
|
28855
|
+
dstChainTxHash: value.dstChainTxHash
|
|
28856
|
+
}),
|
|
28857
|
+
failure: (error) => ({ code: error.code })
|
|
28588
28858
|
}
|
|
28589
|
-
|
|
28590
|
-
} catch (error) {
|
|
28591
|
-
if (isMigrateOrchestrationError(error)) return { ok: false, error };
|
|
28592
|
-
return {
|
|
28593
|
-
ok: false,
|
|
28594
|
-
error: executionFailed("migration", error, baseCtx)
|
|
28595
|
-
};
|
|
28596
|
-
}
|
|
28859
|
+
);
|
|
28597
28860
|
}
|
|
28598
28861
|
/**
|
|
28599
28862
|
* Migrates ICX or wICX tokens from ICON to SODA on the hub chain (Sonic), including relay.
|
|
@@ -28608,37 +28871,57 @@ var MigrationService = class {
|
|
|
28608
28871
|
* check fails, the deposit reverts, or the relay times out.
|
|
28609
28872
|
*/
|
|
28610
28873
|
async migrateIcxToSoda(_params) {
|
|
28611
|
-
|
|
28612
|
-
|
|
28613
|
-
|
|
28614
|
-
|
|
28615
|
-
|
|
28616
|
-
|
|
28617
|
-
|
|
28618
|
-
|
|
28619
|
-
|
|
28620
|
-
|
|
28621
|
-
|
|
28622
|
-
|
|
28623
|
-
|
|
28624
|
-
|
|
28625
|
-
|
|
28626
|
-
|
|
28627
|
-
|
|
28628
|
-
|
|
28629
|
-
|
|
28630
|
-
|
|
28631
|
-
|
|
28632
|
-
|
|
28874
|
+
return this.config.analytics.trackResult(
|
|
28875
|
+
"migration",
|
|
28876
|
+
"migrateIcxToSoda",
|
|
28877
|
+
async () => {
|
|
28878
|
+
const { timeout } = _params;
|
|
28879
|
+
const baseCtx = { srcChainKey: _params.params.srcChainKey, action: "migrateIcxToSoda" };
|
|
28880
|
+
try {
|
|
28881
|
+
const txResult = await this.createMigrateIcxToSodaIntent(_params);
|
|
28882
|
+
if (!txResult.ok) return { ok: false, error: txResult.error };
|
|
28883
|
+
const { tx, relayData } = txResult.value;
|
|
28884
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
28885
|
+
srcTxHash: tx,
|
|
28886
|
+
data: relayData,
|
|
28887
|
+
chainKey: _params.params.srcChainKey,
|
|
28888
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
28889
|
+
timeout
|
|
28890
|
+
});
|
|
28891
|
+
if (!packetResult.ok) {
|
|
28892
|
+
return {
|
|
28893
|
+
ok: false,
|
|
28894
|
+
error: mapRelayFailure(packetResult.error, {
|
|
28895
|
+
feature: "migration",
|
|
28896
|
+
action: baseCtx.action,
|
|
28897
|
+
srcChainKey: baseCtx.srcChainKey
|
|
28898
|
+
})
|
|
28899
|
+
};
|
|
28900
|
+
}
|
|
28901
|
+
return { ok: true, value: { srcChainTxHash: tx, dstChainTxHash: packetResult.value.dst_tx_hash } };
|
|
28902
|
+
} catch (error) {
|
|
28903
|
+
if (isMigrateOrchestrationError(error)) return { ok: false, error };
|
|
28904
|
+
return {
|
|
28905
|
+
ok: false,
|
|
28906
|
+
error: executionFailed("migration", error, baseCtx)
|
|
28907
|
+
};
|
|
28908
|
+
}
|
|
28909
|
+
},
|
|
28910
|
+
{
|
|
28911
|
+
start: () => ({
|
|
28912
|
+
srcChainKey: _params.params.srcChainKey,
|
|
28913
|
+
srcAddress: _params.params.srcAddress,
|
|
28914
|
+
dstAddress: _params.params.dstAddress,
|
|
28915
|
+
address: _params.params.address,
|
|
28916
|
+
amount: _params.params.amount
|
|
28917
|
+
}),
|
|
28918
|
+
success: (value) => ({
|
|
28919
|
+
srcChainTxHash: value.srcChainTxHash,
|
|
28920
|
+
dstChainTxHash: value.dstChainTxHash
|
|
28921
|
+
}),
|
|
28922
|
+
failure: (error) => ({ code: error.code })
|
|
28633
28923
|
}
|
|
28634
|
-
|
|
28635
|
-
} catch (error) {
|
|
28636
|
-
if (isMigrateOrchestrationError(error)) return { ok: false, error };
|
|
28637
|
-
return {
|
|
28638
|
-
ok: false,
|
|
28639
|
-
error: executionFailed("migration", error, baseCtx)
|
|
28640
|
-
};
|
|
28641
|
-
}
|
|
28924
|
+
);
|
|
28642
28925
|
}
|
|
28643
28926
|
/**
|
|
28644
28927
|
* Reverts a previous ICX→SODA migration by swapping SODA back to wICX on the hub and
|
|
@@ -28656,37 +28939,56 @@ var MigrationService = class {
|
|
|
28656
28939
|
* Sonic deposit transaction and `dstChainTxHash` is the hub-side packet receipt.
|
|
28657
28940
|
*/
|
|
28658
28941
|
async revertMigrateSodaToIcx(_params) {
|
|
28659
|
-
|
|
28660
|
-
|
|
28661
|
-
|
|
28662
|
-
|
|
28663
|
-
|
|
28664
|
-
|
|
28665
|
-
|
|
28666
|
-
|
|
28667
|
-
|
|
28668
|
-
|
|
28669
|
-
|
|
28670
|
-
|
|
28671
|
-
|
|
28672
|
-
|
|
28673
|
-
|
|
28674
|
-
|
|
28675
|
-
|
|
28676
|
-
|
|
28677
|
-
|
|
28678
|
-
|
|
28679
|
-
|
|
28680
|
-
|
|
28942
|
+
return this.config.analytics.trackResult(
|
|
28943
|
+
"migration",
|
|
28944
|
+
"revertMigrateSodaToIcx",
|
|
28945
|
+
async () => {
|
|
28946
|
+
const { timeout } = _params;
|
|
28947
|
+
const baseCtx = { srcChainKey: ChainKeys.SONIC_MAINNET, action: "revertMigrateSodaToIcx" };
|
|
28948
|
+
try {
|
|
28949
|
+
const txResult = await this.createRevertSodaToIcxMigrationIntent(_params);
|
|
28950
|
+
if (!txResult.ok) return { ok: false, error: txResult.error };
|
|
28951
|
+
const { tx, relayData } = txResult.value;
|
|
28952
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
28953
|
+
srcTxHash: tx,
|
|
28954
|
+
data: relayData,
|
|
28955
|
+
chainKey: ChainKeys.SONIC_MAINNET,
|
|
28956
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
28957
|
+
timeout
|
|
28958
|
+
});
|
|
28959
|
+
if (!packetResult.ok) {
|
|
28960
|
+
return {
|
|
28961
|
+
ok: false,
|
|
28962
|
+
error: mapRelayFailure(packetResult.error, {
|
|
28963
|
+
feature: "migration",
|
|
28964
|
+
action: baseCtx.action,
|
|
28965
|
+
srcChainKey: baseCtx.srcChainKey
|
|
28966
|
+
})
|
|
28967
|
+
};
|
|
28968
|
+
}
|
|
28969
|
+
return { ok: true, value: { srcChainTxHash: tx, dstChainTxHash: packetResult.value.dst_tx_hash } };
|
|
28970
|
+
} catch (error) {
|
|
28971
|
+
if (isRevertMigrationOrchestrationError(error)) return { ok: false, error };
|
|
28972
|
+
return {
|
|
28973
|
+
ok: false,
|
|
28974
|
+
error: executionFailed("migration", error, baseCtx)
|
|
28975
|
+
};
|
|
28976
|
+
}
|
|
28977
|
+
},
|
|
28978
|
+
{
|
|
28979
|
+
start: () => ({
|
|
28980
|
+
srcChainKey: _params.params.srcChainKey,
|
|
28981
|
+
srcAddress: _params.params.srcAddress,
|
|
28982
|
+
dstAddress: _params.params.dstAddress,
|
|
28983
|
+
amount: _params.params.amount
|
|
28984
|
+
}),
|
|
28985
|
+
success: (value) => ({
|
|
28986
|
+
srcChainTxHash: value.srcChainTxHash,
|
|
28987
|
+
dstChainTxHash: value.dstChainTxHash
|
|
28988
|
+
}),
|
|
28989
|
+
failure: (error) => ({ code: error.code })
|
|
28681
28990
|
}
|
|
28682
|
-
|
|
28683
|
-
} catch (error) {
|
|
28684
|
-
if (isRevertMigrationOrchestrationError(error)) return { ok: false, error };
|
|
28685
|
-
return {
|
|
28686
|
-
ok: false,
|
|
28687
|
-
error: executionFailed("migration", error, baseCtx)
|
|
28688
|
-
};
|
|
28689
|
-
}
|
|
28991
|
+
);
|
|
28690
28992
|
}
|
|
28691
28993
|
/**
|
|
28692
28994
|
* Migrates BALN tokens from ICON to SODA on the hub chain (Sonic), including relay.
|
|
@@ -28703,37 +29005,58 @@ var MigrationService = class {
|
|
|
28703
29005
|
* ICON deposit transaction and `dstChainTxHash` is the hub-side packet receipt.
|
|
28704
29006
|
*/
|
|
28705
29007
|
async migrateBaln(_params) {
|
|
28706
|
-
|
|
28707
|
-
|
|
28708
|
-
|
|
28709
|
-
|
|
28710
|
-
|
|
28711
|
-
|
|
28712
|
-
|
|
28713
|
-
|
|
28714
|
-
|
|
28715
|
-
|
|
28716
|
-
|
|
28717
|
-
|
|
28718
|
-
|
|
28719
|
-
|
|
28720
|
-
|
|
28721
|
-
|
|
28722
|
-
|
|
28723
|
-
|
|
28724
|
-
|
|
28725
|
-
|
|
28726
|
-
|
|
28727
|
-
|
|
29008
|
+
return this.config.analytics.trackResult(
|
|
29009
|
+
"migration",
|
|
29010
|
+
"migrateBaln",
|
|
29011
|
+
async () => {
|
|
29012
|
+
const { timeout } = _params;
|
|
29013
|
+
const baseCtx = { srcChainKey: ChainKeys.ICON_MAINNET, action: "migrateBaln" };
|
|
29014
|
+
try {
|
|
29015
|
+
const txResult = await this.createMigrateBalnIntent(_params);
|
|
29016
|
+
if (!txResult.ok) return { ok: false, error: txResult.error };
|
|
29017
|
+
const { tx, relayData } = txResult.value;
|
|
29018
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
29019
|
+
srcTxHash: tx,
|
|
29020
|
+
data: relayData,
|
|
29021
|
+
chainKey: ChainKeys.ICON_MAINNET,
|
|
29022
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
29023
|
+
timeout
|
|
29024
|
+
});
|
|
29025
|
+
if (!packetResult.ok) {
|
|
29026
|
+
return {
|
|
29027
|
+
ok: false,
|
|
29028
|
+
error: mapRelayFailure(packetResult.error, {
|
|
29029
|
+
feature: "migration",
|
|
29030
|
+
action: baseCtx.action,
|
|
29031
|
+
srcChainKey: baseCtx.srcChainKey
|
|
29032
|
+
})
|
|
29033
|
+
};
|
|
29034
|
+
}
|
|
29035
|
+
return { ok: true, value: { srcChainTxHash: tx, dstChainTxHash: packetResult.value.dst_tx_hash } };
|
|
29036
|
+
} catch (error) {
|
|
29037
|
+
if (isMigrateOrchestrationError(error)) return { ok: false, error };
|
|
29038
|
+
return {
|
|
29039
|
+
ok: false,
|
|
29040
|
+
error: executionFailed("migration", error, baseCtx)
|
|
29041
|
+
};
|
|
29042
|
+
}
|
|
29043
|
+
},
|
|
29044
|
+
{
|
|
29045
|
+
start: () => ({
|
|
29046
|
+
srcChainKey: _params.params.srcChainKey,
|
|
29047
|
+
srcAddress: _params.params.srcAddress,
|
|
29048
|
+
dstAddress: _params.params.dstAddress,
|
|
29049
|
+
amount: _params.params.amount,
|
|
29050
|
+
lockupPeriod: _params.params.lockupPeriod,
|
|
29051
|
+
stake: _params.params.stake
|
|
29052
|
+
}),
|
|
29053
|
+
success: (value) => ({
|
|
29054
|
+
srcChainTxHash: value.srcChainTxHash,
|
|
29055
|
+
dstChainTxHash: value.dstChainTxHash
|
|
29056
|
+
}),
|
|
29057
|
+
failure: (error) => ({ code: error.code })
|
|
28728
29058
|
}
|
|
28729
|
-
|
|
28730
|
-
} catch (error) {
|
|
28731
|
-
if (isMigrateOrchestrationError(error)) return { ok: false, error };
|
|
28732
|
-
return {
|
|
28733
|
-
ok: false,
|
|
28734
|
-
error: executionFailed("migration", error, baseCtx)
|
|
28735
|
-
};
|
|
28736
|
-
}
|
|
29059
|
+
);
|
|
28737
29060
|
}
|
|
28738
29061
|
/**
|
|
28739
29062
|
* Builds and submits the spoke-side deposit for a BALN→SODA migration without relaying.
|
|
@@ -29787,49 +30110,71 @@ var BridgeService = class {
|
|
|
29787
30110
|
* }
|
|
29788
30111
|
*/
|
|
29789
30112
|
async bridge(_params) {
|
|
29790
|
-
|
|
29791
|
-
|
|
29792
|
-
|
|
29793
|
-
|
|
29794
|
-
|
|
29795
|
-
|
|
29796
|
-
|
|
29797
|
-
|
|
29798
|
-
|
|
29799
|
-
|
|
29800
|
-
|
|
29801
|
-
|
|
29802
|
-
|
|
29803
|
-
|
|
30113
|
+
return this.config.analytics.trackResult(
|
|
30114
|
+
"bridge",
|
|
30115
|
+
"bridge",
|
|
30116
|
+
async () => {
|
|
30117
|
+
const { params, timeout } = _params;
|
|
30118
|
+
const baseCtx = { srcChainKey: params.srcChainKey, dstChainKey: params.dstChainKey };
|
|
30119
|
+
try {
|
|
30120
|
+
const txResult = await this.createBridgeIntent(_params);
|
|
30121
|
+
if (!txResult.ok) return { ok: false, error: txResult.error };
|
|
30122
|
+
const verifyTxHashResult = await this.spoke.verifyTxHash({
|
|
30123
|
+
txHash: txResult.value.tx,
|
|
30124
|
+
chainKey: params.srcChainKey
|
|
30125
|
+
});
|
|
30126
|
+
if (!verifyTxHashResult.ok) {
|
|
30127
|
+
return {
|
|
30128
|
+
ok: false,
|
|
30129
|
+
error: verifyFailed("bridge", verifyTxHashResult.error, baseCtx)
|
|
30130
|
+
};
|
|
30131
|
+
}
|
|
30132
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
30133
|
+
srcTxHash: txResult.value.tx,
|
|
30134
|
+
data: txResult.value.relayData,
|
|
30135
|
+
chainKey: params.srcChainKey,
|
|
30136
|
+
relayerApiEndpoint: this.config.relay.relayerApiEndpoint,
|
|
30137
|
+
timeout
|
|
30138
|
+
});
|
|
30139
|
+
if (!packetResult.ok)
|
|
30140
|
+
return {
|
|
30141
|
+
ok: false,
|
|
30142
|
+
error: mapRelayFailure(packetResult.error, {
|
|
30143
|
+
feature: "bridge",
|
|
30144
|
+
action: "bridge",
|
|
30145
|
+
srcChainKey: baseCtx.srcChainKey,
|
|
30146
|
+
dstChainKey: baseCtx.dstChainKey
|
|
30147
|
+
})
|
|
30148
|
+
};
|
|
30149
|
+
return {
|
|
30150
|
+
ok: true,
|
|
30151
|
+
value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: packetResult.value.dst_tx_hash }
|
|
30152
|
+
};
|
|
30153
|
+
} catch (error) {
|
|
30154
|
+
if (isBridgeOrchestrationError(error)) return { ok: false, error };
|
|
30155
|
+
return {
|
|
30156
|
+
ok: false,
|
|
30157
|
+
error: executionFailed("bridge", error, baseCtx)
|
|
30158
|
+
};
|
|
30159
|
+
}
|
|
30160
|
+
},
|
|
30161
|
+
{
|
|
30162
|
+
start: () => ({
|
|
30163
|
+
srcChainKey: _params.params.srcChainKey,
|
|
30164
|
+
dstChainKey: _params.params.dstChainKey,
|
|
30165
|
+
srcToken: _params.params.srcToken,
|
|
30166
|
+
dstToken: _params.params.dstToken,
|
|
30167
|
+
amount: _params.params.amount,
|
|
30168
|
+
srcAddress: _params.params.srcAddress,
|
|
30169
|
+
recipient: _params.params.recipient
|
|
30170
|
+
}),
|
|
30171
|
+
success: (value) => ({
|
|
30172
|
+
srcChainTxHash: value.srcChainTxHash,
|
|
30173
|
+
dstChainTxHash: value.dstChainTxHash
|
|
30174
|
+
}),
|
|
30175
|
+
failure: (error) => ({ code: error.code })
|
|
29804
30176
|
}
|
|
29805
|
-
|
|
29806
|
-
srcTxHash: txResult.value.tx,
|
|
29807
|
-
data: txResult.value.relayData,
|
|
29808
|
-
chainKey: params.srcChainKey,
|
|
29809
|
-
relayerApiEndpoint: this.config.relay.relayerApiEndpoint,
|
|
29810
|
-
timeout
|
|
29811
|
-
});
|
|
29812
|
-
if (!packetResult.ok)
|
|
29813
|
-
return {
|
|
29814
|
-
ok: false,
|
|
29815
|
-
error: mapRelayFailure(packetResult.error, {
|
|
29816
|
-
feature: "bridge",
|
|
29817
|
-
action: "bridge",
|
|
29818
|
-
srcChainKey: baseCtx.srcChainKey,
|
|
29819
|
-
dstChainKey: baseCtx.dstChainKey
|
|
29820
|
-
})
|
|
29821
|
-
};
|
|
29822
|
-
return {
|
|
29823
|
-
ok: true,
|
|
29824
|
-
value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: packetResult.value.dst_tx_hash }
|
|
29825
|
-
};
|
|
29826
|
-
} catch (error) {
|
|
29827
|
-
if (isBridgeOrchestrationError(error)) return { ok: false, error };
|
|
29828
|
-
return {
|
|
29829
|
-
ok: false,
|
|
29830
|
-
error: executionFailed("bridge", error, baseCtx)
|
|
29831
|
-
};
|
|
29832
|
-
}
|
|
30177
|
+
);
|
|
29833
30178
|
}
|
|
29834
30179
|
/**
|
|
29835
30180
|
* Submits the spoke-side deposit transaction that initiates a bridge transfer,
|
|
@@ -29858,8 +30203,8 @@ var BridgeService = class {
|
|
|
29858
30203
|
const baseCtx = { srcChainKey: params.srcChainKey, dstChainKey: params.dstChainKey };
|
|
29859
30204
|
try {
|
|
29860
30205
|
bridgeInvariant(params.amount > 0n, "Amount must be greater than 0", { ...baseCtx, field: "amount" });
|
|
29861
|
-
const srcToken = this.
|
|
29862
|
-
const dstToken = this.
|
|
30206
|
+
const srcToken = this.resolveBridgeEndpointToken(params.srcChainKey, params.srcToken);
|
|
30207
|
+
const dstToken = this.resolveBridgeEndpointToken(params.dstChainKey, params.dstToken);
|
|
29863
30208
|
bridgeInvariant(srcToken, `Unsupported spoke chain (${params.srcChainKey}) token: ${params.srcToken}`, {
|
|
29864
30209
|
...baseCtx,
|
|
29865
30210
|
field: "srcToken"
|
|
@@ -29927,6 +30272,20 @@ var BridgeService = class {
|
|
|
29927
30272
|
};
|
|
29928
30273
|
}
|
|
29929
30274
|
}
|
|
30275
|
+
/**
|
|
30276
|
+
* Resolves a bridge endpoint's {@link XToken} descriptor from a chain key + token address.
|
|
30277
|
+
*
|
|
30278
|
+
* Spoke endpoints (and hub-native tokens such as USDC/WETH/S whose on-chain address equals their
|
|
30279
|
+
* hub asset) resolve by original asset address. On the hub a caller may instead hold a hub asset
|
|
30280
|
+
* that has no spoke-token entry under the hub chain — e.g. a partner BTC fee held as the BTC hub
|
|
30281
|
+
* asset, whose only spoke-token entry lives on Bitcoin. Resolve those by hub-asset address so the
|
|
30282
|
+
* Sonic-sourced "withdraw directly" bridge can find the matching vault/decimals.
|
|
30283
|
+
*/
|
|
30284
|
+
resolveBridgeEndpointToken(chainKey, token) {
|
|
30285
|
+
const spokeToken = this.config.getSpokeTokenFromOriginalAssetAddress(chainKey, token);
|
|
30286
|
+
if (spokeToken) return spokeToken;
|
|
30287
|
+
return isHubChainKeyType(chainKey) ? this.config.getXTokenFromHubAsset(token) : void 0;
|
|
30288
|
+
}
|
|
29930
30289
|
/**
|
|
29931
30290
|
* Encodes the hub-side execution payload for a bridge operation.
|
|
29932
30291
|
*
|
|
@@ -30809,52 +31168,71 @@ var StakingService = class {
|
|
|
30809
31168
|
* @returns `{ ok: true, value: { srcChainTxHash, dstChainTxHash } }` on success.
|
|
30810
31169
|
*/
|
|
30811
31170
|
async stake(_params) {
|
|
30812
|
-
|
|
30813
|
-
|
|
30814
|
-
|
|
30815
|
-
|
|
30816
|
-
|
|
30817
|
-
|
|
30818
|
-
|
|
30819
|
-
|
|
30820
|
-
|
|
30821
|
-
|
|
30822
|
-
|
|
30823
|
-
|
|
30824
|
-
|
|
30825
|
-
|
|
30826
|
-
|
|
30827
|
-
|
|
30828
|
-
|
|
30829
|
-
|
|
30830
|
-
|
|
30831
|
-
|
|
30832
|
-
|
|
30833
|
-
|
|
30834
|
-
|
|
30835
|
-
|
|
30836
|
-
|
|
31171
|
+
return this.config.analytics.trackResult(
|
|
31172
|
+
"staking",
|
|
31173
|
+
"stake",
|
|
31174
|
+
async () => {
|
|
31175
|
+
const { params, timeout } = _params;
|
|
31176
|
+
const baseCtx = { srcChainKey: params.srcChainKey, action: "stake" };
|
|
31177
|
+
try {
|
|
31178
|
+
const txResult = await this.createStakeIntent(_params);
|
|
31179
|
+
if (!txResult.ok) return { ok: false, error: txResult.error };
|
|
31180
|
+
const verifyTxHashResult = await this.spoke.verifyTxHash({
|
|
31181
|
+
txHash: txResult.value.tx,
|
|
31182
|
+
chainKey: params.srcChainKey
|
|
31183
|
+
});
|
|
31184
|
+
if (!verifyTxHashResult.ok) {
|
|
31185
|
+
return {
|
|
31186
|
+
ok: false,
|
|
31187
|
+
error: verifyFailed("staking", verifyTxHashResult.error, baseCtx)
|
|
31188
|
+
};
|
|
31189
|
+
}
|
|
31190
|
+
let hubTxHash;
|
|
31191
|
+
if (!isHubChainKeyType(params.srcChainKey)) {
|
|
31192
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
31193
|
+
srcTxHash: txResult.value.tx,
|
|
31194
|
+
data: txResult.value.relayData,
|
|
31195
|
+
chainKey: params.srcChainKey,
|
|
31196
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
31197
|
+
timeout
|
|
31198
|
+
});
|
|
31199
|
+
if (!packetResult.ok) {
|
|
31200
|
+
return {
|
|
31201
|
+
ok: false,
|
|
31202
|
+
error: mapRelayFailure(packetResult.error, {
|
|
31203
|
+
feature: "staking",
|
|
31204
|
+
action: baseCtx.action,
|
|
31205
|
+
srcChainKey: baseCtx.srcChainKey
|
|
31206
|
+
})
|
|
31207
|
+
};
|
|
31208
|
+
}
|
|
31209
|
+
hubTxHash = packetResult.value.dst_tx_hash;
|
|
31210
|
+
} else {
|
|
31211
|
+
hubTxHash = txResult.value.tx;
|
|
31212
|
+
}
|
|
31213
|
+
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: hubTxHash } };
|
|
31214
|
+
} catch (error) {
|
|
31215
|
+
if (isStakeOrchestrationError(error)) return { ok: false, error };
|
|
30837
31216
|
return {
|
|
30838
31217
|
ok: false,
|
|
30839
|
-
error:
|
|
30840
|
-
feature: "staking",
|
|
30841
|
-
action: baseCtx.action,
|
|
30842
|
-
srcChainKey: baseCtx.srcChainKey
|
|
30843
|
-
})
|
|
31218
|
+
error: executionFailed("staking", error, baseCtx)
|
|
30844
31219
|
};
|
|
30845
31220
|
}
|
|
30846
|
-
|
|
30847
|
-
|
|
30848
|
-
|
|
31221
|
+
},
|
|
31222
|
+
{
|
|
31223
|
+
start: () => ({
|
|
31224
|
+
srcChainKey: _params.params.srcChainKey,
|
|
31225
|
+
srcAddress: _params.params.srcAddress,
|
|
31226
|
+
amount: _params.params.amount,
|
|
31227
|
+
minReceive: _params.params.minReceive
|
|
31228
|
+
}),
|
|
31229
|
+
success: (value) => ({
|
|
31230
|
+
srcChainTxHash: value.srcChainTxHash,
|
|
31231
|
+
dstChainTxHash: value.dstChainTxHash
|
|
31232
|
+
}),
|
|
31233
|
+
failure: (error) => ({ code: error.code })
|
|
30849
31234
|
}
|
|
30850
|
-
|
|
30851
|
-
} catch (error) {
|
|
30852
|
-
if (isStakeOrchestrationError(error)) return { ok: false, error };
|
|
30853
|
-
return {
|
|
30854
|
-
ok: false,
|
|
30855
|
-
error: executionFailed("staking", error, baseCtx)
|
|
30856
|
-
};
|
|
30857
|
-
}
|
|
31235
|
+
);
|
|
30858
31236
|
}
|
|
30859
31237
|
/**
|
|
30860
31238
|
* Submits the stake transaction on the spoke chain without relaying to the hub.
|
|
@@ -30959,42 +31337,60 @@ var StakingService = class {
|
|
|
30959
31337
|
* @returns `{ ok: true, value: { srcChainTxHash, dstChainTxHash } }` on success.
|
|
30960
31338
|
*/
|
|
30961
31339
|
async unstake(_params) {
|
|
30962
|
-
|
|
30963
|
-
|
|
30964
|
-
|
|
30965
|
-
|
|
30966
|
-
|
|
30967
|
-
|
|
30968
|
-
|
|
30969
|
-
|
|
30970
|
-
|
|
30971
|
-
|
|
30972
|
-
|
|
30973
|
-
|
|
30974
|
-
|
|
30975
|
-
|
|
30976
|
-
|
|
31340
|
+
return this.config.analytics.trackResult(
|
|
31341
|
+
"staking",
|
|
31342
|
+
"unstake",
|
|
31343
|
+
async () => {
|
|
31344
|
+
const { params, timeout } = _params;
|
|
31345
|
+
const baseCtx = { srcChainKey: params.srcChainKey, action: "unstake" };
|
|
31346
|
+
try {
|
|
31347
|
+
const txResult = await this.createUnstakeIntent(_params);
|
|
31348
|
+
if (!txResult.ok) return { ok: false, error: txResult.error };
|
|
31349
|
+
let hubTxHash;
|
|
31350
|
+
if (!isHubChainKeyType(params.srcChainKey)) {
|
|
31351
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
31352
|
+
srcTxHash: txResult.value.tx,
|
|
31353
|
+
data: txResult.value.relayData,
|
|
31354
|
+
chainKey: params.srcChainKey,
|
|
31355
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
31356
|
+
timeout
|
|
31357
|
+
});
|
|
31358
|
+
if (!packetResult.ok) {
|
|
31359
|
+
return {
|
|
31360
|
+
ok: false,
|
|
31361
|
+
error: mapRelayFailure(packetResult.error, {
|
|
31362
|
+
feature: "staking",
|
|
31363
|
+
action: baseCtx.action,
|
|
31364
|
+
srcChainKey: baseCtx.srcChainKey
|
|
31365
|
+
})
|
|
31366
|
+
};
|
|
31367
|
+
}
|
|
31368
|
+
hubTxHash = packetResult.value.dst_tx_hash;
|
|
31369
|
+
} else {
|
|
31370
|
+
hubTxHash = txResult.value.tx;
|
|
31371
|
+
}
|
|
31372
|
+
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: hubTxHash } };
|
|
31373
|
+
} catch (error) {
|
|
31374
|
+
if (isStakingOrchestrationError(error)) return { ok: false, error };
|
|
30977
31375
|
return {
|
|
30978
31376
|
ok: false,
|
|
30979
|
-
error:
|
|
30980
|
-
feature: "staking",
|
|
30981
|
-
action: baseCtx.action,
|
|
30982
|
-
srcChainKey: baseCtx.srcChainKey
|
|
30983
|
-
})
|
|
31377
|
+
error: executionFailed("staking", error, baseCtx)
|
|
30984
31378
|
};
|
|
30985
31379
|
}
|
|
30986
|
-
|
|
30987
|
-
|
|
30988
|
-
|
|
31380
|
+
},
|
|
31381
|
+
{
|
|
31382
|
+
start: () => ({
|
|
31383
|
+
srcChainKey: _params.params.srcChainKey,
|
|
31384
|
+
srcAddress: _params.params.srcAddress,
|
|
31385
|
+
amount: _params.params.amount
|
|
31386
|
+
}),
|
|
31387
|
+
success: (value) => ({
|
|
31388
|
+
srcChainTxHash: value.srcChainTxHash,
|
|
31389
|
+
dstChainTxHash: value.dstChainTxHash
|
|
31390
|
+
}),
|
|
31391
|
+
failure: (error) => ({ code: error.code })
|
|
30989
31392
|
}
|
|
30990
|
-
|
|
30991
|
-
} catch (error) {
|
|
30992
|
-
if (isStakingOrchestrationError(error)) return { ok: false, error };
|
|
30993
|
-
return {
|
|
30994
|
-
ok: false,
|
|
30995
|
-
error: executionFailed("staking", error, baseCtx)
|
|
30996
|
-
};
|
|
30997
|
-
}
|
|
31393
|
+
);
|
|
30998
31394
|
}
|
|
30999
31395
|
/**
|
|
31000
31396
|
* Submits the unstake transaction on the spoke chain without relaying to the hub.
|
|
@@ -31090,42 +31486,61 @@ var StakingService = class {
|
|
|
31090
31486
|
* @returns `{ ok: true, value: { srcChainTxHash, dstChainTxHash } }` on success.
|
|
31091
31487
|
*/
|
|
31092
31488
|
async instantUnstake(_params) {
|
|
31093
|
-
|
|
31094
|
-
|
|
31095
|
-
|
|
31096
|
-
|
|
31097
|
-
|
|
31098
|
-
|
|
31099
|
-
|
|
31100
|
-
|
|
31101
|
-
|
|
31102
|
-
|
|
31103
|
-
|
|
31104
|
-
|
|
31105
|
-
|
|
31106
|
-
|
|
31107
|
-
|
|
31489
|
+
return this.config.analytics.trackResult(
|
|
31490
|
+
"staking",
|
|
31491
|
+
"instantUnstake",
|
|
31492
|
+
async () => {
|
|
31493
|
+
const { params, timeout } = _params;
|
|
31494
|
+
const baseCtx = { srcChainKey: params.srcChainKey, action: "instantUnstake" };
|
|
31495
|
+
try {
|
|
31496
|
+
const txResult = await this.createInstantUnstakeIntent(_params);
|
|
31497
|
+
if (!txResult.ok) return { ok: false, error: txResult.error };
|
|
31498
|
+
let hubTxHash;
|
|
31499
|
+
if (!isHubChainKeyType(params.srcChainKey)) {
|
|
31500
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
31501
|
+
srcTxHash: txResult.value.tx,
|
|
31502
|
+
data: txResult.value.relayData,
|
|
31503
|
+
chainKey: params.srcChainKey,
|
|
31504
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
31505
|
+
timeout
|
|
31506
|
+
});
|
|
31507
|
+
if (!packetResult.ok) {
|
|
31508
|
+
return {
|
|
31509
|
+
ok: false,
|
|
31510
|
+
error: mapRelayFailure(packetResult.error, {
|
|
31511
|
+
feature: "staking",
|
|
31512
|
+
action: baseCtx.action,
|
|
31513
|
+
srcChainKey: baseCtx.srcChainKey
|
|
31514
|
+
})
|
|
31515
|
+
};
|
|
31516
|
+
}
|
|
31517
|
+
hubTxHash = packetResult.value.dst_tx_hash;
|
|
31518
|
+
} else {
|
|
31519
|
+
hubTxHash = txResult.value.tx;
|
|
31520
|
+
}
|
|
31521
|
+
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: hubTxHash } };
|
|
31522
|
+
} catch (error) {
|
|
31523
|
+
if (isStakingOrchestrationError(error)) return { ok: false, error };
|
|
31108
31524
|
return {
|
|
31109
31525
|
ok: false,
|
|
31110
|
-
error:
|
|
31111
|
-
feature: "staking",
|
|
31112
|
-
action: baseCtx.action,
|
|
31113
|
-
srcChainKey: baseCtx.srcChainKey
|
|
31114
|
-
})
|
|
31526
|
+
error: executionFailed("staking", error, baseCtx)
|
|
31115
31527
|
};
|
|
31116
31528
|
}
|
|
31117
|
-
|
|
31118
|
-
|
|
31119
|
-
|
|
31529
|
+
},
|
|
31530
|
+
{
|
|
31531
|
+
start: () => ({
|
|
31532
|
+
srcChainKey: _params.params.srcChainKey,
|
|
31533
|
+
srcAddress: _params.params.srcAddress,
|
|
31534
|
+
amount: _params.params.amount,
|
|
31535
|
+
minAmount: _params.params.minAmount
|
|
31536
|
+
}),
|
|
31537
|
+
success: (value) => ({
|
|
31538
|
+
srcChainTxHash: value.srcChainTxHash,
|
|
31539
|
+
dstChainTxHash: value.dstChainTxHash
|
|
31540
|
+
}),
|
|
31541
|
+
failure: (error) => ({ code: error.code })
|
|
31120
31542
|
}
|
|
31121
|
-
|
|
31122
|
-
} catch (error) {
|
|
31123
|
-
if (isStakingOrchestrationError(error)) return { ok: false, error };
|
|
31124
|
-
return {
|
|
31125
|
-
ok: false,
|
|
31126
|
-
error: executionFailed("staking", error, baseCtx)
|
|
31127
|
-
};
|
|
31128
|
-
}
|
|
31543
|
+
);
|
|
31129
31544
|
}
|
|
31130
31545
|
/**
|
|
31131
31546
|
* Submits the instant-unstake transaction on the spoke chain without relaying to the hub.
|
|
@@ -31233,42 +31648,61 @@ var StakingService = class {
|
|
|
31233
31648
|
* @returns `{ ok: true, value: { srcChainTxHash, dstChainTxHash } }` on success.
|
|
31234
31649
|
*/
|
|
31235
31650
|
async claim(_params) {
|
|
31236
|
-
|
|
31237
|
-
|
|
31238
|
-
|
|
31239
|
-
|
|
31240
|
-
|
|
31241
|
-
|
|
31242
|
-
|
|
31243
|
-
|
|
31244
|
-
|
|
31245
|
-
|
|
31246
|
-
|
|
31247
|
-
|
|
31248
|
-
|
|
31249
|
-
|
|
31250
|
-
|
|
31651
|
+
return this.config.analytics.trackResult(
|
|
31652
|
+
"staking",
|
|
31653
|
+
"claim",
|
|
31654
|
+
async () => {
|
|
31655
|
+
const { params, timeout } = _params;
|
|
31656
|
+
const baseCtx = { srcChainKey: params.srcChainKey, action: "claim" };
|
|
31657
|
+
try {
|
|
31658
|
+
const txResult = await this.createClaimIntent(_params);
|
|
31659
|
+
if (!txResult.ok) return { ok: false, error: txResult.error };
|
|
31660
|
+
let hubTxHash;
|
|
31661
|
+
if (!isHubChainKeyType(params.srcChainKey)) {
|
|
31662
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
31663
|
+
srcTxHash: txResult.value.tx,
|
|
31664
|
+
data: txResult.value.relayData,
|
|
31665
|
+
chainKey: params.srcChainKey,
|
|
31666
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
31667
|
+
timeout
|
|
31668
|
+
});
|
|
31669
|
+
if (!packetResult.ok) {
|
|
31670
|
+
return {
|
|
31671
|
+
ok: false,
|
|
31672
|
+
error: mapRelayFailure(packetResult.error, {
|
|
31673
|
+
feature: "staking",
|
|
31674
|
+
action: baseCtx.action,
|
|
31675
|
+
srcChainKey: baseCtx.srcChainKey
|
|
31676
|
+
})
|
|
31677
|
+
};
|
|
31678
|
+
}
|
|
31679
|
+
hubTxHash = packetResult.value.dst_tx_hash;
|
|
31680
|
+
} else {
|
|
31681
|
+
hubTxHash = txResult.value.tx;
|
|
31682
|
+
}
|
|
31683
|
+
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: hubTxHash } };
|
|
31684
|
+
} catch (error) {
|
|
31685
|
+
if (isStakingOrchestrationError(error)) return { ok: false, error };
|
|
31251
31686
|
return {
|
|
31252
31687
|
ok: false,
|
|
31253
|
-
error:
|
|
31254
|
-
feature: "staking",
|
|
31255
|
-
action: baseCtx.action,
|
|
31256
|
-
srcChainKey: baseCtx.srcChainKey
|
|
31257
|
-
})
|
|
31688
|
+
error: executionFailed("staking", error, baseCtx)
|
|
31258
31689
|
};
|
|
31259
31690
|
}
|
|
31260
|
-
|
|
31261
|
-
|
|
31262
|
-
|
|
31691
|
+
},
|
|
31692
|
+
{
|
|
31693
|
+
start: () => ({
|
|
31694
|
+
srcChainKey: _params.params.srcChainKey,
|
|
31695
|
+
srcAddress: _params.params.srcAddress,
|
|
31696
|
+
requestId: _params.params.requestId,
|
|
31697
|
+
amount: _params.params.amount
|
|
31698
|
+
}),
|
|
31699
|
+
success: (value) => ({
|
|
31700
|
+
srcChainTxHash: value.srcChainTxHash,
|
|
31701
|
+
dstChainTxHash: value.dstChainTxHash
|
|
31702
|
+
}),
|
|
31703
|
+
failure: (error) => ({ code: error.code })
|
|
31263
31704
|
}
|
|
31264
|
-
|
|
31265
|
-
} catch (error) {
|
|
31266
|
-
if (isStakingOrchestrationError(error)) return { ok: false, error };
|
|
31267
|
-
return {
|
|
31268
|
-
ok: false,
|
|
31269
|
-
error: executionFailed("staking", error, baseCtx)
|
|
31270
|
-
};
|
|
31271
|
-
}
|
|
31705
|
+
);
|
|
31272
31706
|
}
|
|
31273
31707
|
/**
|
|
31274
31708
|
* Submits the claim transaction on the spoke chain without relaying to the hub.
|
|
@@ -31382,42 +31816,60 @@ var StakingService = class {
|
|
|
31382
31816
|
* @returns `{ ok: true, value: { srcChainTxHash, dstChainTxHash } }` on success.
|
|
31383
31817
|
*/
|
|
31384
31818
|
async cancelUnstake(_params) {
|
|
31385
|
-
|
|
31386
|
-
|
|
31387
|
-
|
|
31388
|
-
|
|
31389
|
-
|
|
31390
|
-
|
|
31391
|
-
|
|
31392
|
-
|
|
31393
|
-
|
|
31394
|
-
|
|
31395
|
-
|
|
31396
|
-
|
|
31397
|
-
|
|
31398
|
-
|
|
31399
|
-
|
|
31819
|
+
return this.config.analytics.trackResult(
|
|
31820
|
+
"staking",
|
|
31821
|
+
"cancelUnstake",
|
|
31822
|
+
async () => {
|
|
31823
|
+
const { params, timeout } = _params;
|
|
31824
|
+
const baseCtx = { srcChainKey: params.srcChainKey, action: "cancelUnstake" };
|
|
31825
|
+
try {
|
|
31826
|
+
const txResult = await this.createCancelUnstakeIntent(_params);
|
|
31827
|
+
if (!txResult.ok) return { ok: false, error: txResult.error };
|
|
31828
|
+
let hubTxHash;
|
|
31829
|
+
if (!isHubChainKeyType(params.srcChainKey)) {
|
|
31830
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
31831
|
+
srcTxHash: txResult.value.tx,
|
|
31832
|
+
data: txResult.value.relayData,
|
|
31833
|
+
chainKey: params.srcChainKey,
|
|
31834
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
31835
|
+
timeout
|
|
31836
|
+
});
|
|
31837
|
+
if (!packetResult.ok) {
|
|
31838
|
+
return {
|
|
31839
|
+
ok: false,
|
|
31840
|
+
error: mapRelayFailure(packetResult.error, {
|
|
31841
|
+
feature: "staking",
|
|
31842
|
+
action: baseCtx.action,
|
|
31843
|
+
srcChainKey: baseCtx.srcChainKey
|
|
31844
|
+
})
|
|
31845
|
+
};
|
|
31846
|
+
}
|
|
31847
|
+
hubTxHash = packetResult.value.dst_tx_hash;
|
|
31848
|
+
} else {
|
|
31849
|
+
hubTxHash = txResult.value.tx;
|
|
31850
|
+
}
|
|
31851
|
+
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: hubTxHash } };
|
|
31852
|
+
} catch (error) {
|
|
31853
|
+
if (isStakingOrchestrationError(error)) return { ok: false, error };
|
|
31400
31854
|
return {
|
|
31401
31855
|
ok: false,
|
|
31402
|
-
error:
|
|
31403
|
-
feature: "staking",
|
|
31404
|
-
action: baseCtx.action,
|
|
31405
|
-
srcChainKey: baseCtx.srcChainKey
|
|
31406
|
-
})
|
|
31856
|
+
error: executionFailed("staking", error, baseCtx)
|
|
31407
31857
|
};
|
|
31408
31858
|
}
|
|
31409
|
-
|
|
31410
|
-
|
|
31411
|
-
|
|
31859
|
+
},
|
|
31860
|
+
{
|
|
31861
|
+
start: () => ({
|
|
31862
|
+
srcChainKey: _params.params.srcChainKey,
|
|
31863
|
+
srcAddress: _params.params.srcAddress,
|
|
31864
|
+
requestId: _params.params.requestId
|
|
31865
|
+
}),
|
|
31866
|
+
success: (value) => ({
|
|
31867
|
+
srcChainTxHash: value.srcChainTxHash,
|
|
31868
|
+
dstChainTxHash: value.dstChainTxHash
|
|
31869
|
+
}),
|
|
31870
|
+
failure: (error) => ({ code: error.code })
|
|
31412
31871
|
}
|
|
31413
|
-
|
|
31414
|
-
} catch (error) {
|
|
31415
|
-
if (isStakingOrchestrationError(error)) return { ok: false, error };
|
|
31416
|
-
return {
|
|
31417
|
-
ok: false,
|
|
31418
|
-
error: executionFailed("staking", error, baseCtx)
|
|
31419
|
-
};
|
|
31420
|
-
}
|
|
31872
|
+
);
|
|
31421
31873
|
}
|
|
31422
31874
|
/**
|
|
31423
31875
|
* Submits the cancel-unstake transaction on the spoke chain without relaying to the hub.
|
|
@@ -32791,34 +33243,56 @@ var ClService = class _ClService {
|
|
|
32791
33243
|
* `dstChainTxHash` (hub) once the packet has been confirmed.
|
|
32792
33244
|
*/
|
|
32793
33245
|
async supplyLiquidity(_params) {
|
|
32794
|
-
|
|
32795
|
-
|
|
32796
|
-
|
|
32797
|
-
|
|
32798
|
-
|
|
32799
|
-
|
|
32800
|
-
|
|
32801
|
-
|
|
32802
|
-
|
|
32803
|
-
|
|
32804
|
-
|
|
32805
|
-
|
|
32806
|
-
|
|
32807
|
-
|
|
32808
|
-
|
|
32809
|
-
|
|
32810
|
-
|
|
32811
|
-
|
|
32812
|
-
|
|
33246
|
+
return this.config.analytics.trackResult(
|
|
33247
|
+
"dex",
|
|
33248
|
+
"supplyLiquidity",
|
|
33249
|
+
async () => {
|
|
33250
|
+
const { params, timeout } = _params;
|
|
33251
|
+
try {
|
|
33252
|
+
const txResult = await this.executeSupplyLiquidity(_params);
|
|
33253
|
+
if (!txResult.ok) {
|
|
33254
|
+
return txResult;
|
|
33255
|
+
}
|
|
33256
|
+
let hubTxHash;
|
|
33257
|
+
if (!isHubChainKeyType(params.srcChainKey)) {
|
|
33258
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
33259
|
+
srcTxHash: txResult.value.tx,
|
|
33260
|
+
data: txResult.value.relayData,
|
|
33261
|
+
chainKey: params.srcChainKey,
|
|
33262
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
33263
|
+
timeout
|
|
33264
|
+
});
|
|
33265
|
+
if (!packetResult.ok) return packetResult;
|
|
33266
|
+
hubTxHash = packetResult.value.dst_tx_hash;
|
|
33267
|
+
} else {
|
|
33268
|
+
hubTxHash = txResult.value.tx;
|
|
33269
|
+
}
|
|
33270
|
+
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: hubTxHash } };
|
|
33271
|
+
} catch (error) {
|
|
33272
|
+
this.config.logger.error("supplyLiquidity error", error);
|
|
33273
|
+
return {
|
|
33274
|
+
ok: false,
|
|
33275
|
+
error
|
|
33276
|
+
};
|
|
33277
|
+
}
|
|
33278
|
+
},
|
|
33279
|
+
{
|
|
33280
|
+
start: () => ({
|
|
33281
|
+
srcChainKey: _params.params.srcChainKey,
|
|
33282
|
+
srcAddress: _params.params.srcAddress,
|
|
33283
|
+
currency0: _params.params.poolKey.currency0,
|
|
33284
|
+
currency1: _params.params.poolKey.currency1,
|
|
33285
|
+
fee: _params.params.poolKey.fee,
|
|
33286
|
+
tickLower: _params.params.tickLower,
|
|
33287
|
+
tickUpper: _params.params.tickUpper,
|
|
33288
|
+
liquidity: _params.params.liquidity,
|
|
33289
|
+
amount0Max: _params.params.amount0Max,
|
|
33290
|
+
amount1Max: _params.params.amount1Max
|
|
33291
|
+
}),
|
|
33292
|
+
success: (value) => ({ srcChainTxHash: value.srcChainTxHash, dstChainTxHash: value.dstChainTxHash }),
|
|
33293
|
+
failure: (error) => ({ code: isSodaxError(error) ? error.code : void 0 })
|
|
32813
33294
|
}
|
|
32814
|
-
|
|
32815
|
-
} catch (error) {
|
|
32816
|
-
this.config.logger.error("supplyLiquidity error", error);
|
|
32817
|
-
return {
|
|
32818
|
-
ok: false,
|
|
32819
|
-
error
|
|
32820
|
-
};
|
|
32821
|
-
}
|
|
33295
|
+
);
|
|
32822
33296
|
}
|
|
32823
33297
|
/**
|
|
32824
33298
|
* Add liquidity to an existing position and wait for the cross-chain relay to complete.
|
|
@@ -32833,33 +33307,56 @@ var ClService = class _ClService {
|
|
|
32833
33307
|
* `dstChainTxHash` (hub) once the packet has been confirmed.
|
|
32834
33308
|
*/
|
|
32835
33309
|
async increaseLiquidity(_params) {
|
|
32836
|
-
|
|
32837
|
-
|
|
32838
|
-
|
|
32839
|
-
|
|
32840
|
-
|
|
32841
|
-
|
|
32842
|
-
|
|
32843
|
-
|
|
32844
|
-
|
|
32845
|
-
|
|
32846
|
-
|
|
32847
|
-
|
|
32848
|
-
|
|
32849
|
-
|
|
32850
|
-
|
|
32851
|
-
|
|
32852
|
-
|
|
32853
|
-
|
|
32854
|
-
|
|
33310
|
+
return this.config.analytics.trackResult(
|
|
33311
|
+
"dex",
|
|
33312
|
+
"increaseLiquidity",
|
|
33313
|
+
async () => {
|
|
33314
|
+
const { params, timeout } = _params;
|
|
33315
|
+
try {
|
|
33316
|
+
const txResult = await this.executeIncreaseLiquidity(_params);
|
|
33317
|
+
if (!txResult.ok) {
|
|
33318
|
+
return txResult;
|
|
33319
|
+
}
|
|
33320
|
+
let hubTxHash;
|
|
33321
|
+
if (!isHubChainKeyType(params.srcChainKey)) {
|
|
33322
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
33323
|
+
srcTxHash: txResult.value.tx,
|
|
33324
|
+
data: txResult.value.relayData,
|
|
33325
|
+
chainKey: params.srcChainKey,
|
|
33326
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
33327
|
+
timeout
|
|
33328
|
+
});
|
|
33329
|
+
if (!packetResult.ok) return packetResult;
|
|
33330
|
+
hubTxHash = packetResult.value.dst_tx_hash;
|
|
33331
|
+
} else {
|
|
33332
|
+
hubTxHash = txResult.value.tx;
|
|
33333
|
+
}
|
|
33334
|
+
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: hubTxHash } };
|
|
33335
|
+
} catch (error) {
|
|
33336
|
+
return {
|
|
33337
|
+
ok: false,
|
|
33338
|
+
error
|
|
33339
|
+
};
|
|
33340
|
+
}
|
|
33341
|
+
},
|
|
33342
|
+
{
|
|
33343
|
+
start: () => ({
|
|
33344
|
+
srcChainKey: _params.params.srcChainKey,
|
|
33345
|
+
srcAddress: _params.params.srcAddress,
|
|
33346
|
+
currency0: _params.params.poolKey.currency0,
|
|
33347
|
+
currency1: _params.params.poolKey.currency1,
|
|
33348
|
+
fee: _params.params.poolKey.fee,
|
|
33349
|
+
tokenId: _params.params.tokenId,
|
|
33350
|
+
tickLower: _params.params.tickLower,
|
|
33351
|
+
tickUpper: _params.params.tickUpper,
|
|
33352
|
+
liquidity: _params.params.liquidity,
|
|
33353
|
+
amount0Max: _params.params.amount0Max,
|
|
33354
|
+
amount1Max: _params.params.amount1Max
|
|
33355
|
+
}),
|
|
33356
|
+
success: (value) => ({ srcChainTxHash: value.srcChainTxHash, dstChainTxHash: value.dstChainTxHash }),
|
|
33357
|
+
failure: (error) => ({ code: isSodaxError(error) ? error.code : void 0 })
|
|
32855
33358
|
}
|
|
32856
|
-
|
|
32857
|
-
} catch (error) {
|
|
32858
|
-
return {
|
|
32859
|
-
ok: false,
|
|
32860
|
-
error
|
|
32861
|
-
};
|
|
32862
|
-
}
|
|
33359
|
+
);
|
|
32863
33360
|
}
|
|
32864
33361
|
/**
|
|
32865
33362
|
* Remove liquidity from an existing position and wait for the cross-chain relay to complete.
|
|
@@ -32874,33 +33371,54 @@ var ClService = class _ClService {
|
|
|
32874
33371
|
* `dstChainTxHash` (hub) once the packet has been confirmed.
|
|
32875
33372
|
*/
|
|
32876
33373
|
async decreaseLiquidity(_params) {
|
|
32877
|
-
|
|
32878
|
-
|
|
32879
|
-
|
|
32880
|
-
|
|
32881
|
-
|
|
32882
|
-
|
|
32883
|
-
|
|
32884
|
-
|
|
32885
|
-
|
|
32886
|
-
|
|
32887
|
-
|
|
32888
|
-
|
|
32889
|
-
|
|
32890
|
-
|
|
32891
|
-
|
|
32892
|
-
|
|
32893
|
-
|
|
32894
|
-
|
|
32895
|
-
|
|
33374
|
+
return this.config.analytics.trackResult(
|
|
33375
|
+
"dex",
|
|
33376
|
+
"decreaseLiquidity",
|
|
33377
|
+
async () => {
|
|
33378
|
+
const { params, timeout } = _params;
|
|
33379
|
+
try {
|
|
33380
|
+
const txResult = await this.executeDecreaseLiquidity(_params);
|
|
33381
|
+
if (!txResult.ok) {
|
|
33382
|
+
return txResult;
|
|
33383
|
+
}
|
|
33384
|
+
let hubTxHash;
|
|
33385
|
+
if (!isHubChainKeyType(params.srcChainKey)) {
|
|
33386
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
33387
|
+
srcTxHash: txResult.value.tx,
|
|
33388
|
+
data: txResult.value.relayData,
|
|
33389
|
+
chainKey: params.srcChainKey,
|
|
33390
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
33391
|
+
timeout
|
|
33392
|
+
});
|
|
33393
|
+
if (!packetResult.ok) return packetResult;
|
|
33394
|
+
hubTxHash = packetResult.value.dst_tx_hash;
|
|
33395
|
+
} else {
|
|
33396
|
+
hubTxHash = txResult.value.tx;
|
|
33397
|
+
}
|
|
33398
|
+
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: hubTxHash } };
|
|
33399
|
+
} catch (error) {
|
|
33400
|
+
return {
|
|
33401
|
+
ok: false,
|
|
33402
|
+
error
|
|
33403
|
+
};
|
|
33404
|
+
}
|
|
33405
|
+
},
|
|
33406
|
+
{
|
|
33407
|
+
start: () => ({
|
|
33408
|
+
srcChainKey: _params.params.srcChainKey,
|
|
33409
|
+
srcAddress: _params.params.srcAddress,
|
|
33410
|
+
currency0: _params.params.poolKey.currency0,
|
|
33411
|
+
currency1: _params.params.poolKey.currency1,
|
|
33412
|
+
fee: _params.params.poolKey.fee,
|
|
33413
|
+
tokenId: _params.params.tokenId,
|
|
33414
|
+
liquidity: _params.params.liquidity,
|
|
33415
|
+
amount0Min: _params.params.amount0Min,
|
|
33416
|
+
amount1Min: _params.params.amount1Min
|
|
33417
|
+
}),
|
|
33418
|
+
success: (value) => ({ srcChainTxHash: value.srcChainTxHash, dstChainTxHash: value.dstChainTxHash }),
|
|
33419
|
+
failure: (error) => ({ code: isSodaxError(error) ? error.code : void 0 })
|
|
32896
33420
|
}
|
|
32897
|
-
|
|
32898
|
-
} catch (error) {
|
|
32899
|
-
return {
|
|
32900
|
-
ok: false,
|
|
32901
|
-
error
|
|
32902
|
-
};
|
|
32903
|
-
}
|
|
33421
|
+
);
|
|
32904
33422
|
}
|
|
32905
33423
|
/**
|
|
32906
33424
|
* Fetch the reward configuration stored in the pool's hook contract.
|
|
@@ -33052,34 +33570,54 @@ var ClService = class _ClService {
|
|
|
33052
33570
|
* `dstChainTxHash` (hub) once the packet has been confirmed.
|
|
33053
33571
|
*/
|
|
33054
33572
|
async claimRewards(_params) {
|
|
33055
|
-
|
|
33056
|
-
|
|
33057
|
-
|
|
33058
|
-
|
|
33059
|
-
|
|
33060
|
-
|
|
33061
|
-
|
|
33062
|
-
|
|
33063
|
-
|
|
33064
|
-
|
|
33065
|
-
|
|
33066
|
-
|
|
33067
|
-
|
|
33068
|
-
|
|
33069
|
-
|
|
33070
|
-
|
|
33071
|
-
|
|
33072
|
-
|
|
33073
|
-
|
|
33573
|
+
return this.config.analytics.trackResult(
|
|
33574
|
+
"dex",
|
|
33575
|
+
"claimRewards",
|
|
33576
|
+
async () => {
|
|
33577
|
+
const { params, timeout } = _params;
|
|
33578
|
+
try {
|
|
33579
|
+
const txResult = await this.executeClaimRewards(_params);
|
|
33580
|
+
if (!txResult.ok) {
|
|
33581
|
+
return txResult;
|
|
33582
|
+
}
|
|
33583
|
+
let hubTxHash;
|
|
33584
|
+
if (!isHubChainKeyType(params.srcChainKey)) {
|
|
33585
|
+
const packetResult = await relayTxAndWaitPacket({
|
|
33586
|
+
srcTxHash: txResult.value.tx,
|
|
33587
|
+
data: txResult.value.relayData,
|
|
33588
|
+
chainKey: params.srcChainKey,
|
|
33589
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
33590
|
+
timeout
|
|
33591
|
+
});
|
|
33592
|
+
if (!packetResult.ok) return packetResult;
|
|
33593
|
+
hubTxHash = packetResult.value.dst_tx_hash;
|
|
33594
|
+
} else {
|
|
33595
|
+
hubTxHash = txResult.value.tx;
|
|
33596
|
+
}
|
|
33597
|
+
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: hubTxHash } };
|
|
33598
|
+
} catch (error) {
|
|
33599
|
+
this.config.logger.error("claimRewards error", error);
|
|
33600
|
+
return {
|
|
33601
|
+
ok: false,
|
|
33602
|
+
error
|
|
33603
|
+
};
|
|
33604
|
+
}
|
|
33605
|
+
},
|
|
33606
|
+
{
|
|
33607
|
+
start: () => ({
|
|
33608
|
+
srcChainKey: _params.params.srcChainKey,
|
|
33609
|
+
srcAddress: _params.params.srcAddress,
|
|
33610
|
+
currency0: _params.params.poolKey.currency0,
|
|
33611
|
+
currency1: _params.params.poolKey.currency1,
|
|
33612
|
+
fee: _params.params.poolKey.fee,
|
|
33613
|
+
tokenId: _params.params.tokenId,
|
|
33614
|
+
tickLower: _params.params.tickLower,
|
|
33615
|
+
tickUpper: _params.params.tickUpper
|
|
33616
|
+
}),
|
|
33617
|
+
success: (value) => ({ srcChainTxHash: value.srcChainTxHash, dstChainTxHash: value.dstChainTxHash }),
|
|
33618
|
+
failure: (error) => ({ code: isSodaxError(error) ? error.code : void 0 })
|
|
33074
33619
|
}
|
|
33075
|
-
|
|
33076
|
-
} catch (error) {
|
|
33077
|
-
this.config.logger.error("claimRewards error", error);
|
|
33078
|
-
return {
|
|
33079
|
-
ok: false,
|
|
33080
|
-
error
|
|
33081
|
-
};
|
|
33082
|
-
}
|
|
33620
|
+
);
|
|
33083
33621
|
}
|
|
33084
33622
|
/**
|
|
33085
33623
|
* Return the list of configured concentrated-liquidity pool keys for the SODAX DEX.
|
|
@@ -36002,50 +36540,68 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
36002
36540
|
* @returns A pair of transaction hashes — `srcChainTxHash` (spoke) and `dstChainTxHash` (hub).
|
|
36003
36541
|
*/
|
|
36004
36542
|
async supply(_params) {
|
|
36005
|
-
|
|
36006
|
-
|
|
36007
|
-
|
|
36008
|
-
|
|
36009
|
-
|
|
36010
|
-
|
|
36011
|
-
|
|
36012
|
-
|
|
36013
|
-
|
|
36014
|
-
ok: false,
|
|
36015
|
-
|
|
36016
|
-
|
|
36017
|
-
|
|
36018
|
-
|
|
36019
|
-
|
|
36020
|
-
|
|
36021
|
-
|
|
36022
|
-
|
|
36543
|
+
return this.config.analytics.trackResult(
|
|
36544
|
+
"moneyMarket",
|
|
36545
|
+
"supply",
|
|
36546
|
+
async () => {
|
|
36547
|
+
const { params, timeout = DEFAULT_RELAY_TX_TIMEOUT } = _params;
|
|
36548
|
+
const srcChainKey = params.srcChainKey;
|
|
36549
|
+
const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey, action: "supply" };
|
|
36550
|
+
try {
|
|
36551
|
+
const txResult = await this.createSupplyIntent(_params);
|
|
36552
|
+
if (!txResult.ok) return { ok: false, error: txResult.error };
|
|
36553
|
+
const verify = await this.spoke.verifyTxHash({ txHash: txResult.value.tx, chainKey: srcChainKey });
|
|
36554
|
+
if (!verify.ok) {
|
|
36555
|
+
return {
|
|
36556
|
+
ok: false,
|
|
36557
|
+
error: verifyFailed("moneyMarket", verify.error, baseCtx)
|
|
36558
|
+
};
|
|
36559
|
+
}
|
|
36560
|
+
if (isHubChainKeyType(srcChainKey)) {
|
|
36561
|
+
return {
|
|
36562
|
+
ok: true,
|
|
36563
|
+
value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: txResult.value.tx }
|
|
36564
|
+
};
|
|
36565
|
+
}
|
|
36566
|
+
const packet = await relayTxAndWaitPacket({
|
|
36567
|
+
srcTxHash: txResult.value.tx,
|
|
36568
|
+
data: txResult.value.relayData,
|
|
36569
|
+
chainKey: srcChainKey,
|
|
36570
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
36571
|
+
timeout
|
|
36572
|
+
});
|
|
36573
|
+
if (!packet.ok)
|
|
36574
|
+
return {
|
|
36575
|
+
ok: false,
|
|
36576
|
+
error: mapRelayFailure(packet.error, {
|
|
36577
|
+
feature: "moneyMarket",
|
|
36578
|
+
action: baseCtx.action,
|
|
36579
|
+
srcChainKey: baseCtx.srcChainKey,
|
|
36580
|
+
dstChainKey: baseCtx.dstChainKey
|
|
36581
|
+
})
|
|
36582
|
+
};
|
|
36583
|
+
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: packet.value.dst_tx_hash } };
|
|
36584
|
+
} catch (error) {
|
|
36585
|
+
if (isMoneyMarketOrchestrationError(error)) return { ok: false, error };
|
|
36586
|
+
return {
|
|
36587
|
+
ok: false,
|
|
36588
|
+
error: executionFailed("moneyMarket", error, { ...baseCtx, phase: "intentCreation" })
|
|
36589
|
+
};
|
|
36590
|
+
}
|
|
36591
|
+
},
|
|
36592
|
+
{
|
|
36593
|
+
start: () => ({
|
|
36594
|
+
srcChainKey: _params.params.srcChainKey,
|
|
36595
|
+
srcAddress: _params.params.srcAddress,
|
|
36596
|
+
dstChainKey: _params.params.dstChainKey,
|
|
36597
|
+
dstAddress: _params.params.dstAddress,
|
|
36598
|
+
token: _params.params.token,
|
|
36599
|
+
amount: _params.params.amount
|
|
36600
|
+
}),
|
|
36601
|
+
success: (value) => ({ srcChainTxHash: value.srcChainTxHash, dstChainTxHash: value.dstChainTxHash }),
|
|
36602
|
+
failure: (error) => ({ code: error.code })
|
|
36023
36603
|
}
|
|
36024
|
-
|
|
36025
|
-
srcTxHash: txResult.value.tx,
|
|
36026
|
-
data: txResult.value.relayData,
|
|
36027
|
-
chainKey: srcChainKey,
|
|
36028
|
-
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
36029
|
-
timeout
|
|
36030
|
-
});
|
|
36031
|
-
if (!packet.ok)
|
|
36032
|
-
return {
|
|
36033
|
-
ok: false,
|
|
36034
|
-
error: mapRelayFailure(packet.error, {
|
|
36035
|
-
feature: "moneyMarket",
|
|
36036
|
-
action: baseCtx.action,
|
|
36037
|
-
srcChainKey: baseCtx.srcChainKey,
|
|
36038
|
-
dstChainKey: baseCtx.dstChainKey
|
|
36039
|
-
})
|
|
36040
|
-
};
|
|
36041
|
-
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: packet.value.dst_tx_hash } };
|
|
36042
|
-
} catch (error) {
|
|
36043
|
-
if (isMoneyMarketOrchestrationError(error)) return { ok: false, error };
|
|
36044
|
-
return {
|
|
36045
|
-
ok: false,
|
|
36046
|
-
error: executionFailed("moneyMarket", error, { ...baseCtx, phase: "intentCreation" })
|
|
36047
|
-
};
|
|
36048
|
-
}
|
|
36604
|
+
);
|
|
36049
36605
|
}
|
|
36050
36606
|
/**
|
|
36051
36607
|
* Build and optionally broadcast the spoke-side supply transaction without waiting for the
|
|
@@ -36162,58 +36718,76 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
36162
36718
|
* `dstChainTxHash` (hub delivery or relay destination).
|
|
36163
36719
|
*/
|
|
36164
36720
|
async borrow(_params) {
|
|
36165
|
-
|
|
36166
|
-
|
|
36167
|
-
|
|
36168
|
-
|
|
36169
|
-
|
|
36170
|
-
|
|
36171
|
-
|
|
36172
|
-
|
|
36173
|
-
|
|
36174
|
-
|
|
36175
|
-
ok: false,
|
|
36176
|
-
|
|
36177
|
-
|
|
36178
|
-
|
|
36179
|
-
|
|
36180
|
-
|
|
36181
|
-
|
|
36182
|
-
|
|
36183
|
-
|
|
36184
|
-
|
|
36185
|
-
|
|
36186
|
-
|
|
36187
|
-
|
|
36188
|
-
|
|
36189
|
-
|
|
36190
|
-
|
|
36191
|
-
|
|
36192
|
-
|
|
36193
|
-
|
|
36194
|
-
|
|
36195
|
-
|
|
36196
|
-
|
|
36197
|
-
|
|
36198
|
-
|
|
36199
|
-
|
|
36200
|
-
|
|
36201
|
-
|
|
36202
|
-
|
|
36203
|
-
|
|
36204
|
-
|
|
36205
|
-
|
|
36206
|
-
|
|
36207
|
-
|
|
36721
|
+
return this.config.analytics.trackResult(
|
|
36722
|
+
"moneyMarket",
|
|
36723
|
+
"borrow",
|
|
36724
|
+
async () => {
|
|
36725
|
+
const { params, timeout = DEFAULT_RELAY_TX_TIMEOUT } = _params;
|
|
36726
|
+
const srcChainKey = params.srcChainKey;
|
|
36727
|
+
const hubChainId = this.hubProvider.chainConfig.chain.key;
|
|
36728
|
+
const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey, action: "borrow" };
|
|
36729
|
+
try {
|
|
36730
|
+
const txResult = await this.createBorrowIntent(_params);
|
|
36731
|
+
if (!txResult.ok) return { ok: false, error: txResult.error };
|
|
36732
|
+
const verify = await this.spoke.verifyTxHash({ txHash: txResult.value.tx, chainKey: srcChainKey });
|
|
36733
|
+
if (!verify.ok) {
|
|
36734
|
+
return {
|
|
36735
|
+
ok: false,
|
|
36736
|
+
error: verifyFailed("moneyMarket", verify.error, baseCtx)
|
|
36737
|
+
};
|
|
36738
|
+
}
|
|
36739
|
+
const needsRelay = srcChainKey !== hubChainId || params.dstChainKey != null && params.dstAddress != null && params.dstChainKey !== hubChainId;
|
|
36740
|
+
if (!needsRelay) {
|
|
36741
|
+
return {
|
|
36742
|
+
ok: true,
|
|
36743
|
+
value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: txResult.value.tx }
|
|
36744
|
+
};
|
|
36745
|
+
}
|
|
36746
|
+
const relayIdentity = this.buildRelayIdentity(srcChainKey, txResult.value.tx, txResult.value.relayData);
|
|
36747
|
+
const packet = await relayTxAndWaitPacket({
|
|
36748
|
+
...relayIdentity,
|
|
36749
|
+
chainKey: srcChainKey,
|
|
36750
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
36751
|
+
timeout
|
|
36752
|
+
});
|
|
36753
|
+
if (!packet.ok)
|
|
36754
|
+
return {
|
|
36755
|
+
ok: false,
|
|
36756
|
+
error: mapRelayFailure(packet.error, {
|
|
36757
|
+
feature: "moneyMarket",
|
|
36758
|
+
action: baseCtx.action,
|
|
36759
|
+
srcChainKey: baseCtx.srcChainKey,
|
|
36760
|
+
dstChainKey: baseCtx.dstChainKey
|
|
36761
|
+
})
|
|
36762
|
+
};
|
|
36763
|
+
return {
|
|
36764
|
+
ok: true,
|
|
36765
|
+
value: {
|
|
36766
|
+
srcChainTxHash: relayIdentity.pollTxHash ?? txResult.value.tx,
|
|
36767
|
+
dstChainTxHash: packet.value.dst_tx_hash
|
|
36768
|
+
}
|
|
36769
|
+
};
|
|
36770
|
+
} catch (error) {
|
|
36771
|
+
if (isMoneyMarketOrchestrationError(error)) return { ok: false, error };
|
|
36772
|
+
return {
|
|
36773
|
+
ok: false,
|
|
36774
|
+
error: executionFailed("moneyMarket", error, { ...baseCtx, phase: "intentCreation" })
|
|
36775
|
+
};
|
|
36208
36776
|
}
|
|
36209
|
-
}
|
|
36210
|
-
|
|
36211
|
-
|
|
36212
|
-
|
|
36213
|
-
|
|
36214
|
-
|
|
36215
|
-
|
|
36216
|
-
|
|
36777
|
+
},
|
|
36778
|
+
{
|
|
36779
|
+
start: () => ({
|
|
36780
|
+
srcChainKey: _params.params.srcChainKey,
|
|
36781
|
+
srcAddress: _params.params.srcAddress,
|
|
36782
|
+
dstChainKey: _params.params.dstChainKey,
|
|
36783
|
+
dstAddress: _params.params.dstAddress,
|
|
36784
|
+
token: _params.params.token,
|
|
36785
|
+
amount: _params.params.amount
|
|
36786
|
+
}),
|
|
36787
|
+
success: (value) => ({ srcChainTxHash: value.srcChainTxHash, dstChainTxHash: value.dstChainTxHash }),
|
|
36788
|
+
failure: (error) => ({ code: error.code })
|
|
36789
|
+
}
|
|
36790
|
+
);
|
|
36217
36791
|
}
|
|
36218
36792
|
/**
|
|
36219
36793
|
* Build and optionally broadcast the spoke-side borrow message without waiting for the
|
|
@@ -36311,59 +36885,77 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
36311
36885
|
* `dstChainTxHash` (hub or relay destination).
|
|
36312
36886
|
*/
|
|
36313
36887
|
async withdraw(_params) {
|
|
36314
|
-
|
|
36315
|
-
|
|
36316
|
-
|
|
36317
|
-
|
|
36318
|
-
|
|
36319
|
-
|
|
36320
|
-
|
|
36321
|
-
|
|
36322
|
-
|
|
36323
|
-
|
|
36324
|
-
|
|
36325
|
-
ok: false,
|
|
36326
|
-
|
|
36327
|
-
|
|
36328
|
-
|
|
36329
|
-
|
|
36330
|
-
|
|
36331
|
-
|
|
36332
|
-
|
|
36333
|
-
|
|
36334
|
-
|
|
36335
|
-
|
|
36336
|
-
|
|
36337
|
-
|
|
36338
|
-
|
|
36339
|
-
|
|
36340
|
-
|
|
36341
|
-
|
|
36342
|
-
|
|
36343
|
-
|
|
36344
|
-
|
|
36345
|
-
|
|
36346
|
-
|
|
36347
|
-
|
|
36348
|
-
|
|
36349
|
-
|
|
36350
|
-
|
|
36351
|
-
|
|
36352
|
-
|
|
36353
|
-
|
|
36354
|
-
|
|
36355
|
-
|
|
36356
|
-
|
|
36357
|
-
|
|
36888
|
+
return this.config.analytics.trackResult(
|
|
36889
|
+
"moneyMarket",
|
|
36890
|
+
"withdraw",
|
|
36891
|
+
async () => {
|
|
36892
|
+
const { params, timeout = DEFAULT_RELAY_TX_TIMEOUT } = _params;
|
|
36893
|
+
const srcChainKey = params.srcChainKey;
|
|
36894
|
+
const hubChainId = this.hubProvider.chainConfig.chain.key;
|
|
36895
|
+
const walletRouter = this.hubProvider.chainConfig.addresses.walletRouter;
|
|
36896
|
+
const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey, action: "withdraw" };
|
|
36897
|
+
try {
|
|
36898
|
+
const txResult = await this.createWithdrawIntent(_params);
|
|
36899
|
+
if (!txResult.ok) return { ok: false, error: txResult.error };
|
|
36900
|
+
const verify = await this.spoke.verifyTxHash({ txHash: txResult.value.tx, chainKey: srcChainKey });
|
|
36901
|
+
if (!verify.ok) {
|
|
36902
|
+
return {
|
|
36903
|
+
ok: false,
|
|
36904
|
+
error: verifyFailed("moneyMarket", verify.error, baseCtx)
|
|
36905
|
+
};
|
|
36906
|
+
}
|
|
36907
|
+
const needsRelay = srcChainKey !== hubChainId || params.dstChainKey != null && params.dstAddress != null && params.dstChainKey !== hubChainId && params.dstAddress !== walletRouter;
|
|
36908
|
+
if (!needsRelay) {
|
|
36909
|
+
return {
|
|
36910
|
+
ok: true,
|
|
36911
|
+
value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: txResult.value.tx }
|
|
36912
|
+
};
|
|
36913
|
+
}
|
|
36914
|
+
const relayIdentity = this.buildRelayIdentity(srcChainKey, txResult.value.tx, txResult.value.relayData);
|
|
36915
|
+
const packet = await relayTxAndWaitPacket({
|
|
36916
|
+
...relayIdentity,
|
|
36917
|
+
chainKey: srcChainKey,
|
|
36918
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
36919
|
+
timeout
|
|
36920
|
+
});
|
|
36921
|
+
if (!packet.ok)
|
|
36922
|
+
return {
|
|
36923
|
+
ok: false,
|
|
36924
|
+
error: mapRelayFailure(packet.error, {
|
|
36925
|
+
feature: "moneyMarket",
|
|
36926
|
+
action: baseCtx.action,
|
|
36927
|
+
srcChainKey: baseCtx.srcChainKey,
|
|
36928
|
+
dstChainKey: baseCtx.dstChainKey
|
|
36929
|
+
})
|
|
36930
|
+
};
|
|
36931
|
+
return {
|
|
36932
|
+
ok: true,
|
|
36933
|
+
value: {
|
|
36934
|
+
srcChainTxHash: relayIdentity.pollTxHash ?? txResult.value.tx,
|
|
36935
|
+
dstChainTxHash: packet.value.dst_tx_hash
|
|
36936
|
+
}
|
|
36937
|
+
};
|
|
36938
|
+
} catch (error) {
|
|
36939
|
+
if (isMoneyMarketOrchestrationError(error)) return { ok: false, error };
|
|
36940
|
+
return {
|
|
36941
|
+
ok: false,
|
|
36942
|
+
error: executionFailed("moneyMarket", error, { ...baseCtx, phase: "intentCreation" })
|
|
36943
|
+
};
|
|
36358
36944
|
}
|
|
36359
|
-
}
|
|
36360
|
-
|
|
36361
|
-
|
|
36362
|
-
|
|
36363
|
-
|
|
36364
|
-
|
|
36365
|
-
|
|
36366
|
-
|
|
36945
|
+
},
|
|
36946
|
+
{
|
|
36947
|
+
start: () => ({
|
|
36948
|
+
srcChainKey: _params.params.srcChainKey,
|
|
36949
|
+
srcAddress: _params.params.srcAddress,
|
|
36950
|
+
dstChainKey: _params.params.dstChainKey,
|
|
36951
|
+
dstAddress: _params.params.dstAddress,
|
|
36952
|
+
token: _params.params.token,
|
|
36953
|
+
amount: _params.params.amount
|
|
36954
|
+
}),
|
|
36955
|
+
success: (value) => ({ srcChainTxHash: value.srcChainTxHash, dstChainTxHash: value.dstChainTxHash }),
|
|
36956
|
+
failure: (error) => ({ code: error.code })
|
|
36957
|
+
}
|
|
36958
|
+
);
|
|
36367
36959
|
}
|
|
36368
36960
|
/**
|
|
36369
36961
|
* Build and optionally broadcast the spoke-side withdraw message without waiting for the
|
|
@@ -36459,50 +37051,68 @@ var MoneyMarketService = class _MoneyMarketService {
|
|
|
36459
37051
|
* @returns A pair of transaction hashes — `srcChainTxHash` (spoke) and `dstChainTxHash` (hub).
|
|
36460
37052
|
*/
|
|
36461
37053
|
async repay(_params) {
|
|
36462
|
-
|
|
36463
|
-
|
|
36464
|
-
|
|
36465
|
-
|
|
36466
|
-
|
|
36467
|
-
|
|
36468
|
-
|
|
36469
|
-
|
|
36470
|
-
|
|
36471
|
-
ok: false,
|
|
36472
|
-
|
|
36473
|
-
|
|
36474
|
-
|
|
36475
|
-
|
|
36476
|
-
|
|
36477
|
-
|
|
36478
|
-
|
|
36479
|
-
|
|
37054
|
+
return this.config.analytics.trackResult(
|
|
37055
|
+
"moneyMarket",
|
|
37056
|
+
"repay",
|
|
37057
|
+
async () => {
|
|
37058
|
+
const { params, timeout = DEFAULT_RELAY_TX_TIMEOUT } = _params;
|
|
37059
|
+
const srcChainKey = params.srcChainKey;
|
|
37060
|
+
const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey, action: "repay" };
|
|
37061
|
+
try {
|
|
37062
|
+
const txResult = await this.createRepayIntent(_params);
|
|
37063
|
+
if (!txResult.ok) return { ok: false, error: txResult.error };
|
|
37064
|
+
const verify = await this.spoke.verifyTxHash({ txHash: txResult.value.tx, chainKey: srcChainKey });
|
|
37065
|
+
if (!verify.ok) {
|
|
37066
|
+
return {
|
|
37067
|
+
ok: false,
|
|
37068
|
+
error: verifyFailed("moneyMarket", verify.error, baseCtx)
|
|
37069
|
+
};
|
|
37070
|
+
}
|
|
37071
|
+
if (isHubChainKeyType(srcChainKey)) {
|
|
37072
|
+
return {
|
|
37073
|
+
ok: true,
|
|
37074
|
+
value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: txResult.value.tx }
|
|
37075
|
+
};
|
|
37076
|
+
}
|
|
37077
|
+
const packet = await relayTxAndWaitPacket({
|
|
37078
|
+
srcTxHash: txResult.value.tx,
|
|
37079
|
+
data: txResult.value.relayData,
|
|
37080
|
+
chainKey: srcChainKey,
|
|
37081
|
+
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
37082
|
+
timeout
|
|
37083
|
+
});
|
|
37084
|
+
if (!packet.ok)
|
|
37085
|
+
return {
|
|
37086
|
+
ok: false,
|
|
37087
|
+
error: mapRelayFailure(packet.error, {
|
|
37088
|
+
feature: "moneyMarket",
|
|
37089
|
+
action: baseCtx.action,
|
|
37090
|
+
srcChainKey: baseCtx.srcChainKey,
|
|
37091
|
+
dstChainKey: baseCtx.dstChainKey
|
|
37092
|
+
})
|
|
37093
|
+
};
|
|
37094
|
+
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: packet.value.dst_tx_hash } };
|
|
37095
|
+
} catch (error) {
|
|
37096
|
+
if (isMoneyMarketOrchestrationError(error)) return { ok: false, error };
|
|
37097
|
+
return {
|
|
37098
|
+
ok: false,
|
|
37099
|
+
error: executionFailed("moneyMarket", error, { ...baseCtx, phase: "intentCreation" })
|
|
37100
|
+
};
|
|
37101
|
+
}
|
|
37102
|
+
},
|
|
37103
|
+
{
|
|
37104
|
+
start: () => ({
|
|
37105
|
+
srcChainKey: _params.params.srcChainKey,
|
|
37106
|
+
srcAddress: _params.params.srcAddress,
|
|
37107
|
+
dstChainKey: _params.params.dstChainKey,
|
|
37108
|
+
dstAddress: _params.params.dstAddress,
|
|
37109
|
+
token: _params.params.token,
|
|
37110
|
+
amount: _params.params.amount
|
|
37111
|
+
}),
|
|
37112
|
+
success: (value) => ({ srcChainTxHash: value.srcChainTxHash, dstChainTxHash: value.dstChainTxHash }),
|
|
37113
|
+
failure: (error) => ({ code: error.code })
|
|
36480
37114
|
}
|
|
36481
|
-
|
|
36482
|
-
srcTxHash: txResult.value.tx,
|
|
36483
|
-
data: txResult.value.relayData,
|
|
36484
|
-
chainKey: srcChainKey,
|
|
36485
|
-
relayerApiEndpoint: this.relayerApiEndpoint,
|
|
36486
|
-
timeout
|
|
36487
|
-
});
|
|
36488
|
-
if (!packet.ok)
|
|
36489
|
-
return {
|
|
36490
|
-
ok: false,
|
|
36491
|
-
error: mapRelayFailure(packet.error, {
|
|
36492
|
-
feature: "moneyMarket",
|
|
36493
|
-
action: baseCtx.action,
|
|
36494
|
-
srcChainKey: baseCtx.srcChainKey,
|
|
36495
|
-
dstChainKey: baseCtx.dstChainKey
|
|
36496
|
-
})
|
|
36497
|
-
};
|
|
36498
|
-
return { ok: true, value: { srcChainTxHash: txResult.value.tx, dstChainTxHash: packet.value.dst_tx_hash } };
|
|
36499
|
-
} catch (error) {
|
|
36500
|
-
if (isMoneyMarketOrchestrationError(error)) return { ok: false, error };
|
|
36501
|
-
return {
|
|
36502
|
-
ok: false,
|
|
36503
|
-
error: executionFailed("moneyMarket", error, { ...baseCtx, phase: "intentCreation" })
|
|
36504
|
-
};
|
|
36505
|
-
}
|
|
37115
|
+
);
|
|
36506
37116
|
}
|
|
36507
37117
|
/**
|
|
36508
37118
|
* Build and optionally broadcast the spoke-side repay transaction without waiting for the
|
|
@@ -37203,50 +37813,67 @@ var PartnerFeeClaimService = class {
|
|
|
37203
37813
|
* unsigned raw transaction (`raw: true`). Returns an error on failure.
|
|
37204
37814
|
*/
|
|
37205
37815
|
async setSwapPreference(_params) {
|
|
37206
|
-
|
|
37207
|
-
|
|
37208
|
-
|
|
37209
|
-
|
|
37210
|
-
|
|
37211
|
-
|
|
37212
|
-
|
|
37213
|
-
|
|
37214
|
-
|
|
37215
|
-
|
|
37216
|
-
from: params.srcAddress,
|
|
37217
|
-
to: this.protocolIntentsContract,
|
|
37218
|
-
value: 0n,
|
|
37219
|
-
data: viem.encodeFunctionData({
|
|
37220
|
-
abi: ProtocolIntentsAbi,
|
|
37221
|
-
functionName: "setAutoSwapPreferences",
|
|
37222
|
-
args: [
|
|
37816
|
+
return this.config.analytics.trackResult(
|
|
37817
|
+
"partner",
|
|
37818
|
+
"setSwapPreference",
|
|
37819
|
+
async () => {
|
|
37820
|
+
const { params, walletProvider, raw } = _params;
|
|
37821
|
+
try {
|
|
37822
|
+
invariant(isHubChainKeyType(params.srcChainKey), "PartnerFeeClaimService only supports Sonic spoke provider");
|
|
37823
|
+
invariant(this.protocolIntentsContract, "protocolIntentsContract is not configured in solver config");
|
|
37824
|
+
const outputToken = params.dstChainKey !== this.hubProvider.chainConfig.chain.key ? this.hubProvider.config.getSpokeTokenFromOriginalAssetAddress(params.dstChainKey, params.outputToken)?.hubAsset : params.outputToken;
|
|
37825
|
+
invariant(
|
|
37223
37826
|
outputToken,
|
|
37224
|
-
|
|
37225
|
-
|
|
37226
|
-
|
|
37227
|
-
|
|
37228
|
-
|
|
37229
|
-
|
|
37230
|
-
|
|
37231
|
-
|
|
37232
|
-
|
|
37233
|
-
|
|
37827
|
+
`hub asset not found for spoke chain token (params.outputToken): ${params.outputToken} with chain key: ${params.dstChainKey}`
|
|
37828
|
+
);
|
|
37829
|
+
const rawTx = {
|
|
37830
|
+
from: params.srcAddress,
|
|
37831
|
+
to: this.protocolIntentsContract,
|
|
37832
|
+
value: 0n,
|
|
37833
|
+
data: viem.encodeFunctionData({
|
|
37834
|
+
abi: ProtocolIntentsAbi,
|
|
37835
|
+
functionName: "setAutoSwapPreferences",
|
|
37836
|
+
args: [
|
|
37837
|
+
outputToken,
|
|
37838
|
+
BigInt(getIntentRelayChainId(params.dstChainKey)),
|
|
37839
|
+
encodeAddress(params.dstChainKey, params.dstAddress)
|
|
37840
|
+
]
|
|
37841
|
+
})
|
|
37842
|
+
};
|
|
37843
|
+
if (raw) {
|
|
37844
|
+
return {
|
|
37845
|
+
ok: true,
|
|
37846
|
+
value: rawTx
|
|
37847
|
+
};
|
|
37848
|
+
}
|
|
37849
|
+
invariant(
|
|
37850
|
+
isEvmWalletProviderType(walletProvider),
|
|
37851
|
+
"PartnerFeeClaimService only supports Evm (sonic) wallet provider"
|
|
37852
|
+
);
|
|
37853
|
+
const txHash = await walletProvider.sendTransaction(rawTx);
|
|
37854
|
+
return {
|
|
37855
|
+
ok: true,
|
|
37856
|
+
value: txHash
|
|
37857
|
+
};
|
|
37858
|
+
} catch (error) {
|
|
37859
|
+
return {
|
|
37860
|
+
ok: false,
|
|
37861
|
+
error
|
|
37862
|
+
};
|
|
37863
|
+
}
|
|
37864
|
+
},
|
|
37865
|
+
{
|
|
37866
|
+
start: () => ({
|
|
37867
|
+
srcChainKey: _params.params.srcChainKey,
|
|
37868
|
+
srcAddress: _params.params.srcAddress,
|
|
37869
|
+
outputToken: _params.params.outputToken,
|
|
37870
|
+
dstChainKey: _params.params.dstChainKey,
|
|
37871
|
+
dstAddress: _params.params.dstAddress
|
|
37872
|
+
}),
|
|
37873
|
+
success: (value) => ({ txHash: value }),
|
|
37874
|
+
failure: (error) => ({ code: isSodaxError(error) ? error.code : void 0 })
|
|
37234
37875
|
}
|
|
37235
|
-
|
|
37236
|
-
isEvmWalletProviderType(walletProvider),
|
|
37237
|
-
"PartnerFeeClaimService only supports Evm (sonic) wallet provider"
|
|
37238
|
-
);
|
|
37239
|
-
const txHash = await walletProvider.sendTransaction(rawTx);
|
|
37240
|
-
return {
|
|
37241
|
-
ok: true,
|
|
37242
|
-
value: txHash
|
|
37243
|
-
};
|
|
37244
|
-
} catch (error) {
|
|
37245
|
-
return {
|
|
37246
|
-
ok: false,
|
|
37247
|
-
error
|
|
37248
|
-
};
|
|
37249
|
-
}
|
|
37876
|
+
);
|
|
37250
37877
|
}
|
|
37251
37878
|
/**
|
|
37252
37879
|
* Checks whether a hub-chain ERC-20 token is already approved for the ProtocolIntents contract.
|
|
@@ -37358,6 +37985,11 @@ var PartnerFeeClaimService = class {
|
|
|
37358
37985
|
* This is the low-level building block. Use `swap` for the full flow that also waits for
|
|
37359
37986
|
* the solver to execute the intent.
|
|
37360
37987
|
*
|
|
37988
|
+
* Guards against same-token intents: if the configured output token equals `fromToken` the solver
|
|
37989
|
+
* cannot fill the swap, so the call is rejected with `VALIDATION_FAILED` before any transaction is
|
|
37990
|
+
* built. The guard fails closed — if the preference lookup fails the call returns that error rather
|
|
37991
|
+
* than submitting an intent that may become unfillable.
|
|
37992
|
+
*
|
|
37361
37993
|
* @param _params - Action descriptor containing:
|
|
37362
37994
|
* - `params.srcChainKey` — must be the hub chain key (Sonic).
|
|
37363
37995
|
* - `params.srcAddress` — partner's EVM address; also used as the intent creator.
|
|
@@ -37381,6 +38013,25 @@ var PartnerFeeClaimService = class {
|
|
|
37381
38013
|
this.config.solver.protocolIntentsContract,
|
|
37382
38014
|
"protocolIntentsContract is not configured in solver config"
|
|
37383
38015
|
);
|
|
38016
|
+
const prefs = await this.getAutoSwapPreferences(params.srcAddress);
|
|
38017
|
+
if (!prefs.ok) return prefs;
|
|
38018
|
+
if (prefs.value.outputToken.toLowerCase() === params.fromToken.toLowerCase()) {
|
|
38019
|
+
return {
|
|
38020
|
+
ok: false,
|
|
38021
|
+
error: new SodaxError(
|
|
38022
|
+
"VALIDATION_FAILED",
|
|
38023
|
+
"Auto-swap output token equals the fee token; the solver cannot swap a token into itself. Withdraw the fee token directly (bridge/transfer) or change the swap preference before claiming.",
|
|
38024
|
+
{
|
|
38025
|
+
feature: "partner",
|
|
38026
|
+
context: {
|
|
38027
|
+
action: "createIntentAutoSwap",
|
|
38028
|
+
fromToken: params.fromToken,
|
|
38029
|
+
outputToken: prefs.value.outputToken
|
|
38030
|
+
}
|
|
38031
|
+
}
|
|
38032
|
+
)
|
|
38033
|
+
};
|
|
38034
|
+
}
|
|
37384
38035
|
const minOutputAmount = 0n;
|
|
37385
38036
|
const rawTx = {
|
|
37386
38037
|
from: params.srcAddress,
|
|
@@ -37428,47 +38079,218 @@ var PartnerFeeClaimService = class {
|
|
|
37428
38079
|
*
|
|
37429
38080
|
* On failure the `error` is tagged:
|
|
37430
38081
|
* - `WAIT_INTENT_AUTO_SWAP_FAILED` — transaction was submitted but receipt polling failed.
|
|
37431
|
-
* - Error from `createIntentAutoSwap` — if the initial submission failed
|
|
38082
|
+
* - Error from `createIntentAutoSwap` — if the initial submission failed, including
|
|
38083
|
+
* `VALIDATION_FAILED` when the output token equals the fee token (same-token guard) or the
|
|
38084
|
+
* preference lookup that backs the guard fails.
|
|
37432
38085
|
* - Error from `SolverApiService.postExecution` — if the solver notification failed.
|
|
37433
38086
|
*/
|
|
37434
38087
|
async swap(_params) {
|
|
37435
|
-
|
|
37436
|
-
|
|
37437
|
-
|
|
37438
|
-
|
|
38088
|
+
return this.config.analytics.trackResult(
|
|
38089
|
+
"partner",
|
|
38090
|
+
"swap",
|
|
38091
|
+
async () => {
|
|
38092
|
+
try {
|
|
38093
|
+
const txHash = await this.createIntentAutoSwap(_params);
|
|
38094
|
+
if (!txHash.ok) {
|
|
38095
|
+
return txHash;
|
|
38096
|
+
}
|
|
38097
|
+
let intentTxHash;
|
|
38098
|
+
try {
|
|
38099
|
+
const receipt = await this.hubProvider.publicClient.waitForTransactionReceipt({ hash: txHash.value });
|
|
38100
|
+
intentTxHash = receipt.transactionHash;
|
|
38101
|
+
} catch (error) {
|
|
38102
|
+
return {
|
|
38103
|
+
ok: false,
|
|
38104
|
+
error: new SodaxError(
|
|
38105
|
+
"EXECUTION_FAILED",
|
|
38106
|
+
error instanceof Error ? error.message : "waitIntentAutoSwap failed",
|
|
38107
|
+
{ feature: "partner", cause: error, context: { action: "waitAutoSwap", phase: "execution" } }
|
|
38108
|
+
)
|
|
38109
|
+
};
|
|
38110
|
+
}
|
|
38111
|
+
const solverExecutionResponse = await SolverApiService.postExecution(
|
|
38112
|
+
{ intent_tx_hash: intentTxHash },
|
|
38113
|
+
this.config.solver,
|
|
38114
|
+
this.config.logger
|
|
38115
|
+
);
|
|
38116
|
+
if (!solverExecutionResponse.ok) {
|
|
38117
|
+
return solverExecutionResponse;
|
|
38118
|
+
}
|
|
38119
|
+
return {
|
|
38120
|
+
ok: true,
|
|
38121
|
+
value: {
|
|
38122
|
+
srcTxHash: txHash.value,
|
|
38123
|
+
solverExecutionResponse: solverExecutionResponse.value,
|
|
38124
|
+
intentTxHash
|
|
38125
|
+
}
|
|
38126
|
+
};
|
|
38127
|
+
} catch (error) {
|
|
38128
|
+
return { ok: false, error };
|
|
38129
|
+
}
|
|
38130
|
+
},
|
|
38131
|
+
{
|
|
38132
|
+
start: () => ({
|
|
38133
|
+
srcChainKey: _params.params.srcChainKey,
|
|
38134
|
+
srcAddress: _params.params.srcAddress,
|
|
38135
|
+
fromToken: _params.params.fromToken,
|
|
38136
|
+
amount: _params.params.amount
|
|
38137
|
+
}),
|
|
38138
|
+
success: (value) => ({
|
|
38139
|
+
srcTxHash: value.srcTxHash,
|
|
38140
|
+
intentTxHash: value.intentTxHash
|
|
38141
|
+
}),
|
|
38142
|
+
failure: (error) => ({ code: isSodaxError(error) ? error.code : void 0 })
|
|
37439
38143
|
}
|
|
37440
|
-
|
|
37441
|
-
|
|
37442
|
-
|
|
37443
|
-
|
|
37444
|
-
|
|
38144
|
+
);
|
|
38145
|
+
}
|
|
38146
|
+
/**
|
|
38147
|
+
* Cancels a partner fee-claim auto-swap intent and refunds the input token to the partner.
|
|
38148
|
+
*
|
|
38149
|
+
* This targets the ProtocolIntents contract's own `cancelIntent(fromToken, toToken)`, which is
|
|
38150
|
+
* the only authorized cancel path for partner auto-swap intents: the intent's `creator` is the
|
|
38151
|
+
* ProtocolIntents contract (not the partner), so the generic `SwapService.cancelIntent` reverts
|
|
38152
|
+
* with `Unauthorized()`. ProtocolIntents looks up the caller's intent for the token pair, cancels
|
|
38153
|
+
* it in the main intents contract (as the creator), and transfers the locked `inputAmount` back
|
|
38154
|
+
* to the partner (`msg.sender`).
|
|
38155
|
+
*
|
|
38156
|
+
* Use this to recover funds stuck in an unfillable intent — most commonly a same-token claim
|
|
38157
|
+
* (`fromToken === toToken`) the solver refused to fill (see the guard in {@link swap}).
|
|
38158
|
+
*
|
|
38159
|
+
* @param _params - Action descriptor containing:
|
|
38160
|
+
* - `params.srcChainKey` — must be the hub chain key (Sonic).
|
|
38161
|
+
* - `params.srcAddress` — the partner's EVM address; must match the intent's owner.
|
|
38162
|
+
* - `params.fromToken` — the stuck intent's input (fee) token, hub-chain address.
|
|
38163
|
+
* - `params.toToken` — the stuck intent's output token, hub-chain address.
|
|
38164
|
+
* - `raw` — when `true`, returns the unsigned transaction object instead of submitting it.
|
|
38165
|
+
* - `walletProvider` — required when `raw` is `false`; must be an EVM wallet provider.
|
|
38166
|
+
* @returns A `Result` containing the submitted transaction hash (`raw: false`) or the unsigned
|
|
38167
|
+
* raw transaction (`raw: true`).
|
|
38168
|
+
*/
|
|
38169
|
+
async cancelIntent(_params) {
|
|
38170
|
+
return this.config.analytics.trackResult(
|
|
38171
|
+
"partner",
|
|
38172
|
+
"cancelIntent",
|
|
38173
|
+
async () => {
|
|
38174
|
+
const { params } = _params;
|
|
38175
|
+
try {
|
|
38176
|
+
invariant(isHubChainKeyType(params.srcChainKey), "PartnerFeeClaimService only supports Hub srcChainKey");
|
|
38177
|
+
invariant(
|
|
38178
|
+
isOptionalEvmWalletProviderType(_params.walletProvider),
|
|
38179
|
+
"PartnerFeeClaimService only supports Evm wallet provider"
|
|
38180
|
+
);
|
|
38181
|
+
invariant(this.protocolIntentsContract, "protocolIntentsContract is not configured in solver config");
|
|
38182
|
+
const rawTx = {
|
|
38183
|
+
from: params.srcAddress,
|
|
38184
|
+
to: this.protocolIntentsContract,
|
|
38185
|
+
value: 0n,
|
|
38186
|
+
data: viem.encodeFunctionData({
|
|
38187
|
+
abi: ProtocolIntentsAbi,
|
|
38188
|
+
functionName: "cancelIntent",
|
|
38189
|
+
args: [params.fromToken, params.toToken]
|
|
38190
|
+
})
|
|
38191
|
+
};
|
|
38192
|
+
if (_params.raw) {
|
|
38193
|
+
return {
|
|
38194
|
+
ok: true,
|
|
38195
|
+
value: rawTx
|
|
38196
|
+
};
|
|
38197
|
+
}
|
|
38198
|
+
const txHash = await _params.walletProvider.sendTransaction(rawTx);
|
|
38199
|
+
return {
|
|
38200
|
+
ok: true,
|
|
38201
|
+
value: txHash
|
|
38202
|
+
};
|
|
38203
|
+
} catch (error) {
|
|
38204
|
+
return { ok: false, error };
|
|
38205
|
+
}
|
|
38206
|
+
},
|
|
38207
|
+
{
|
|
38208
|
+
start: () => ({
|
|
38209
|
+
srcChainKey: _params.params.srcChainKey,
|
|
38210
|
+
srcAddress: _params.params.srcAddress,
|
|
38211
|
+
fromToken: _params.params.fromToken,
|
|
38212
|
+
toToken: _params.params.toToken
|
|
38213
|
+
}),
|
|
38214
|
+
success: (value) => ({ txHash: value }),
|
|
38215
|
+
failure: (error) => ({ code: isSodaxError(error) ? error.code : void 0 })
|
|
38216
|
+
}
|
|
38217
|
+
);
|
|
38218
|
+
}
|
|
38219
|
+
/**
|
|
38220
|
+
* Returns the stored intent hash for a partner's `(user, fromToken, toToken)` token pair.
|
|
38221
|
+
*
|
|
38222
|
+
* A non-zero hash means an auto-swap intent currently exists for that pair (e.g. an unfilled
|
|
38223
|
+
* same-token claim) and can be cancelled via {@link cancelIntent}. A zero hash
|
|
38224
|
+
* (`0x000…0`) means there is no open intent for the pair.
|
|
38225
|
+
*
|
|
38226
|
+
* @param params.user - The partner's EVM address on Sonic.
|
|
38227
|
+
* @param params.fromToken - Input (fee) token, hub-chain address.
|
|
38228
|
+
* @param params.toToken - Output token, hub-chain address.
|
|
38229
|
+
* @returns A `Result` containing the intent hash, or an `Error` tagged `LOOKUP_FAILED`.
|
|
38230
|
+
*/
|
|
38231
|
+
async getUserIntent({ user, fromToken, toToken }) {
|
|
38232
|
+
try {
|
|
38233
|
+
invariant(this.protocolIntentsContract, "protocolIntentsContract is not configured in solver config");
|
|
38234
|
+
const intentHash = await this.hubProvider.publicClient.readContract({
|
|
38235
|
+
address: this.protocolIntentsContract,
|
|
38236
|
+
abi: ProtocolIntentsAbi,
|
|
38237
|
+
functionName: "getUserIntent",
|
|
38238
|
+
args: [user, fromToken, toToken]
|
|
38239
|
+
});
|
|
38240
|
+
return { ok: true, value: intentHash };
|
|
38241
|
+
} catch (error) {
|
|
38242
|
+
return { ok: false, error: lookupFailed("partner", "getUserIntent", error) };
|
|
38243
|
+
}
|
|
38244
|
+
}
|
|
38245
|
+
/**
|
|
38246
|
+
* Reads the full {@link Intent} details for a stored intent hash from the ProtocolIntents contract.
|
|
38247
|
+
*
|
|
38248
|
+
* Useful for displaying a stuck intent before cancelling it — e.g. the locked `inputAmount` and
|
|
38249
|
+
* `inputToken`. Pair with {@link getUserIntent} to resolve the hash from a token pair.
|
|
38250
|
+
*
|
|
38251
|
+
* @param intentHash - The intent hash (from {@link getUserIntent}).
|
|
38252
|
+
* @returns A `Result` containing the `Intent`, or an `Error` tagged `LOOKUP_FAILED`.
|
|
38253
|
+
*/
|
|
38254
|
+
async getIntentDetails(intentHash) {
|
|
38255
|
+
try {
|
|
38256
|
+
invariant(this.protocolIntentsContract, "protocolIntentsContract is not configured in solver config");
|
|
38257
|
+
const intent = await this.hubProvider.publicClient.readContract({
|
|
38258
|
+
address: this.protocolIntentsContract,
|
|
38259
|
+
abi: ProtocolIntentsAbi,
|
|
38260
|
+
functionName: "getIntentDetails",
|
|
38261
|
+
args: [intentHash]
|
|
38262
|
+
});
|
|
38263
|
+
if (!this.config.isValidIntentRelayChainId(intent.srcChain) || !this.config.isValidIntentRelayChainId(intent.dstChain)) {
|
|
37445
38264
|
return {
|
|
37446
38265
|
ok: false,
|
|
37447
|
-
error:
|
|
37448
|
-
"
|
|
37449
|
-
|
|
37450
|
-
|
|
38266
|
+
error: lookupFailed(
|
|
38267
|
+
"partner",
|
|
38268
|
+
"getIntentDetails",
|
|
38269
|
+
new Error(`Invalid intent relay chain id: ${intent.srcChain} or ${intent.dstChain}`)
|
|
37451
38270
|
)
|
|
37452
38271
|
};
|
|
37453
38272
|
}
|
|
37454
|
-
const solverExecutionResponse = await SolverApiService.postExecution(
|
|
37455
|
-
{ intent_tx_hash: intentTxHash },
|
|
37456
|
-
this.config.solver,
|
|
37457
|
-
this.config.logger
|
|
37458
|
-
);
|
|
37459
|
-
if (!solverExecutionResponse.ok) {
|
|
37460
|
-
return solverExecutionResponse;
|
|
37461
|
-
}
|
|
37462
38273
|
return {
|
|
37463
38274
|
ok: true,
|
|
37464
38275
|
value: {
|
|
37465
|
-
|
|
37466
|
-
|
|
37467
|
-
|
|
38276
|
+
intentId: intent.intentId,
|
|
38277
|
+
creator: intent.creator,
|
|
38278
|
+
inputToken: intent.inputToken,
|
|
38279
|
+
outputToken: intent.outputToken,
|
|
38280
|
+
inputAmount: intent.inputAmount,
|
|
38281
|
+
minOutputAmount: intent.minOutputAmount,
|
|
38282
|
+
deadline: intent.deadline,
|
|
38283
|
+
allowPartialFill: intent.allowPartialFill,
|
|
38284
|
+
srcChain: intent.srcChain,
|
|
38285
|
+
dstChain: intent.dstChain,
|
|
38286
|
+
srcAddress: intent.srcAddress,
|
|
38287
|
+
dstAddress: intent.dstAddress,
|
|
38288
|
+
solver: intent.solver,
|
|
38289
|
+
data: intent.data
|
|
37468
38290
|
}
|
|
37469
38291
|
};
|
|
37470
38292
|
} catch (error) {
|
|
37471
|
-
return { ok: false, error };
|
|
38293
|
+
return { ok: false, error: lookupFailed("partner", "getIntentDetails", error) };
|
|
37472
38294
|
}
|
|
37473
38295
|
}
|
|
37474
38296
|
};
|
|
@@ -37603,42 +38425,62 @@ var RecoveryService = class {
|
|
|
37603
38425
|
* transaction object when `raw: true`, or the broadcast transaction hash when `raw: false`.
|
|
37604
38426
|
*/
|
|
37605
38427
|
async withdrawHubAsset(_params) {
|
|
37606
|
-
|
|
37607
|
-
|
|
37608
|
-
|
|
37609
|
-
|
|
37610
|
-
{
|
|
37611
|
-
|
|
37612
|
-
|
|
37613
|
-
|
|
37614
|
-
|
|
37615
|
-
|
|
37616
|
-
|
|
37617
|
-
|
|
37618
|
-
|
|
37619
|
-
|
|
37620
|
-
|
|
37621
|
-
|
|
37622
|
-
|
|
37623
|
-
|
|
37624
|
-
|
|
37625
|
-
|
|
37626
|
-
|
|
37627
|
-
|
|
37628
|
-
|
|
37629
|
-
|
|
37630
|
-
|
|
37631
|
-
|
|
37632
|
-
|
|
37633
|
-
|
|
37634
|
-
|
|
37635
|
-
|
|
37636
|
-
|
|
37637
|
-
|
|
37638
|
-
|
|
37639
|
-
|
|
37640
|
-
|
|
37641
|
-
|
|
38428
|
+
return this.config.analytics.trackResult(
|
|
38429
|
+
"recovery",
|
|
38430
|
+
"withdrawHubAsset",
|
|
38431
|
+
async () => {
|
|
38432
|
+
const { params } = _params;
|
|
38433
|
+
try {
|
|
38434
|
+
const hubWallet = await this.hubProvider.getUserHubWalletAddress(params.srcAddress, params.srcChainKey);
|
|
38435
|
+
const payload = EvmAssetManagerService.withdrawAssetData(
|
|
38436
|
+
{
|
|
38437
|
+
token: params.token,
|
|
38438
|
+
to: encodeAddress(params.srcChainKey, params.srcAddress),
|
|
38439
|
+
amount: params.amount
|
|
38440
|
+
},
|
|
38441
|
+
this.hubProvider,
|
|
38442
|
+
params.srcChainKey
|
|
38443
|
+
);
|
|
38444
|
+
const coreParams = {
|
|
38445
|
+
srcChainKey: params.srcChainKey,
|
|
38446
|
+
srcAddress: params.srcAddress,
|
|
38447
|
+
dstChainKey: this.hubProvider.chainConfig.chain.key,
|
|
38448
|
+
dstAddress: hubWallet,
|
|
38449
|
+
payload
|
|
38450
|
+
};
|
|
38451
|
+
const sendMessageParams = _params.raw ? { ...coreParams, raw: true } : {
|
|
38452
|
+
...coreParams,
|
|
38453
|
+
raw: false,
|
|
38454
|
+
walletProvider: _params.walletProvider
|
|
38455
|
+
};
|
|
38456
|
+
const txResult = await this.spoke.sendMessage(sendMessageParams);
|
|
38457
|
+
if (!txResult.ok) return txResult;
|
|
38458
|
+
return {
|
|
38459
|
+
ok: true,
|
|
38460
|
+
value: txResult.value
|
|
38461
|
+
};
|
|
38462
|
+
} catch (error) {
|
|
38463
|
+
return {
|
|
38464
|
+
ok: false,
|
|
38465
|
+
error: new SodaxError(
|
|
38466
|
+
"EXECUTION_FAILED",
|
|
38467
|
+
error instanceof Error ? error.message : "withdrawHubAsset failed",
|
|
38468
|
+
{ feature: "recovery", cause: error, context: { action: "withdrawHubAsset", phase: "execution" } }
|
|
38469
|
+
)
|
|
38470
|
+
};
|
|
38471
|
+
}
|
|
38472
|
+
},
|
|
38473
|
+
{
|
|
38474
|
+
start: () => ({
|
|
38475
|
+
srcChainKey: _params.params.srcChainKey,
|
|
38476
|
+
srcAddress: _params.params.srcAddress,
|
|
38477
|
+
token: _params.params.token,
|
|
38478
|
+
amount: _params.params.amount
|
|
38479
|
+
}),
|
|
38480
|
+
success: (value) => ({ txHash: typeof value === "string" ? value : void 0 }),
|
|
38481
|
+
failure: (error) => ({ code: isSodaxError(error) ? error.code : void 0 })
|
|
38482
|
+
}
|
|
38483
|
+
);
|
|
37642
38484
|
}
|
|
37643
38485
|
};
|
|
37644
38486
|
|
|
@@ -38098,70 +38940,93 @@ var LeverageYieldService = class {
|
|
|
38098
38940
|
const { params } = _params;
|
|
38099
38941
|
const srcChainKey = params.srcChainKey;
|
|
38100
38942
|
const baseCtx = { srcChainKey, dstChainKey: params.dstChainKey, action: "vaultSwap" };
|
|
38101
|
-
|
|
38102
|
-
|
|
38103
|
-
|
|
38104
|
-
|
|
38105
|
-
|
|
38106
|
-
|
|
38107
|
-
|
|
38108
|
-
|
|
38109
|
-
|
|
38110
|
-
|
|
38111
|
-
|
|
38112
|
-
|
|
38113
|
-
|
|
38114
|
-
|
|
38115
|
-
|
|
38116
|
-
|
|
38117
|
-
|
|
38118
|
-
|
|
38119
|
-
|
|
38120
|
-
|
|
38121
|
-
|
|
38122
|
-
|
|
38123
|
-
|
|
38124
|
-
|
|
38125
|
-
|
|
38126
|
-
|
|
38127
|
-
|
|
38128
|
-
|
|
38129
|
-
|
|
38943
|
+
return this.config.analytics.trackResult(
|
|
38944
|
+
"leverageYield",
|
|
38945
|
+
"vaultSwap",
|
|
38946
|
+
async () => {
|
|
38947
|
+
try {
|
|
38948
|
+
const timeout = _params.timeout;
|
|
38949
|
+
const createIntentResult = await this.createVaultIntent(_params);
|
|
38950
|
+
if (!createIntentResult.ok) {
|
|
38951
|
+
return { ok: false, error: createIntentResult.error };
|
|
38952
|
+
}
|
|
38953
|
+
const { tx: spokeTxHash, intent, relayData } = createIntentResult.value;
|
|
38954
|
+
const verifyTxHashResult = await this.spoke.verifyTxHash({
|
|
38955
|
+
txHash: spokeTxHash,
|
|
38956
|
+
chainKey: srcChainKey
|
|
38957
|
+
});
|
|
38958
|
+
if (!verifyTxHashResult.ok) {
|
|
38959
|
+
return {
|
|
38960
|
+
ok: false,
|
|
38961
|
+
error: verifyFailed("leverageYield", verifyTxHashResult.error, baseCtx)
|
|
38962
|
+
};
|
|
38963
|
+
}
|
|
38964
|
+
let dstIntentTxHash;
|
|
38965
|
+
if (isHubChainKeyType(srcChainKey)) {
|
|
38966
|
+
dstIntentTxHash = spokeTxHash;
|
|
38967
|
+
} else {
|
|
38968
|
+
const packet = await relayTxAndWaitPacket({
|
|
38969
|
+
srcTxHash: spokeTxHash,
|
|
38970
|
+
data: relayData,
|
|
38971
|
+
chainKey: srcChainKey,
|
|
38972
|
+
relayerApiEndpoint: this.config.relay.relayerApiEndpoint,
|
|
38973
|
+
timeout
|
|
38974
|
+
});
|
|
38975
|
+
if (!packet.ok) {
|
|
38976
|
+
return {
|
|
38977
|
+
ok: false,
|
|
38978
|
+
error: mapRelayFailure(packet.error, { feature: "leverageYield", ...baseCtx })
|
|
38979
|
+
};
|
|
38980
|
+
}
|
|
38981
|
+
dstIntentTxHash = packet.value.dst_tx_hash;
|
|
38982
|
+
}
|
|
38983
|
+
const postExecResult = await this.notifySolver({
|
|
38984
|
+
intent_tx_hash: dstIntentTxHash
|
|
38985
|
+
});
|
|
38986
|
+
if (!postExecResult.ok) {
|
|
38987
|
+
return { ok: false, error: postExecResult.error };
|
|
38988
|
+
}
|
|
38989
|
+
return {
|
|
38990
|
+
ok: true,
|
|
38991
|
+
value: {
|
|
38992
|
+
solverExecutionResponse: postExecResult.value,
|
|
38993
|
+
intent,
|
|
38994
|
+
intentDeliveryInfo: {
|
|
38995
|
+
srcChainKey,
|
|
38996
|
+
srcTxHash: spokeTxHash,
|
|
38997
|
+
srcAddress: params.srcAddress,
|
|
38998
|
+
dstChainKey: params.dstChainKey,
|
|
38999
|
+
dstTxHash: dstIntentTxHash,
|
|
39000
|
+
dstAddress: params.dstAddress
|
|
39001
|
+
}
|
|
39002
|
+
}
|
|
39003
|
+
};
|
|
39004
|
+
} catch (error) {
|
|
39005
|
+
if (isLeverageYieldSwapError(error)) return { ok: false, error };
|
|
38130
39006
|
return {
|
|
38131
39007
|
ok: false,
|
|
38132
|
-
error:
|
|
39008
|
+
error: unknownFailed("leverageYield", error, baseCtx)
|
|
38133
39009
|
};
|
|
38134
39010
|
}
|
|
38135
|
-
|
|
38136
|
-
|
|
38137
|
-
|
|
38138
|
-
|
|
38139
|
-
|
|
38140
|
-
|
|
38141
|
-
|
|
39011
|
+
},
|
|
39012
|
+
{
|
|
39013
|
+
start: () => ({
|
|
39014
|
+
srcChainKey: _params.params.srcChainKey,
|
|
39015
|
+
dstChainKey: _params.params.dstChainKey,
|
|
39016
|
+
srcAddress: _params.params.srcAddress,
|
|
39017
|
+
dstAddress: _params.params.dstAddress,
|
|
39018
|
+
inputToken: _params.params.inputToken,
|
|
39019
|
+
outputToken: _params.params.outputToken,
|
|
39020
|
+
inputAmount: _params.params.inputAmount
|
|
39021
|
+
}),
|
|
39022
|
+
success: (value) => ({
|
|
39023
|
+
intentId: value.intent.intentId,
|
|
39024
|
+
srcTxHash: value.intentDeliveryInfo.srcTxHash,
|
|
39025
|
+
dstTxHash: value.intentDeliveryInfo.dstTxHash
|
|
39026
|
+
}),
|
|
39027
|
+
failure: (error) => ({ code: error.code })
|
|
38142
39028
|
}
|
|
38143
|
-
|
|
38144
|
-
ok: true,
|
|
38145
|
-
value: {
|
|
38146
|
-
solverExecutionResponse: postExecResult.value,
|
|
38147
|
-
intent,
|
|
38148
|
-
intentDeliveryInfo: {
|
|
38149
|
-
srcChainKey,
|
|
38150
|
-
srcTxHash: spokeTxHash,
|
|
38151
|
-
srcAddress: params.srcAddress,
|
|
38152
|
-
dstChainKey: params.dstChainKey,
|
|
38153
|
-
dstTxHash: dstIntentTxHash,
|
|
38154
|
-
dstAddress: params.dstAddress
|
|
38155
|
-
}
|
|
38156
|
-
}
|
|
38157
|
-
};
|
|
38158
|
-
} catch (error) {
|
|
38159
|
-
if (isLeverageYieldSwapError(error)) return { ok: false, error };
|
|
38160
|
-
return {
|
|
38161
|
-
ok: false,
|
|
38162
|
-
error: unknownFailed("leverageYield", error, baseCtx)
|
|
38163
|
-
};
|
|
38164
|
-
}
|
|
39029
|
+
);
|
|
38165
39030
|
}
|
|
38166
39031
|
/**
|
|
38167
39032
|
* Notifies the solver that the vault intent landed on the hub, triggering it to fill.
|
|
@@ -38538,6 +39403,7 @@ var Sodax = class {
|
|
|
38538
39403
|
// spoke service enabling spoke chain operations
|
|
38539
39404
|
constructor(options) {
|
|
38540
39405
|
const logger = resolveLogger(options?.logger);
|
|
39406
|
+
const analytics = resolveAnalytics(options?.analytics);
|
|
38541
39407
|
const fee = options?.fee;
|
|
38542
39408
|
this.instanceConfig = options ? mergeSodaxConfig(sodaxConfig, options) : sodaxConfig;
|
|
38543
39409
|
this.backendApi = new BackendApiService(this.instanceConfig.api, logger);
|
|
@@ -38546,6 +39412,7 @@ var Sodax = class {
|
|
|
38546
39412
|
config: this.instanceConfig,
|
|
38547
39413
|
userConfig: options,
|
|
38548
39414
|
logger,
|
|
39415
|
+
analytics,
|
|
38549
39416
|
fee
|
|
38550
39417
|
});
|
|
38551
39418
|
this.hubProvider = new EvmHubProvider({ config: this.config });
|
|
@@ -38983,6 +39850,7 @@ exports.moneyMarketSupportedTokens = moneyMarketSupportedTokens;
|
|
|
38983
39850
|
exports.nativeToUSD = nativeToUSD;
|
|
38984
39851
|
exports.nearSupportedTokens = nearSupportedTokens;
|
|
38985
39852
|
exports.newbnUSDSpokeChainIds = newbnUSDSpokeChainIds;
|
|
39853
|
+
exports.noopAnalytics = noopAnalytics;
|
|
38986
39854
|
exports.normalize = normalize;
|
|
38987
39855
|
exports.normalizeBN = normalizeBN;
|
|
38988
39856
|
exports.normalizePsbtToBase64 = normalizePsbtToBase64;
|
|
@@ -39011,6 +39879,7 @@ exports.relayTxAndWaitPacket = relayTxAndWaitPacket;
|
|
|
39011
39879
|
exports.requestAddress = requestAddress;
|
|
39012
39880
|
exports.requestJsonRpc = requestJsonRpc;
|
|
39013
39881
|
exports.requestSigning = requestSigning;
|
|
39882
|
+
exports.resolveAnalytics = resolveAnalytics;
|
|
39014
39883
|
exports.resolveLogger = resolveLogger;
|
|
39015
39884
|
exports.retry = retry;
|
|
39016
39885
|
exports.reverseEncodeAddress = reverseEncodeAddress;
|