@defuse-protocol/intents-sdk 0.36.2 → 0.37.1
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/README.md +0 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge.cjs +6 -4
- package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge.js +6 -4
- package/dist/src/bridges/direct-bridge/direct-bridge.cjs +8 -5
- package/dist/src/bridges/direct-bridge/direct-bridge.js +8 -5
- package/dist/src/bridges/hot-bridge/hot-bridge.cjs +12 -15
- package/dist/src/bridges/hot-bridge/hot-bridge.js +12 -15
- package/dist/src/bridges/intents-bridge/intents-bridge.cjs +2 -1
- package/dist/src/bridges/intents-bridge/intents-bridge.js +2 -1
- package/dist/src/bridges/omni-bridge/error.cjs +6 -6
- package/dist/src/bridges/omni-bridge/error.d.cts +5 -5
- package/dist/src/bridges/omni-bridge/error.d.ts +5 -5
- package/dist/src/bridges/omni-bridge/error.js +6 -6
- package/dist/src/bridges/omni-bridge/omni-bridge.cjs +20 -11
- package/dist/src/bridges/omni-bridge/omni-bridge.js +21 -12
- package/dist/src/bridges/poa-bridge/poa-bridge.cjs +9 -3
- package/dist/src/bridges/poa-bridge/poa-bridge.js +9 -3
- package/dist/src/lib/estimate-fee.cjs +19 -1
- package/dist/src/lib/estimate-fee.js +18 -1
- package/dist/src/shared-types.d.cts +48 -1
- package/dist/src/shared-types.d.ts +48 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -316,7 +316,6 @@ const feeEstimation = await sdk.estimateWithdrawalFee({
|
|
|
316
316
|
});
|
|
317
317
|
|
|
318
318
|
console.log('Fee amount:', feeEstimation.amount);
|
|
319
|
-
console.log('Quote info:', feeEstimation.quote); // null if fee paid with withdrawn token
|
|
320
319
|
|
|
321
320
|
// Batch fee estimation
|
|
322
321
|
const batchFees = await sdk.estimateWithdrawalFee({
|
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,6 @@ Object.defineProperty(exports, 'BaseError', {
|
|
|
30
30
|
exports.BridgeNameEnum = require_bridge_name_enum.BridgeNameEnum;
|
|
31
31
|
exports.Chains = require_caip2.Chains;
|
|
32
32
|
exports.DestinationExplicitNearAccountDoesntExistError = require_error.DestinationExplicitNearAccountDoesntExistError;
|
|
33
|
-
exports.FailedToFetchFeeError = require_error$2.FailedToFetchFeeError;
|
|
34
33
|
exports.FeeExceedsAmountError = require_errors.FeeExceedsAmountError;
|
|
35
34
|
exports.HotWithdrawalApiFeeRequestTimeoutError = require_error$1.HotWithdrawalApiFeeRequestTimeoutError;
|
|
36
35
|
exports.HotWithdrawalCancelledError = require_error$1.HotWithdrawalCancelledError;
|
|
@@ -51,6 +50,7 @@ Object.defineProperty(exports, 'IntentSettlementError', {
|
|
|
51
50
|
});
|
|
52
51
|
exports.IntentsNearOmniAvailableBalanceTooLowError = require_error$2.IntentsNearOmniAvailableBalanceTooLowError;
|
|
53
52
|
exports.IntentsSDK = require_sdk.IntentsSDK;
|
|
53
|
+
exports.InvalidFeeValueError = require_error$2.InvalidFeeValueError;
|
|
54
54
|
exports.MinWithdrawalAmountError = require_errors.MinWithdrawalAmountError;
|
|
55
55
|
exports.OmniTokenNormalisationCheckError = require_error$2.OmniTokenNormalisationCheckError;
|
|
56
56
|
exports.OmniTransferDestinationChainHashNotFoundError = require_error$2.OmniTransferDestinationChainHashNotFoundError;
|
package/dist/index.d.cts
CHANGED
|
@@ -13,7 +13,7 @@ import { createDefaultRoute, createHotBridgeRoute, createInternalTransferRoute,
|
|
|
13
13
|
import { FeeExceedsAmountError, FeeExceedsAmountErrorType, MinWithdrawalAmountError, MinWithdrawalAmountErrorType, TrustlineNotFoundError, TrustlineNotFoundErrorType, UnsupportedAssetIdError, UnsupportedAssetIdErrorType, UnsupportedDestinationMemoError, UnsupportedDestinationMemoErrorType } from "./src/classes/errors.cjs";
|
|
14
14
|
import { DestinationExplicitNearAccountDoesntExistError, DestinationExplicitNearAccountDoesntExistErrorType } from "./src/bridges/direct-bridge/error.cjs";
|
|
15
15
|
import { HotWithdrawalApiFeeRequestTimeoutError, HotWithdrawalApiFeeRequestTimeoutErrorType, HotWithdrawalCancelledError, HotWithdrawalCancelledErrorType, HotWithdrawalNotFoundError, HotWithdrawalNotFoundErrorType, HotWithdrawalPendingError, HotWithdrawalPendingErrorType } from "./src/bridges/hot-bridge/error.cjs";
|
|
16
|
-
import {
|
|
16
|
+
import { IntentsNearOmniAvailableBalanceTooLowError, IntentsNearOmniAvailableBalanceTooLowErrorType, InvalidFeeValueError, InvalidFeeValueErrorType, OmniTokenNormalisationCheckError, OmniTokenNormalisationCheckErrorType, OmniTransferDestinationChainHashNotFoundError, OmniTransferDestinationChainHashNotFoundErrorType, OmniTransferNotFoundError, OmniTransferNotFoundErrorType, OmniWithdrawalApiFeeRequestTimeoutError, OmniWithdrawalApiFeeRequestTimeoutErrorType, TokenNotFoundInDestinationChainError, TokenNotFoundInDestinationChainErrorType } from "./src/bridges/omni-bridge/error.cjs";
|
|
17
17
|
import { computeIntentHash } from "./src/intents/intent-hash.cjs";
|
|
18
18
|
import { AssertionError, AssertionErrorType, BaseError, BaseErrorType, HttpRequestError, HttpRequestErrorType, ILogger, IntentSettlementError, IntentSettlementErrorType, NearIntentsEnv, PoaWithdrawalInvariantError, PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, PoaWithdrawalPendingErrorType, QuoteError, QuoteErrorType, RelayPublishError, RelayPublishErrorType, RetryOptions, RpcRequestError, RpcRequestErrorType, TimeoutError, TimeoutErrorType } from "@defuse-protocol/internal-utils";
|
|
19
|
-
export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType,
|
|
19
|
+
export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, type FeeEstimation, FeeExceedsAmountError, type FeeExceedsAmountErrorType, type HotBridgeRouteConfig, HotWithdrawalApiFeeRequestTimeoutError, type HotWithdrawalApiFeeRequestTimeoutErrorType, HotWithdrawalCancelledError, type HotWithdrawalCancelledErrorType, HotWithdrawalNotFoundError, type HotWithdrawalNotFoundErrorType, HotWithdrawalPendingError, type HotWithdrawalPendingErrorType, HttpRequestError, type HttpRequestErrorType, type IIntentSigner, type ILogger, type IntentPayload, IntentPayloadBuilder, type IntentPayloadFactory, type IntentPrimitive, type IntentPublishResult, type IntentRelayParamsFactory, IntentSettlementError, type IntentSettlementErrorType, type IntentSettlementStatus, IntentsNearOmniAvailableBalanceTooLowError, type IntentsNearOmniAvailableBalanceTooLowErrorType, IntentsSDK, type IntentsSDKConfig, type InternalTransferRouteConfig, InvalidFeeValueError, type InvalidFeeValueErrorType, MinWithdrawalAmountError, type MinWithdrawalAmountErrorType, type MultiPayload, type NearIntentsEnv, type NearTxInfo, type NearWithdrawalRouteConfig, type OmniBridgeRouteConfig, OmniTokenNormalisationCheckError, type OmniTokenNormalisationCheckErrorType, OmniTransferDestinationChainHashNotFoundError, type OmniTransferDestinationChainHashNotFoundErrorType, OmniTransferNotFoundError, type OmniTransferNotFoundErrorType, OmniWithdrawalApiFeeRequestTimeoutError, type OmniWithdrawalApiFeeRequestTimeoutErrorType, type OnBeforePublishIntentHook, type ParsedAssetInfo, type PoaBridgeRouteConfig, PoaWithdrawalInvariantError, type PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, type PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, type PoaWithdrawalPendingErrorType, type ProcessWithdrawalArgs, QuoteError, type QuoteErrorType, RelayPublishError, type RelayPublishErrorType, type RetryOptions, type RouteConfig, RouteEnum, type RouteEnumValues, RpcRequestError, type RpcRequestErrorType, type SignAndSendArgs, type SignAndSendWithdrawalArgs, type SignedIntentsComposition, TimeoutError, type TimeoutErrorType, TokenNotFoundInDestinationChainError, type TokenNotFoundInDestinationChainErrorType, TrustlineNotFoundError, type TrustlineNotFoundErrorType, type TxInfo, type TxNoInfo, UnsupportedAssetIdError, type UnsupportedAssetIdErrorType, UnsupportedDestinationMemoError, type UnsupportedDestinationMemoErrorType, VersionedNonceBuilder, type VirtualChainRouteConfig, type WithdrawalIdentifier, type WithdrawalParams, type WithdrawalResult, computeIntentHash, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { createDefaultRoute, createHotBridgeRoute, createInternalTransferRoute,
|
|
|
13
13
|
import { FeeExceedsAmountError, FeeExceedsAmountErrorType, MinWithdrawalAmountError, MinWithdrawalAmountErrorType, TrustlineNotFoundError, TrustlineNotFoundErrorType, UnsupportedAssetIdError, UnsupportedAssetIdErrorType, UnsupportedDestinationMemoError, UnsupportedDestinationMemoErrorType } from "./src/classes/errors.js";
|
|
14
14
|
import { DestinationExplicitNearAccountDoesntExistError, DestinationExplicitNearAccountDoesntExistErrorType } from "./src/bridges/direct-bridge/error.js";
|
|
15
15
|
import { HotWithdrawalApiFeeRequestTimeoutError, HotWithdrawalApiFeeRequestTimeoutErrorType, HotWithdrawalCancelledError, HotWithdrawalCancelledErrorType, HotWithdrawalNotFoundError, HotWithdrawalNotFoundErrorType, HotWithdrawalPendingError, HotWithdrawalPendingErrorType } from "./src/bridges/hot-bridge/error.js";
|
|
16
|
-
import {
|
|
16
|
+
import { IntentsNearOmniAvailableBalanceTooLowError, IntentsNearOmniAvailableBalanceTooLowErrorType, InvalidFeeValueError, InvalidFeeValueErrorType, OmniTokenNormalisationCheckError, OmniTokenNormalisationCheckErrorType, OmniTransferDestinationChainHashNotFoundError, OmniTransferDestinationChainHashNotFoundErrorType, OmniTransferNotFoundError, OmniTransferNotFoundErrorType, OmniWithdrawalApiFeeRequestTimeoutError, OmniWithdrawalApiFeeRequestTimeoutErrorType, TokenNotFoundInDestinationChainError, TokenNotFoundInDestinationChainErrorType } from "./src/bridges/omni-bridge/error.js";
|
|
17
17
|
import { computeIntentHash } from "./src/intents/intent-hash.js";
|
|
18
18
|
import { AssertionError, AssertionErrorType, BaseError, BaseErrorType, HttpRequestError, HttpRequestErrorType, ILogger, IntentSettlementError, IntentSettlementErrorType, NearIntentsEnv, PoaWithdrawalInvariantError, PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, PoaWithdrawalPendingErrorType, QuoteError, QuoteErrorType, RelayPublishError, RelayPublishErrorType, RetryOptions, RpcRequestError, RpcRequestErrorType, TimeoutError, TimeoutErrorType } from "@defuse-protocol/internal-utils";
|
|
19
|
-
export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType,
|
|
19
|
+
export { AssertionError, type AssertionErrorType, BaseError, type BaseErrorType, type BatchWithdrawalResult, BridgeNameEnum, type BridgeNameEnumValues, type Chain, Chains, DestinationExplicitNearAccountDoesntExistError, type DestinationExplicitNearAccountDoesntExistErrorType, type FeeEstimation, FeeExceedsAmountError, type FeeExceedsAmountErrorType, type HotBridgeRouteConfig, HotWithdrawalApiFeeRequestTimeoutError, type HotWithdrawalApiFeeRequestTimeoutErrorType, HotWithdrawalCancelledError, type HotWithdrawalCancelledErrorType, HotWithdrawalNotFoundError, type HotWithdrawalNotFoundErrorType, HotWithdrawalPendingError, type HotWithdrawalPendingErrorType, HttpRequestError, type HttpRequestErrorType, type IIntentSigner, type ILogger, type IntentPayload, IntentPayloadBuilder, type IntentPayloadFactory, type IntentPrimitive, type IntentPublishResult, type IntentRelayParamsFactory, IntentSettlementError, type IntentSettlementErrorType, type IntentSettlementStatus, IntentsNearOmniAvailableBalanceTooLowError, type IntentsNearOmniAvailableBalanceTooLowErrorType, IntentsSDK, type IntentsSDKConfig, type InternalTransferRouteConfig, InvalidFeeValueError, type InvalidFeeValueErrorType, MinWithdrawalAmountError, type MinWithdrawalAmountErrorType, type MultiPayload, type NearIntentsEnv, type NearTxInfo, type NearWithdrawalRouteConfig, type OmniBridgeRouteConfig, OmniTokenNormalisationCheckError, type OmniTokenNormalisationCheckErrorType, OmniTransferDestinationChainHashNotFoundError, type OmniTransferDestinationChainHashNotFoundErrorType, OmniTransferNotFoundError, type OmniTransferNotFoundErrorType, OmniWithdrawalApiFeeRequestTimeoutError, type OmniWithdrawalApiFeeRequestTimeoutErrorType, type OnBeforePublishIntentHook, type ParsedAssetInfo, type PoaBridgeRouteConfig, PoaWithdrawalInvariantError, type PoaWithdrawalInvariantErrorType, PoaWithdrawalNotFoundError, type PoaWithdrawalNotFoundErrorType, PoaWithdrawalPendingError, type PoaWithdrawalPendingErrorType, type ProcessWithdrawalArgs, QuoteError, type QuoteErrorType, RelayPublishError, type RelayPublishErrorType, type RetryOptions, type RouteConfig, RouteEnum, type RouteEnumValues, RpcRequestError, type RpcRequestErrorType, type SignAndSendArgs, type SignAndSendWithdrawalArgs, type SignedIntentsComposition, TimeoutError, type TimeoutErrorType, TokenNotFoundInDestinationChainError, type TokenNotFoundInDestinationChainErrorType, TrustlineNotFoundError, type TrustlineNotFoundErrorType, type TxInfo, type TxNoInfo, UnsupportedAssetIdError, type UnsupportedAssetIdErrorType, UnsupportedDestinationMemoError, type UnsupportedDestinationMemoErrorType, VersionedNonceBuilder, type VirtualChainRouteConfig, type WithdrawalIdentifier, type WithdrawalParams, type WithdrawalResult, computeIntentHash, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute };
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Chains } from "./src/lib/caip2.js";
|
|
|
4
4
|
import { BridgeNameEnum } from "./src/constants/bridge-name-enum.js";
|
|
5
5
|
import { DestinationExplicitNearAccountDoesntExistError } from "./src/bridges/direct-bridge/error.js";
|
|
6
6
|
import { HotWithdrawalApiFeeRequestTimeoutError, HotWithdrawalCancelledError, HotWithdrawalNotFoundError, HotWithdrawalPendingError } from "./src/bridges/hot-bridge/error.js";
|
|
7
|
-
import {
|
|
7
|
+
import { IntentsNearOmniAvailableBalanceTooLowError, InvalidFeeValueError, OmniTokenNormalisationCheckError, OmniTransferDestinationChainHashNotFoundError, OmniTransferNotFoundError, OmniWithdrawalApiFeeRequestTimeoutError, TokenNotFoundInDestinationChainError } from "./src/bridges/omni-bridge/error.js";
|
|
8
8
|
import { computeIntentHash } from "./src/intents/intent-hash.js";
|
|
9
9
|
import { VersionedNonceBuilder } from "./src/intents/expirable-nonce.js";
|
|
10
10
|
import { createDefaultRoute, createHotBridgeRoute, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute } from "./src/lib/route-config-factory.js";
|
|
@@ -13,4 +13,4 @@ import { IntentsSDK } from "./src/sdk.js";
|
|
|
13
13
|
import { createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem } from "./src/intents/intent-signer-impl/factories.js";
|
|
14
14
|
import { AssertionError, BaseError, HttpRequestError, IntentSettlementError, PoaWithdrawalInvariantError, PoaWithdrawalNotFoundError, PoaWithdrawalPendingError, QuoteError, RelayPublishError, RpcRequestError, TimeoutError } from "@defuse-protocol/internal-utils";
|
|
15
15
|
|
|
16
|
-
export { AssertionError, BaseError, BridgeNameEnum, Chains, DestinationExplicitNearAccountDoesntExistError,
|
|
16
|
+
export { AssertionError, BaseError, BridgeNameEnum, Chains, DestinationExplicitNearAccountDoesntExistError, FeeExceedsAmountError, HotWithdrawalApiFeeRequestTimeoutError, HotWithdrawalCancelledError, HotWithdrawalNotFoundError, HotWithdrawalPendingError, HttpRequestError, IntentPayloadBuilder, IntentSettlementError, IntentsNearOmniAvailableBalanceTooLowError, IntentsSDK, InvalidFeeValueError, MinWithdrawalAmountError, OmniTokenNormalisationCheckError, OmniTransferDestinationChainHashNotFoundError, OmniTransferNotFoundError, OmniWithdrawalApiFeeRequestTimeoutError, PoaWithdrawalInvariantError, PoaWithdrawalNotFoundError, PoaWithdrawalPendingError, QuoteError, RelayPublishError, RouteEnum, RpcRequestError, TimeoutError, TokenNotFoundInDestinationChainError, TrustlineNotFoundError, UnsupportedAssetIdError, UnsupportedDestinationMemoError, VersionedNonceBuilder, computeIntentHash, createDefaultRoute, createHotBridgeRoute, createIntentSignerNEP413, createIntentSignerNearKeyPair, createIntentSignerViem, createInternalTransferRoute, createNearWithdrawalRoute, createOmniBridgeRoute, createPoaBridgeRoute, createVirtualChainRoute };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_route_enum = require('../../constants/route-enum.cjs');
|
|
3
|
+
const require_estimate_fee = require('../../lib/estimate-fee.cjs');
|
|
3
4
|
const require_aurora_engine_bridge_constants = require('./aurora-engine-bridge-constants.cjs');
|
|
4
5
|
const require_aurora_engine_bridge_utils = require('./aurora-engine-bridge-utils.cjs');
|
|
5
6
|
const require_errors = require('../../classes/errors.cjs');
|
|
6
7
|
const require_parse_defuse_asset_id = require('../../lib/parse-defuse-asset-id.cjs');
|
|
7
|
-
const require_estimate_fee = require('../../lib/estimate-fee.cjs');
|
|
8
8
|
const require_caip2 = require('../../lib/caip2.cjs');
|
|
9
9
|
const require_validateAddress = require('../../lib/validateAddress.cjs');
|
|
10
10
|
let __defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
@@ -46,7 +46,7 @@ var AuroraEngineBridge = class {
|
|
|
46
46
|
proxyTokenContractId: args.withdrawalParams.routeConfig.proxyTokenContractId,
|
|
47
47
|
destinationAddress: args.withdrawalParams.destinationAddress,
|
|
48
48
|
amount: args.withdrawalParams.amount,
|
|
49
|
-
storageDeposit:
|
|
49
|
+
storageDeposit: require_estimate_fee.getUnderlyingFee(args.feeEstimation, require_route_enum.RouteEnum.VirtualChain, "storageDepositFee")
|
|
50
50
|
});
|
|
51
51
|
intents.push(intent);
|
|
52
52
|
return Promise.resolve(intents);
|
|
@@ -71,7 +71,8 @@ var AuroraEngineBridge = class {
|
|
|
71
71
|
})]);
|
|
72
72
|
if (minStorageBalance <= userStorageBalance) return {
|
|
73
73
|
amount: 0n,
|
|
74
|
-
quote: null
|
|
74
|
+
quote: null,
|
|
75
|
+
underlyingFees: { [require_route_enum.RouteEnum.VirtualChain]: { storageDepositFee: 0n } }
|
|
75
76
|
};
|
|
76
77
|
const feeAssetId = require_aurora_engine_bridge_constants.NEAR_NATIVE_ASSET_ID;
|
|
77
78
|
const feeAmount = minStorageBalance - userStorageBalance;
|
|
@@ -86,7 +87,8 @@ var AuroraEngineBridge = class {
|
|
|
86
87
|
});
|
|
87
88
|
return {
|
|
88
89
|
amount: feeQuote ? BigInt(feeQuote.amount_in) : feeAmount,
|
|
89
|
-
quote: feeQuote
|
|
90
|
+
quote: feeQuote,
|
|
91
|
+
underlyingFees: { [require_route_enum.RouteEnum.VirtualChain]: { storageDepositFee: feeAmount } }
|
|
90
92
|
};
|
|
91
93
|
}
|
|
92
94
|
async waitForWithdrawalCompletion(_args) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { RouteEnum } from "../../constants/route-enum.js";
|
|
2
|
+
import { getFeeQuote, getUnderlyingFee } from "../../lib/estimate-fee.js";
|
|
2
3
|
import { NEAR_NATIVE_ASSET_ID } from "./aurora-engine-bridge-constants.js";
|
|
3
4
|
import { createWithdrawIntentPrimitive, withdrawalParamsInvariant } from "./aurora-engine-bridge-utils.js";
|
|
4
5
|
import { InvalidDestinationAddressForWithdrawalError, UnsupportedAssetIdError } from "../../classes/errors.js";
|
|
5
6
|
import { parseDefuseAssetId } from "../../lib/parse-defuse-asset-id.js";
|
|
6
|
-
import { getFeeQuote } from "../../lib/estimate-fee.js";
|
|
7
7
|
import { Chains } from "../../lib/caip2.js";
|
|
8
8
|
import { validateAddress } from "../../lib/validateAddress.js";
|
|
9
9
|
import { assert, getNearNep141MinStorageBalance, getNearNep141StorageBalance, utils } from "@defuse-protocol/internal-utils";
|
|
@@ -44,7 +44,7 @@ var AuroraEngineBridge = class {
|
|
|
44
44
|
proxyTokenContractId: args.withdrawalParams.routeConfig.proxyTokenContractId,
|
|
45
45
|
destinationAddress: args.withdrawalParams.destinationAddress,
|
|
46
46
|
amount: args.withdrawalParams.amount,
|
|
47
|
-
storageDeposit: args.feeEstimation.
|
|
47
|
+
storageDeposit: getUnderlyingFee(args.feeEstimation, RouteEnum.VirtualChain, "storageDepositFee")
|
|
48
48
|
});
|
|
49
49
|
intents.push(intent);
|
|
50
50
|
return Promise.resolve(intents);
|
|
@@ -69,7 +69,8 @@ var AuroraEngineBridge = class {
|
|
|
69
69
|
})]);
|
|
70
70
|
if (minStorageBalance <= userStorageBalance) return {
|
|
71
71
|
amount: 0n,
|
|
72
|
-
quote: null
|
|
72
|
+
quote: null,
|
|
73
|
+
underlyingFees: { [RouteEnum.VirtualChain]: { storageDepositFee: 0n } }
|
|
73
74
|
};
|
|
74
75
|
const feeAssetId = NEAR_NATIVE_ASSET_ID;
|
|
75
76
|
const feeAmount = minStorageBalance - userStorageBalance;
|
|
@@ -84,7 +85,8 @@ var AuroraEngineBridge = class {
|
|
|
84
85
|
});
|
|
85
86
|
return {
|
|
86
87
|
amount: feeQuote ? BigInt(feeQuote.amount_in) : feeAmount,
|
|
87
|
-
quote: feeQuote
|
|
88
|
+
quote: feeQuote,
|
|
89
|
+
underlyingFees: { [RouteEnum.VirtualChain]: { storageDepositFee: feeAmount } }
|
|
88
90
|
};
|
|
89
91
|
}
|
|
90
92
|
async waitForWithdrawalCompletion(_args) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_route_enum = require('../../constants/route-enum.cjs');
|
|
3
|
+
const require_estimate_fee = require('../../lib/estimate-fee.cjs');
|
|
3
4
|
const require_errors = require('../../classes/errors.cjs');
|
|
4
5
|
const require_parse_defuse_asset_id = require('../../lib/parse-defuse-asset-id.cjs');
|
|
5
|
-
const require_estimate_fee = require('../../lib/estimate-fee.cjs');
|
|
6
6
|
const require_caip2 = require('../../lib/caip2.cjs');
|
|
7
7
|
const require_validateAddress = require('../../lib/validateAddress.cjs');
|
|
8
8
|
const require_bridge_name_enum = require('../../constants/bridge-name-enum.cjs');
|
|
@@ -62,7 +62,7 @@ var DirectBridge = class {
|
|
|
62
62
|
assetId: args.withdrawalParams.assetId,
|
|
63
63
|
destinationAddress: args.withdrawalParams.destinationAddress,
|
|
64
64
|
amount: args.withdrawalParams.amount,
|
|
65
|
-
storageDeposit:
|
|
65
|
+
storageDeposit: require_estimate_fee.getUnderlyingFee(args.feeEstimation, require_route_enum.RouteEnum.NearWithdrawal, "storageDepositFee"),
|
|
66
66
|
msg: args.withdrawalParams.routeConfig?.msg
|
|
67
67
|
});
|
|
68
68
|
intents.push(intent);
|
|
@@ -81,12 +81,14 @@ var DirectBridge = class {
|
|
|
81
81
|
(0, __defuse_protocol_internal_utils.assert)(standard === "nep141", "Only NEP-141 is supported");
|
|
82
82
|
if (args.withdrawalParams.assetId === require_direct_bridge_constants.NEAR_NATIVE_ASSET_ID && args.withdrawalParams.routeConfig?.msg === void 0) return {
|
|
83
83
|
amount: 0n,
|
|
84
|
-
quote: null
|
|
84
|
+
quote: null,
|
|
85
|
+
underlyingFees: { [require_route_enum.RouteEnum.NearWithdrawal]: { storageDepositFee: 0n } }
|
|
85
86
|
};
|
|
86
87
|
const [minStorageBalance, userStorageBalance] = await this.getCachedStorageDepositValue(tokenAccountId, args.withdrawalParams.destinationAddress);
|
|
87
88
|
if (minStorageBalance <= userStorageBalance) return {
|
|
88
89
|
amount: 0n,
|
|
89
|
-
quote: null
|
|
90
|
+
quote: null,
|
|
91
|
+
underlyingFees: { [require_route_enum.RouteEnum.NearWithdrawal]: { storageDepositFee: 0n } }
|
|
90
92
|
};
|
|
91
93
|
const feeAssetId = require_direct_bridge_constants.NEAR_NATIVE_ASSET_ID;
|
|
92
94
|
const feeAmount = minStorageBalance - userStorageBalance;
|
|
@@ -101,7 +103,8 @@ var DirectBridge = class {
|
|
|
101
103
|
});
|
|
102
104
|
return {
|
|
103
105
|
amount: feeQuote ? BigInt(feeQuote.amount_in) : feeAmount,
|
|
104
|
-
quote: feeQuote
|
|
106
|
+
quote: feeQuote,
|
|
107
|
+
underlyingFees: { [require_route_enum.RouteEnum.NearWithdrawal]: { storageDepositFee: feeAmount } }
|
|
105
108
|
};
|
|
106
109
|
}
|
|
107
110
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RouteEnum } from "../../constants/route-enum.js";
|
|
2
|
+
import { getFeeQuote, getUnderlyingFee } from "../../lib/estimate-fee.js";
|
|
2
3
|
import { InvalidDestinationAddressForWithdrawalError, UnsupportedAssetIdError } from "../../classes/errors.js";
|
|
3
4
|
import { parseDefuseAssetId } from "../../lib/parse-defuse-asset-id.js";
|
|
4
|
-
import { getFeeQuote } from "../../lib/estimate-fee.js";
|
|
5
5
|
import { Chains } from "../../lib/caip2.js";
|
|
6
6
|
import { validateAddress } from "../../lib/validateAddress.js";
|
|
7
7
|
import { BridgeNameEnum } from "../../constants/bridge-name-enum.js";
|
|
@@ -59,7 +59,7 @@ var DirectBridge = class {
|
|
|
59
59
|
assetId: args.withdrawalParams.assetId,
|
|
60
60
|
destinationAddress: args.withdrawalParams.destinationAddress,
|
|
61
61
|
amount: args.withdrawalParams.amount,
|
|
62
|
-
storageDeposit:
|
|
62
|
+
storageDeposit: getUnderlyingFee(args.feeEstimation, RouteEnum.NearWithdrawal, "storageDepositFee"),
|
|
63
63
|
msg: args.withdrawalParams.routeConfig?.msg
|
|
64
64
|
});
|
|
65
65
|
intents.push(intent);
|
|
@@ -78,12 +78,14 @@ var DirectBridge = class {
|
|
|
78
78
|
assert(standard === "nep141", "Only NEP-141 is supported");
|
|
79
79
|
if (args.withdrawalParams.assetId === NEAR_NATIVE_ASSET_ID && args.withdrawalParams.routeConfig?.msg === void 0) return {
|
|
80
80
|
amount: 0n,
|
|
81
|
-
quote: null
|
|
81
|
+
quote: null,
|
|
82
|
+
underlyingFees: { [RouteEnum.NearWithdrawal]: { storageDepositFee: 0n } }
|
|
82
83
|
};
|
|
83
84
|
const [minStorageBalance, userStorageBalance] = await this.getCachedStorageDepositValue(tokenAccountId, args.withdrawalParams.destinationAddress);
|
|
84
85
|
if (minStorageBalance <= userStorageBalance) return {
|
|
85
86
|
amount: 0n,
|
|
86
|
-
quote: null
|
|
87
|
+
quote: null,
|
|
88
|
+
underlyingFees: { [RouteEnum.NearWithdrawal]: { storageDepositFee: 0n } }
|
|
87
89
|
};
|
|
88
90
|
const feeAssetId = NEAR_NATIVE_ASSET_ID;
|
|
89
91
|
const feeAmount = minStorageBalance - userStorageBalance;
|
|
@@ -98,7 +100,8 @@ var DirectBridge = class {
|
|
|
98
100
|
});
|
|
99
101
|
return {
|
|
100
102
|
amount: feeQuote ? BigInt(feeQuote.amount_in) : feeAmount,
|
|
101
|
-
quote: feeQuote
|
|
103
|
+
quote: feeQuote,
|
|
104
|
+
underlyingFees: { [RouteEnum.NearWithdrawal]: { storageDepositFee: feeAmount } }
|
|
102
105
|
};
|
|
103
106
|
}
|
|
104
107
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_route_enum = require('../../constants/route-enum.cjs');
|
|
3
|
+
const require_estimate_fee = require('../../lib/estimate-fee.cjs');
|
|
3
4
|
const require_errors = require('../../classes/errors.cjs');
|
|
4
5
|
const require_parse_defuse_asset_id = require('../../lib/parse-defuse-asset-id.cjs');
|
|
5
|
-
const require_estimate_fee = require('../../lib/estimate-fee.cjs');
|
|
6
6
|
const require_caip2 = require('../../lib/caip2.cjs');
|
|
7
7
|
const require_validateAddress = require('../../lib/validateAddress.cjs');
|
|
8
8
|
const require_bridge_name_enum = require('../../constants/bridge-name-enum.cjs');
|
|
@@ -55,19 +55,15 @@ var HotBridge = class {
|
|
|
55
55
|
(0, __defuse_protocol_internal_utils.assert)(assetInfo != null, "Asset is not supported");
|
|
56
56
|
if (args.withdrawalParams.destinationMemo != null && args.withdrawalParams.destinationMemo !== "") throw new require_errors.UnsupportedDestinationMemoError(assetInfo.blockchain, args.withdrawalParams.assetId);
|
|
57
57
|
const intents = [];
|
|
58
|
-
|
|
59
|
-
if (args.feeEstimation.quote
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
},
|
|
68
|
-
referral: args.referral
|
|
69
|
-
});
|
|
70
|
-
}
|
|
58
|
+
const feeAmount = require_estimate_fee.getUnderlyingFee(args.feeEstimation, require_route_enum.RouteEnum.HotBridge, "relayerFee");
|
|
59
|
+
if (args.feeEstimation.quote !== null) intents.push({
|
|
60
|
+
intent: "token_diff",
|
|
61
|
+
diff: {
|
|
62
|
+
[args.feeEstimation.quote.defuse_asset_identifier_in]: `-${args.feeEstimation.quote.amount_in}`,
|
|
63
|
+
[args.feeEstimation.quote.defuse_asset_identifier_out]: args.feeEstimation.quote.amount_out
|
|
64
|
+
},
|
|
65
|
+
referral: args.referral
|
|
66
|
+
});
|
|
71
67
|
const isNative = "native" in assetInfo;
|
|
72
68
|
const amount = args.withdrawalParams.amount + (isNative ? feeAmount : 0n);
|
|
73
69
|
const intent = await this.hotSdk.buildGaslessWithdrawIntent({
|
|
@@ -123,7 +119,8 @@ var HotBridge = class {
|
|
|
123
119
|
});
|
|
124
120
|
return {
|
|
125
121
|
amount: feeQuote ? BigInt(feeQuote.amount_in) : feeAmount,
|
|
126
|
-
quote: feeQuote
|
|
122
|
+
quote: feeQuote,
|
|
123
|
+
underlyingFees: { [require_route_enum.RouteEnum.HotBridge]: { relayerFee: feeAmount } }
|
|
127
124
|
};
|
|
128
125
|
}
|
|
129
126
|
async waitForWithdrawalCompletion(args) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RouteEnum } from "../../constants/route-enum.js";
|
|
2
|
+
import { getFeeQuote, getUnderlyingFee } from "../../lib/estimate-fee.js";
|
|
2
3
|
import { InvalidDestinationAddressForWithdrawalError, TrustlineNotFoundError, UnsupportedAssetIdError, UnsupportedDestinationMemoError } from "../../classes/errors.js";
|
|
3
4
|
import { parseDefuseAssetId } from "../../lib/parse-defuse-asset-id.js";
|
|
4
|
-
import { getFeeQuote } from "../../lib/estimate-fee.js";
|
|
5
5
|
import { Chains } from "../../lib/caip2.js";
|
|
6
6
|
import { validateAddress } from "../../lib/validateAddress.js";
|
|
7
7
|
import { BridgeNameEnum } from "../../constants/bridge-name-enum.js";
|
|
@@ -51,19 +51,15 @@ var HotBridge$1 = class {
|
|
|
51
51
|
assert(assetInfo != null, "Asset is not supported");
|
|
52
52
|
if (args.withdrawalParams.destinationMemo != null && args.withdrawalParams.destinationMemo !== "") throw new UnsupportedDestinationMemoError(assetInfo.blockchain, args.withdrawalParams.assetId);
|
|
53
53
|
const intents = [];
|
|
54
|
-
|
|
55
|
-
if (args.feeEstimation.quote
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
},
|
|
64
|
-
referral: args.referral
|
|
65
|
-
});
|
|
66
|
-
}
|
|
54
|
+
const feeAmount = getUnderlyingFee(args.feeEstimation, RouteEnum.HotBridge, "relayerFee");
|
|
55
|
+
if (args.feeEstimation.quote !== null) intents.push({
|
|
56
|
+
intent: "token_diff",
|
|
57
|
+
diff: {
|
|
58
|
+
[args.feeEstimation.quote.defuse_asset_identifier_in]: `-${args.feeEstimation.quote.amount_in}`,
|
|
59
|
+
[args.feeEstimation.quote.defuse_asset_identifier_out]: args.feeEstimation.quote.amount_out
|
|
60
|
+
},
|
|
61
|
+
referral: args.referral
|
|
62
|
+
});
|
|
67
63
|
const isNative = "native" in assetInfo;
|
|
68
64
|
const amount = args.withdrawalParams.amount + (isNative ? feeAmount : 0n);
|
|
69
65
|
const intent = await this.hotSdk.buildGaslessWithdrawIntent({
|
|
@@ -119,7 +115,8 @@ var HotBridge$1 = class {
|
|
|
119
115
|
});
|
|
120
116
|
return {
|
|
121
117
|
amount: feeQuote ? BigInt(feeQuote.amount_in) : feeAmount,
|
|
122
|
-
quote: feeQuote
|
|
118
|
+
quote: feeQuote,
|
|
119
|
+
underlyingFees: { [RouteEnum.HotBridge]: { relayerFee: feeAmount } }
|
|
123
120
|
};
|
|
124
121
|
}
|
|
125
122
|
async waitForWithdrawalCompletion(args) {
|
|
@@ -32,11 +32,11 @@ var TokenNotFoundInDestinationChainError = class extends __defuse_protocol_inter
|
|
|
32
32
|
this.destinationChain = destinationChain;
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
var
|
|
36
|
-
constructor(token) {
|
|
37
|
-
super(`
|
|
38
|
-
metaMessages: [`Token: ${token}`],
|
|
39
|
-
name: "
|
|
35
|
+
var InvalidFeeValueError = class extends __defuse_protocol_internal_utils.BaseError {
|
|
36
|
+
constructor(token, value) {
|
|
37
|
+
super(`Invalid fee value`, {
|
|
38
|
+
metaMessages: [`Token: ${token}`, `Fee value: ${value}`],
|
|
39
|
+
name: "InvalidFeeValueError"
|
|
40
40
|
});
|
|
41
41
|
this.token = token;
|
|
42
42
|
}
|
|
@@ -76,8 +76,8 @@ var OmniWithdrawalApiFeeRequestTimeoutError = class extends __defuse_protocol_in
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
//#endregion
|
|
79
|
-
exports.FailedToFetchFeeError = FailedToFetchFeeError;
|
|
80
79
|
exports.IntentsNearOmniAvailableBalanceTooLowError = IntentsNearOmniAvailableBalanceTooLowError;
|
|
80
|
+
exports.InvalidFeeValueError = InvalidFeeValueError;
|
|
81
81
|
exports.OmniTokenNormalisationCheckError = OmniTokenNormalisationCheckError;
|
|
82
82
|
exports.OmniTransferDestinationChainHashNotFoundError = OmniTransferDestinationChainHashNotFoundError;
|
|
83
83
|
exports.OmniTransferNotFoundError = OmniTransferNotFoundError;
|
|
@@ -25,12 +25,12 @@ declare class TokenNotFoundInDestinationChainError extends BaseError {
|
|
|
25
25
|
destinationChain: Chain;
|
|
26
26
|
constructor(token: string, destinationChain: Chain);
|
|
27
27
|
}
|
|
28
|
-
type
|
|
29
|
-
name: "
|
|
28
|
+
type InvalidFeeValueErrorType = InvalidFeeValueError & {
|
|
29
|
+
name: "InvalidFeeValueError";
|
|
30
30
|
};
|
|
31
|
-
declare class
|
|
31
|
+
declare class InvalidFeeValueError extends BaseError {
|
|
32
32
|
token: string;
|
|
33
|
-
constructor(token: string);
|
|
33
|
+
constructor(token: string, value: unknown);
|
|
34
34
|
}
|
|
35
35
|
type OmniTokenNormalisationCheckErrorType = OmniTokenNormalisationCheckError & {
|
|
36
36
|
name: "OmniTokenNormalisationCheckError";
|
|
@@ -56,4 +56,4 @@ declare class OmniWithdrawalApiFeeRequestTimeoutError extends BaseError {
|
|
|
56
56
|
constructor();
|
|
57
57
|
}
|
|
58
58
|
//#endregion
|
|
59
|
-
export {
|
|
59
|
+
export { IntentsNearOmniAvailableBalanceTooLowError, IntentsNearOmniAvailableBalanceTooLowErrorType, InvalidFeeValueError, InvalidFeeValueErrorType, OmniTokenNormalisationCheckError, OmniTokenNormalisationCheckErrorType, OmniTransferDestinationChainHashNotFoundError, OmniTransferDestinationChainHashNotFoundErrorType, OmniTransferNotFoundError, OmniTransferNotFoundErrorType, OmniWithdrawalApiFeeRequestTimeoutError, OmniWithdrawalApiFeeRequestTimeoutErrorType, TokenNotFoundInDestinationChainError, TokenNotFoundInDestinationChainErrorType };
|
|
@@ -25,12 +25,12 @@ declare class TokenNotFoundInDestinationChainError extends BaseError {
|
|
|
25
25
|
destinationChain: Chain;
|
|
26
26
|
constructor(token: string, destinationChain: Chain);
|
|
27
27
|
}
|
|
28
|
-
type
|
|
29
|
-
name: "
|
|
28
|
+
type InvalidFeeValueErrorType = InvalidFeeValueError & {
|
|
29
|
+
name: "InvalidFeeValueError";
|
|
30
30
|
};
|
|
31
|
-
declare class
|
|
31
|
+
declare class InvalidFeeValueError extends BaseError {
|
|
32
32
|
token: string;
|
|
33
|
-
constructor(token: string);
|
|
33
|
+
constructor(token: string, value: unknown);
|
|
34
34
|
}
|
|
35
35
|
type OmniTokenNormalisationCheckErrorType = OmniTokenNormalisationCheckError & {
|
|
36
36
|
name: "OmniTokenNormalisationCheckError";
|
|
@@ -56,4 +56,4 @@ declare class OmniWithdrawalApiFeeRequestTimeoutError extends BaseError {
|
|
|
56
56
|
constructor();
|
|
57
57
|
}
|
|
58
58
|
//#endregion
|
|
59
|
-
export {
|
|
59
|
+
export { IntentsNearOmniAvailableBalanceTooLowError, IntentsNearOmniAvailableBalanceTooLowErrorType, InvalidFeeValueError, InvalidFeeValueErrorType, OmniTokenNormalisationCheckError, OmniTokenNormalisationCheckErrorType, OmniTransferDestinationChainHashNotFoundError, OmniTransferDestinationChainHashNotFoundErrorType, OmniTransferNotFoundError, OmniTransferNotFoundErrorType, OmniWithdrawalApiFeeRequestTimeoutError, OmniWithdrawalApiFeeRequestTimeoutErrorType, TokenNotFoundInDestinationChainError, TokenNotFoundInDestinationChainErrorType };
|
|
@@ -30,11 +30,11 @@ var TokenNotFoundInDestinationChainError = class extends BaseError {
|
|
|
30
30
|
this.destinationChain = destinationChain;
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
var
|
|
34
|
-
constructor(token) {
|
|
35
|
-
super(`
|
|
36
|
-
metaMessages: [`Token: ${token}`],
|
|
37
|
-
name: "
|
|
33
|
+
var InvalidFeeValueError = class extends BaseError {
|
|
34
|
+
constructor(token, value) {
|
|
35
|
+
super(`Invalid fee value`, {
|
|
36
|
+
metaMessages: [`Token: ${token}`, `Fee value: ${value}`],
|
|
37
|
+
name: "InvalidFeeValueError"
|
|
38
38
|
});
|
|
39
39
|
this.token = token;
|
|
40
40
|
}
|
|
@@ -74,4 +74,4 @@ var OmniWithdrawalApiFeeRequestTimeoutError = class extends BaseError {
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
//#endregion
|
|
77
|
-
export {
|
|
77
|
+
export { IntentsNearOmniAvailableBalanceTooLowError, InvalidFeeValueError, OmniTokenNormalisationCheckError, OmniTransferDestinationChainHashNotFoundError, OmniTransferNotFoundError, OmniWithdrawalApiFeeRequestTimeoutError, TokenNotFoundInDestinationChainError };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_route_enum = require('../../constants/route-enum.cjs');
|
|
3
|
+
const require_estimate_fee = require('../../lib/estimate-fee.cjs');
|
|
3
4
|
const require_errors = require('../../classes/errors.cjs');
|
|
4
5
|
const require_parse_defuse_asset_id = require('../../lib/parse-defuse-asset-id.cjs');
|
|
5
|
-
const require_estimate_fee = require('../../lib/estimate-fee.cjs');
|
|
6
6
|
const require_validateAddress = require('../../lib/validateAddress.cjs');
|
|
7
7
|
const require_bridge_name_enum = require('../../constants/bridge-name-enum.cjs');
|
|
8
8
|
const require_error = require('./error.cjs');
|
|
@@ -103,8 +103,6 @@ var OmniBridge = class {
|
|
|
103
103
|
(0, __defuse_protocol_internal_utils.assert)(assetInfo !== null, `Asset ${args.withdrawalParams.assetId} is not supported by Omni Bridge`);
|
|
104
104
|
const omniChainKind = require_omni_bridge_utils.caip2ToChainKind(assetInfo.blockchain);
|
|
105
105
|
(0, __defuse_protocol_internal_utils.assert)(omniChainKind !== null, `Chain ${assetInfo.blockchain} is not supported by Omni Bridge`);
|
|
106
|
-
const [minStorageBalance, currentStorageBalance] = await this.getCachedStorageDepositValue(assetInfo.contractId);
|
|
107
|
-
const storageDepositAmount = minStorageBalance > currentStorageBalance ? minStorageBalance - currentStorageBalance : 0n;
|
|
108
106
|
const intents = [];
|
|
109
107
|
if (args.feeEstimation.quote !== null) intents.push({
|
|
110
108
|
intent: "token_diff",
|
|
@@ -114,16 +112,16 @@ var OmniBridge = class {
|
|
|
114
112
|
},
|
|
115
113
|
referral: args.referral
|
|
116
114
|
});
|
|
117
|
-
const
|
|
118
|
-
(0, __defuse_protocol_internal_utils.assert)(
|
|
115
|
+
const relayerFee = require_estimate_fee.getUnderlyingFee(args.feeEstimation, require_route_enum.RouteEnum.OmniBridge, "relayerFee");
|
|
116
|
+
(0, __defuse_protocol_internal_utils.assert)(relayerFee > 0n, `Invalid Omni bridge relayer fee: expected > 0, got ${relayerFee}`);
|
|
119
117
|
intents.push(...require_omni_bridge_utils.createWithdrawIntentsPrimitive({
|
|
120
118
|
assetId: args.withdrawalParams.assetId,
|
|
121
119
|
destinationAddress: args.withdrawalParams.destinationAddress,
|
|
122
120
|
amount: args.withdrawalParams.amount,
|
|
123
121
|
omniChainKind,
|
|
124
122
|
intentsContract: __defuse_protocol_internal_utils.configsByEnvironment[this.env].contractID,
|
|
125
|
-
nativeFee,
|
|
126
|
-
storageDepositAmount
|
|
123
|
+
nativeFee: relayerFee,
|
|
124
|
+
storageDepositAmount: require_estimate_fee.getUnderlyingFee(args.feeEstimation, require_route_enum.RouteEnum.OmniBridge, "storageDepositFee")
|
|
127
125
|
}));
|
|
128
126
|
return Promise.resolve(intents);
|
|
129
127
|
}
|
|
@@ -156,12 +154,22 @@ var OmniBridge = class {
|
|
|
156
154
|
timeout: typeof window !== "undefined" ? 1e4 : 3e3,
|
|
157
155
|
errorInstance: new require_error.OmniWithdrawalApiFeeRequestTimeoutError()
|
|
158
156
|
});
|
|
159
|
-
if (fee.native_token_fee === null) throw new require_error.
|
|
157
|
+
if (fee.native_token_fee === null || fee.native_token_fee <= 0n) throw new require_error.InvalidFeeValueError(args.withdrawalParams.assetId, fee.native_token_fee);
|
|
158
|
+
const underlyingFees = {
|
|
159
|
+
relayerFee: fee.native_token_fee,
|
|
160
|
+
storageDepositFee: 0n
|
|
161
|
+
};
|
|
162
|
+
let totalAmountToQuote = fee.native_token_fee;
|
|
160
163
|
const [minStorageBalance, currentStorageBalance] = await this.getCachedStorageDepositValue(assetInfo.contractId);
|
|
161
|
-
const
|
|
164
|
+
const storageDepositFee = minStorageBalance - currentStorageBalance;
|
|
165
|
+
if (storageDepositFee > 0n) {
|
|
166
|
+
totalAmountToQuote += storageDepositFee;
|
|
167
|
+
underlyingFees.storageDepositFee = storageDepositFee;
|
|
168
|
+
}
|
|
162
169
|
if (args.withdrawalParams.assetId === require_omni_bridge_constants.NEAR_NATIVE_ASSET_ID) return {
|
|
163
170
|
amount: totalAmountToQuote,
|
|
164
|
-
quote: null
|
|
171
|
+
quote: null,
|
|
172
|
+
underlyingFees: { [require_route_enum.RouteEnum.OmniBridge]: underlyingFees }
|
|
165
173
|
};
|
|
166
174
|
const quote = await require_estimate_fee.getFeeQuote({
|
|
167
175
|
feeAmount: totalAmountToQuote,
|
|
@@ -174,7 +182,8 @@ var OmniBridge = class {
|
|
|
174
182
|
});
|
|
175
183
|
return {
|
|
176
184
|
amount: BigInt(quote.amount_in),
|
|
177
|
-
quote
|
|
185
|
+
quote,
|
|
186
|
+
underlyingFees: { [require_route_enum.RouteEnum.OmniBridge]: underlyingFees }
|
|
178
187
|
};
|
|
179
188
|
}
|
|
180
189
|
async waitForWithdrawalCompletion(args) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RouteEnum } from "../../constants/route-enum.js";
|
|
2
|
+
import { getFeeQuote, getUnderlyingFee } from "../../lib/estimate-fee.js";
|
|
2
3
|
import { InvalidDestinationAddressForWithdrawalError, UnsupportedAssetIdError } from "../../classes/errors.js";
|
|
3
4
|
import { parseDefuseAssetId } from "../../lib/parse-defuse-asset-id.js";
|
|
4
|
-
import { getFeeQuote } from "../../lib/estimate-fee.js";
|
|
5
5
|
import { validateAddress } from "../../lib/validateAddress.js";
|
|
6
6
|
import { BridgeNameEnum } from "../../constants/bridge-name-enum.js";
|
|
7
|
-
import {
|
|
7
|
+
import { IntentsNearOmniAvailableBalanceTooLowError, InvalidFeeValueError, OmniTokenNormalisationCheckError, OmniTransferDestinationChainHashNotFoundError, OmniTransferNotFoundError, OmniWithdrawalApiFeeRequestTimeoutError, TokenNotFoundInDestinationChainError } from "./error.js";
|
|
8
8
|
import { MIN_ALLOWED_STORAGE_BALANCE_FOR_INTENTS_NEAR, NEAR_NATIVE_ASSET_ID, OMNI_BRIDGE_CONTRACT } from "./omni-bridge-constants.js";
|
|
9
9
|
import { caip2ToChainKind, chainKindToCaip2, createWithdrawIntentsPrimitive, getAccountOmniStorageBalance, getBridgedToken, getTokenDecimals, validateOmniToken } from "./omni-bridge-utils.js";
|
|
10
10
|
import { RETRY_CONFIGS, assert, configsByEnvironment, getNearNep141MinStorageBalance, getNearNep141StorageBalance, withTimeout } from "@defuse-protocol/internal-utils";
|
|
@@ -97,8 +97,6 @@ var OmniBridge = class {
|
|
|
97
97
|
assert(assetInfo !== null, `Asset ${args.withdrawalParams.assetId} is not supported by Omni Bridge`);
|
|
98
98
|
const omniChainKind = caip2ToChainKind(assetInfo.blockchain);
|
|
99
99
|
assert(omniChainKind !== null, `Chain ${assetInfo.blockchain} is not supported by Omni Bridge`);
|
|
100
|
-
const [minStorageBalance, currentStorageBalance] = await this.getCachedStorageDepositValue(assetInfo.contractId);
|
|
101
|
-
const storageDepositAmount = minStorageBalance > currentStorageBalance ? minStorageBalance - currentStorageBalance : 0n;
|
|
102
100
|
const intents = [];
|
|
103
101
|
if (args.feeEstimation.quote !== null) intents.push({
|
|
104
102
|
intent: "token_diff",
|
|
@@ -108,16 +106,16 @@ var OmniBridge = class {
|
|
|
108
106
|
},
|
|
109
107
|
referral: args.referral
|
|
110
108
|
});
|
|
111
|
-
const
|
|
112
|
-
assert(
|
|
109
|
+
const relayerFee = getUnderlyingFee(args.feeEstimation, RouteEnum.OmniBridge, "relayerFee");
|
|
110
|
+
assert(relayerFee > 0n, `Invalid Omni bridge relayer fee: expected > 0, got ${relayerFee}`);
|
|
113
111
|
intents.push(...createWithdrawIntentsPrimitive({
|
|
114
112
|
assetId: args.withdrawalParams.assetId,
|
|
115
113
|
destinationAddress: args.withdrawalParams.destinationAddress,
|
|
116
114
|
amount: args.withdrawalParams.amount,
|
|
117
115
|
omniChainKind,
|
|
118
116
|
intentsContract: configsByEnvironment[this.env].contractID,
|
|
119
|
-
nativeFee,
|
|
120
|
-
storageDepositAmount
|
|
117
|
+
nativeFee: relayerFee,
|
|
118
|
+
storageDepositAmount: getUnderlyingFee(args.feeEstimation, RouteEnum.OmniBridge, "storageDepositFee")
|
|
121
119
|
}));
|
|
122
120
|
return Promise.resolve(intents);
|
|
123
121
|
}
|
|
@@ -150,12 +148,22 @@ var OmniBridge = class {
|
|
|
150
148
|
timeout: typeof window !== "undefined" ? 1e4 : 3e3,
|
|
151
149
|
errorInstance: new OmniWithdrawalApiFeeRequestTimeoutError()
|
|
152
150
|
});
|
|
153
|
-
if (fee.native_token_fee === null) throw new
|
|
151
|
+
if (fee.native_token_fee === null || fee.native_token_fee <= 0n) throw new InvalidFeeValueError(args.withdrawalParams.assetId, fee.native_token_fee);
|
|
152
|
+
const underlyingFees = {
|
|
153
|
+
relayerFee: fee.native_token_fee,
|
|
154
|
+
storageDepositFee: 0n
|
|
155
|
+
};
|
|
156
|
+
let totalAmountToQuote = fee.native_token_fee;
|
|
154
157
|
const [minStorageBalance, currentStorageBalance] = await this.getCachedStorageDepositValue(assetInfo.contractId);
|
|
155
|
-
const
|
|
158
|
+
const storageDepositFee = minStorageBalance - currentStorageBalance;
|
|
159
|
+
if (storageDepositFee > 0n) {
|
|
160
|
+
totalAmountToQuote += storageDepositFee;
|
|
161
|
+
underlyingFees.storageDepositFee = storageDepositFee;
|
|
162
|
+
}
|
|
156
163
|
if (args.withdrawalParams.assetId === NEAR_NATIVE_ASSET_ID) return {
|
|
157
164
|
amount: totalAmountToQuote,
|
|
158
|
-
quote: null
|
|
165
|
+
quote: null,
|
|
166
|
+
underlyingFees: { [RouteEnum.OmniBridge]: underlyingFees }
|
|
159
167
|
};
|
|
160
168
|
const quote = await getFeeQuote({
|
|
161
169
|
feeAmount: totalAmountToQuote,
|
|
@@ -168,7 +176,8 @@ var OmniBridge = class {
|
|
|
168
176
|
});
|
|
169
177
|
return {
|
|
170
178
|
amount: BigInt(quote.amount_in),
|
|
171
|
-
quote
|
|
179
|
+
quote,
|
|
180
|
+
underlyingFees: { [RouteEnum.OmniBridge]: underlyingFees }
|
|
172
181
|
};
|
|
173
182
|
}
|
|
174
183
|
async waitForWithdrawalCompletion(args) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_route_enum = require('../../constants/route-enum.cjs');
|
|
3
|
+
const require_estimate_fee = require('../../lib/estimate-fee.cjs');
|
|
3
4
|
const require_errors = require('../../classes/errors.cjs');
|
|
4
5
|
const require_parse_defuse_asset_id = require('../../lib/parse-defuse-asset-id.cjs');
|
|
5
6
|
const require_validateAddress = require('../../lib/validateAddress.cjs');
|
|
@@ -41,9 +42,11 @@ var PoaBridge = class {
|
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
createWithdrawalIntents(args) {
|
|
45
|
+
const relayerFee = require_estimate_fee.getUnderlyingFee(args.feeEstimation, require_route_enum.RouteEnum.PoaBridge, "relayerFee");
|
|
46
|
+
(0, __defuse_protocol_internal_utils.assert)(relayerFee > 0n, `Invalid POA bridge relayer fee: expected > 0, got ${relayerFee}`);
|
|
44
47
|
const intent = require_poa_bridge_utils.createWithdrawIntentPrimitive({
|
|
45
48
|
...args.withdrawalParams,
|
|
46
|
-
amount: args.withdrawalParams.amount +
|
|
49
|
+
amount: args.withdrawalParams.amount + relayerFee,
|
|
47
50
|
destinationMemo: args.withdrawalParams.destinationMemo
|
|
48
51
|
});
|
|
49
52
|
return Promise.resolve([intent]);
|
|
@@ -76,9 +79,12 @@ var PoaBridge = class {
|
|
|
76
79
|
baseURL: __defuse_protocol_internal_utils.configsByEnvironment[this.env].poaBridgeBaseURL,
|
|
77
80
|
logger: args.logger
|
|
78
81
|
});
|
|
82
|
+
const relayerFee = BigInt(estimation.withdrawalFee);
|
|
83
|
+
(0, __defuse_protocol_internal_utils.assert)(relayerFee > 0n, `Invalid POA bridge relayer fee: expected > 0, got ${relayerFee}`);
|
|
79
84
|
return {
|
|
80
|
-
amount:
|
|
81
|
-
quote: null
|
|
85
|
+
amount: relayerFee,
|
|
86
|
+
quote: null,
|
|
87
|
+
underlyingFees: { [require_route_enum.RouteEnum.PoaBridge]: { relayerFee } }
|
|
82
88
|
};
|
|
83
89
|
}
|
|
84
90
|
async waitForWithdrawalCompletion(args) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RouteEnum } from "../../constants/route-enum.js";
|
|
2
|
+
import { getUnderlyingFee } from "../../lib/estimate-fee.js";
|
|
2
3
|
import { InvalidDestinationAddressForWithdrawalError, MinWithdrawalAmountError, UnsupportedAssetIdError } from "../../classes/errors.js";
|
|
3
4
|
import { parseDefuseAssetId } from "../../lib/parse-defuse-asset-id.js";
|
|
4
5
|
import { validateAddress } from "../../lib/validateAddress.js";
|
|
@@ -38,9 +39,11 @@ var PoaBridge = class {
|
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
createWithdrawalIntents(args) {
|
|
42
|
+
const relayerFee = getUnderlyingFee(args.feeEstimation, RouteEnum.PoaBridge, "relayerFee");
|
|
43
|
+
assert(relayerFee > 0n, `Invalid POA bridge relayer fee: expected > 0, got ${relayerFee}`);
|
|
41
44
|
const intent = createWithdrawIntentPrimitive({
|
|
42
45
|
...args.withdrawalParams,
|
|
43
|
-
amount: args.withdrawalParams.amount +
|
|
46
|
+
amount: args.withdrawalParams.amount + relayerFee,
|
|
44
47
|
destinationMemo: args.withdrawalParams.destinationMemo
|
|
45
48
|
});
|
|
46
49
|
return Promise.resolve([intent]);
|
|
@@ -73,9 +76,12 @@ var PoaBridge = class {
|
|
|
73
76
|
baseURL: configsByEnvironment[this.env].poaBridgeBaseURL,
|
|
74
77
|
logger: args.logger
|
|
75
78
|
});
|
|
79
|
+
const relayerFee = BigInt(estimation.withdrawalFee);
|
|
80
|
+
assert(relayerFee > 0n, `Invalid POA bridge relayer fee: expected > 0, got ${relayerFee}`);
|
|
76
81
|
return {
|
|
77
|
-
amount:
|
|
78
|
-
quote: null
|
|
82
|
+
amount: relayerFee,
|
|
83
|
+
quote: null,
|
|
84
|
+
underlyingFees: { [RouteEnum.PoaBridge]: { relayerFee } }
|
|
79
85
|
};
|
|
80
86
|
}
|
|
81
87
|
async waitForWithdrawalCompletion(args) {
|
|
@@ -5,6 +5,23 @@ __defuse_protocol_internal_utils = require_rolldown_runtime.__toESM(__defuse_pro
|
|
|
5
5
|
|
|
6
6
|
//#region src/lib/estimate-fee.ts
|
|
7
7
|
/**
|
|
8
|
+
* Helper to extract a specific fee from FeeEstimation's underlyingFees.
|
|
9
|
+
* Throws if the route's fee object doesn't exist (invariant: bridges must populate their fees during estimation).
|
|
10
|
+
* Returns the fee value which may be undefined for optional fees within the route object.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const relayerFee = getUnderlyingFee(feeEstimation, RouteEnum.HotBridge, 'relayerFee');
|
|
15
|
+
* const storageDepositFee = getUnderlyingFee(feeEstimation, RouteEnum.OmniBridge, 'storageDepositFee');
|
|
16
|
+
* ```
|
|
17
|
+
* @throws {Error} If the route's fee object is not found in underlyingFees
|
|
18
|
+
*/
|
|
19
|
+
function getUnderlyingFee(feeEstimation, route, feeKey) {
|
|
20
|
+
const routeFees = feeEstimation.underlyingFees?.[route];
|
|
21
|
+
if (routeFees === void 0) throw new Error(`Missing underlying fees for route "${String(route)}". Fee estimation must populate underlyingFees before creating withdrawal intents.`);
|
|
22
|
+
return routeFees[feeKey];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
8
25
|
* ExactIn fallback with 1.2x multiplier
|
|
9
26
|
*/
|
|
10
27
|
async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions, env, logger, solverRelayApiKey }) {
|
|
@@ -76,4 +93,5 @@ async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions,
|
|
|
76
93
|
}
|
|
77
94
|
|
|
78
95
|
//#endregion
|
|
79
|
-
exports.getFeeQuote = getFeeQuote;
|
|
96
|
+
exports.getFeeQuote = getFeeQuote;
|
|
97
|
+
exports.getUnderlyingFee = getUnderlyingFee;
|
|
@@ -3,6 +3,23 @@ import { QuoteError, configsByEnvironment, solverRelay } from "@defuse-protocol/
|
|
|
3
3
|
|
|
4
4
|
//#region src/lib/estimate-fee.ts
|
|
5
5
|
/**
|
|
6
|
+
* Helper to extract a specific fee from FeeEstimation's underlyingFees.
|
|
7
|
+
* Throws if the route's fee object doesn't exist (invariant: bridges must populate their fees during estimation).
|
|
8
|
+
* Returns the fee value which may be undefined for optional fees within the route object.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const relayerFee = getUnderlyingFee(feeEstimation, RouteEnum.HotBridge, 'relayerFee');
|
|
13
|
+
* const storageDepositFee = getUnderlyingFee(feeEstimation, RouteEnum.OmniBridge, 'storageDepositFee');
|
|
14
|
+
* ```
|
|
15
|
+
* @throws {Error} If the route's fee object is not found in underlyingFees
|
|
16
|
+
*/
|
|
17
|
+
function getUnderlyingFee(feeEstimation, route, feeKey) {
|
|
18
|
+
const routeFees = feeEstimation.underlyingFees?.[route];
|
|
19
|
+
if (routeFees === void 0) throw new Error(`Missing underlying fees for route "${String(route)}". Fee estimation must populate underlyingFees before creating withdrawal intents.`);
|
|
20
|
+
return routeFees[feeKey];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
6
23
|
* ExactIn fallback with 1.2x multiplier
|
|
7
24
|
*/
|
|
8
25
|
async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions, env, logger, solverRelayApiKey }) {
|
|
@@ -74,4 +91,4 @@ async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions,
|
|
|
74
91
|
}
|
|
75
92
|
|
|
76
93
|
//#endregion
|
|
77
|
-
export { getFeeQuote };
|
|
94
|
+
export { getFeeQuote, getUnderlyingFee };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HotBridgeEVMChain } from "./bridges/hot-bridge/hot-bridge-chains.cjs";
|
|
2
2
|
import { BridgeNameEnumValues } from "./constants/bridge-name-enum.cjs";
|
|
3
|
-
import { RouteEnum } from "./constants/route-enum.cjs";
|
|
3
|
+
import { RouteEnum, RouteEnumValues } from "./constants/route-enum.cjs";
|
|
4
4
|
import { IntentHash, IntentPayloadFactory, IntentPrimitive, IntentRelayParamsFactory, MultiPayload } from "./intents/shared-types.cjs";
|
|
5
5
|
import { IIntentSigner } from "./intents/interfaces/intent-signer.cjs";
|
|
6
6
|
import { OnBeforePublishIntentHook } from "./intents/intent-executer-impl/intent-executer.cjs";
|
|
@@ -212,9 +212,56 @@ type OmniBridgeRouteConfig = {
|
|
|
212
212
|
chain?: Chain;
|
|
213
213
|
};
|
|
214
214
|
type RouteConfig = NearWithdrawalRouteConfig | InternalTransferRouteConfig | VirtualChainRouteConfig | PoaBridgeRouteConfig | HotBridgeRouteConfig | OmniBridgeRouteConfig;
|
|
215
|
+
/**
|
|
216
|
+
* Fee structure definitions for each route type.
|
|
217
|
+
*/
|
|
218
|
+
interface RouteFeeStructures {
|
|
219
|
+
[RouteEnum.HotBridge]: {
|
|
220
|
+
/** Relayer fee for processing the withdrawal on destination chain, taken in base token of destination chain. */
|
|
221
|
+
relayerFee: bigint;
|
|
222
|
+
};
|
|
223
|
+
[RouteEnum.PoaBridge]: {
|
|
224
|
+
/** Relayer fee for POA bridge transfers, taken in transferred token. */
|
|
225
|
+
relayerFee: bigint;
|
|
226
|
+
};
|
|
227
|
+
[RouteEnum.NearWithdrawal]: {
|
|
228
|
+
/** Fee for nep141 storage deposit in NEAR blockchain, taken in wrap.near token. Paid for a token recipient. */
|
|
229
|
+
storageDepositFee: bigint;
|
|
230
|
+
};
|
|
231
|
+
[RouteEnum.OmniBridge]: {
|
|
232
|
+
/** Fee for nep141 storage deposit in NEAR blockchain, taken in wrap.near token. Paid for omni bridge contract. */
|
|
233
|
+
storageDepositFee: bigint;
|
|
234
|
+
/** Relayer fee for transferring tokens via Omni Bridge to other supported blockchains, taken in wrap.near token. */
|
|
235
|
+
relayerFee: bigint;
|
|
236
|
+
/** Fee taken when making a withdrawal via UTXO connector (e.g., btc-connector.bridge.near), taken in transferred token. */
|
|
237
|
+
utxoProtocolFee?: bigint;
|
|
238
|
+
/** Maximum amount of tokens that can be spent on gas when making a withdrawal via UTXO connector (e.g., btc-connector.bridge.near), taken in transferred token. */
|
|
239
|
+
utxoMaxGasFee?: bigint;
|
|
240
|
+
};
|
|
241
|
+
[RouteEnum.VirtualChain]: {
|
|
242
|
+
/** Fee for nep141 storage deposit in NEAR blockchain, taken in wrap.near token. Paid for virtual chain contract */
|
|
243
|
+
storageDepositFee: bigint;
|
|
244
|
+
};
|
|
245
|
+
/** Internal transfers have no fees */
|
|
246
|
+
[RouteEnum.InternalTransfer]: null;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Represents the different categories of fees that may apply across various withdrawal operations.
|
|
250
|
+
* Each route type has an optional fee structure. Uses a mapped type to ensure all RouteEnum values are covered.
|
|
251
|
+
*/
|
|
252
|
+
type UnderlyingFees = { [K in RouteEnumValues]?: RouteFeeStructures[K] };
|
|
215
253
|
interface FeeEstimation {
|
|
216
254
|
amount: bigint;
|
|
255
|
+
/**
|
|
256
|
+
* @internal Implementation detail - do not use directly.
|
|
257
|
+
* This field may change or be removed without notice.
|
|
258
|
+
*/
|
|
217
259
|
quote: null | solverRelay.Quote;
|
|
260
|
+
/**
|
|
261
|
+
* @internal Implementation detail - do not use directly.
|
|
262
|
+
* This field may change or be removed without notice.
|
|
263
|
+
*/
|
|
264
|
+
underlyingFees: UnderlyingFees;
|
|
218
265
|
}
|
|
219
266
|
interface Bridge {
|
|
220
267
|
is(routeConfig: RouteConfig): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HotBridgeEVMChain } from "./bridges/hot-bridge/hot-bridge-chains.js";
|
|
2
2
|
import { BridgeNameEnumValues } from "./constants/bridge-name-enum.js";
|
|
3
|
-
import { RouteEnum } from "./constants/route-enum.js";
|
|
3
|
+
import { RouteEnum, RouteEnumValues } from "./constants/route-enum.js";
|
|
4
4
|
import { IntentHash, IntentPayloadFactory, IntentPrimitive, IntentRelayParamsFactory, MultiPayload } from "./intents/shared-types.js";
|
|
5
5
|
import { IIntentSigner } from "./intents/interfaces/intent-signer.js";
|
|
6
6
|
import { OnBeforePublishIntentHook } from "./intents/intent-executer-impl/intent-executer.js";
|
|
@@ -212,9 +212,56 @@ type OmniBridgeRouteConfig = {
|
|
|
212
212
|
chain?: Chain;
|
|
213
213
|
};
|
|
214
214
|
type RouteConfig = NearWithdrawalRouteConfig | InternalTransferRouteConfig | VirtualChainRouteConfig | PoaBridgeRouteConfig | HotBridgeRouteConfig | OmniBridgeRouteConfig;
|
|
215
|
+
/**
|
|
216
|
+
* Fee structure definitions for each route type.
|
|
217
|
+
*/
|
|
218
|
+
interface RouteFeeStructures {
|
|
219
|
+
[RouteEnum.HotBridge]: {
|
|
220
|
+
/** Relayer fee for processing the withdrawal on destination chain, taken in base token of destination chain. */
|
|
221
|
+
relayerFee: bigint;
|
|
222
|
+
};
|
|
223
|
+
[RouteEnum.PoaBridge]: {
|
|
224
|
+
/** Relayer fee for POA bridge transfers, taken in transferred token. */
|
|
225
|
+
relayerFee: bigint;
|
|
226
|
+
};
|
|
227
|
+
[RouteEnum.NearWithdrawal]: {
|
|
228
|
+
/** Fee for nep141 storage deposit in NEAR blockchain, taken in wrap.near token. Paid for a token recipient. */
|
|
229
|
+
storageDepositFee: bigint;
|
|
230
|
+
};
|
|
231
|
+
[RouteEnum.OmniBridge]: {
|
|
232
|
+
/** Fee for nep141 storage deposit in NEAR blockchain, taken in wrap.near token. Paid for omni bridge contract. */
|
|
233
|
+
storageDepositFee: bigint;
|
|
234
|
+
/** Relayer fee for transferring tokens via Omni Bridge to other supported blockchains, taken in wrap.near token. */
|
|
235
|
+
relayerFee: bigint;
|
|
236
|
+
/** Fee taken when making a withdrawal via UTXO connector (e.g., btc-connector.bridge.near), taken in transferred token. */
|
|
237
|
+
utxoProtocolFee?: bigint;
|
|
238
|
+
/** Maximum amount of tokens that can be spent on gas when making a withdrawal via UTXO connector (e.g., btc-connector.bridge.near), taken in transferred token. */
|
|
239
|
+
utxoMaxGasFee?: bigint;
|
|
240
|
+
};
|
|
241
|
+
[RouteEnum.VirtualChain]: {
|
|
242
|
+
/** Fee for nep141 storage deposit in NEAR blockchain, taken in wrap.near token. Paid for virtual chain contract */
|
|
243
|
+
storageDepositFee: bigint;
|
|
244
|
+
};
|
|
245
|
+
/** Internal transfers have no fees */
|
|
246
|
+
[RouteEnum.InternalTransfer]: null;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Represents the different categories of fees that may apply across various withdrawal operations.
|
|
250
|
+
* Each route type has an optional fee structure. Uses a mapped type to ensure all RouteEnum values are covered.
|
|
251
|
+
*/
|
|
252
|
+
type UnderlyingFees = { [K in RouteEnumValues]?: RouteFeeStructures[K] };
|
|
215
253
|
interface FeeEstimation {
|
|
216
254
|
amount: bigint;
|
|
255
|
+
/**
|
|
256
|
+
* @internal Implementation detail - do not use directly.
|
|
257
|
+
* This field may change or be removed without notice.
|
|
258
|
+
*/
|
|
217
259
|
quote: null | solverRelay.Quote;
|
|
260
|
+
/**
|
|
261
|
+
* @internal Implementation detail - do not use directly.
|
|
262
|
+
* This field may change or be removed without notice.
|
|
263
|
+
*/
|
|
264
|
+
underlyingFees: UnderlyingFees;
|
|
218
265
|
}
|
|
219
266
|
interface Bridge {
|
|
220
267
|
is(routeConfig: RouteConfig): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defuse-protocol/intents-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"ripple-address-codec": "^5.0.0",
|
|
39
39
|
"valibot": "^1.0.0",
|
|
40
40
|
"viem": "^2.0.0",
|
|
41
|
-
"@defuse-protocol/
|
|
42
|
-
"@defuse-protocol/
|
|
41
|
+
"@defuse-protocol/contract-types": "0.4.0",
|
|
42
|
+
"@defuse-protocol/internal-utils": "0.19.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"tsdown": "0.15.5",
|