@defuse-protocol/intents-sdk 0.43.0 → 0.43.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/dist/src/bridges/hot-bridge/hot-bridge.cjs +8 -4
- package/dist/src/bridges/hot-bridge/hot-bridge.js +8 -4
- package/dist/src/bridges/omni-bridge/omni-bridge.cjs +2 -2
- package/dist/src/bridges/omni-bridge/omni-bridge.js +2 -2
- package/dist/src/shared-types.d.cts +2 -0
- package/dist/src/shared-types.d.ts +2 -0
- package/package.json +2 -2
|
@@ -53,6 +53,7 @@ var HotBridge = class {
|
|
|
53
53
|
if (args.withdrawalParams.destinationMemo != null && args.withdrawalParams.destinationMemo !== "") throw new require_errors.UnsupportedDestinationMemoError(assetInfo.blockchain, args.withdrawalParams.assetId);
|
|
54
54
|
const intents = [];
|
|
55
55
|
const feeAmount = require_estimate_fee.getUnderlyingFee(args.feeEstimation, require_route_enum.RouteEnum.HotBridge, "relayerFee");
|
|
56
|
+
const blockNumber = require_estimate_fee.getUnderlyingFee(args.feeEstimation, require_route_enum.RouteEnum.HotBridge, "blockNumber");
|
|
56
57
|
if (args.feeEstimation.quote !== null) intents.push({
|
|
57
58
|
intent: "token_diff",
|
|
58
59
|
diff: {
|
|
@@ -66,11 +67,11 @@ var HotBridge = class {
|
|
|
66
67
|
const intent = await this.hotSdk.buildGaslessWithdrawIntent({
|
|
67
68
|
feeToken: "native",
|
|
68
69
|
feeAmount,
|
|
70
|
+
blockNumber,
|
|
69
71
|
chain: require_hot_bridge_utils.toHotNetworkId(assetInfo.blockchain),
|
|
70
72
|
token: isNative ? "native" : assetInfo.address,
|
|
71
73
|
amount,
|
|
72
|
-
receiver: args.withdrawalParams.destinationAddress
|
|
73
|
-
intentAccount: ""
|
|
74
|
+
receiver: args.withdrawalParams.destinationAddress
|
|
74
75
|
});
|
|
75
76
|
(0, __defuse_protocol_internal_utils.assert)(intent.amounts[0] === amount.toString(), "Amount is not correct");
|
|
76
77
|
if (intent.amounts.length === 2) (0, __defuse_protocol_internal_utils.assert)(intent.amounts[1] === feeAmount.toString(), "Amount is not correct");
|
|
@@ -96,7 +97,7 @@ var HotBridge = class {
|
|
|
96
97
|
const assetInfo = this.parseAssetId(args.withdrawalParams.assetId);
|
|
97
98
|
(0, __defuse_protocol_internal_utils.assert)(assetInfo != null, "Asset is not supported");
|
|
98
99
|
require_hot_bridge_utils.hotBlockchainInvariant(assetInfo.blockchain);
|
|
99
|
-
const { gasPrice: feeAmount } = await (0, __defuse_protocol_internal_utils.withTimeout)(() => this.hotSdk.getGaslessWithdrawFee({
|
|
100
|
+
const { gasPrice: feeAmount, blockNumber } = await (0, __defuse_protocol_internal_utils.withTimeout)(() => this.hotSdk.getGaslessWithdrawFee({
|
|
100
101
|
chain: require_hot_bridge_utils.toHotNetworkId(assetInfo.blockchain),
|
|
101
102
|
token: "native" in assetInfo ? "native" : assetInfo.address,
|
|
102
103
|
receiver: args.withdrawalParams.destinationAddress
|
|
@@ -117,7 +118,10 @@ var HotBridge = class {
|
|
|
117
118
|
return {
|
|
118
119
|
amount: feeQuote ? BigInt(feeQuote.amount_in) : feeAmount,
|
|
119
120
|
quote: feeQuote,
|
|
120
|
-
underlyingFees: { [require_route_enum.RouteEnum.HotBridge]: {
|
|
121
|
+
underlyingFees: { [require_route_enum.RouteEnum.HotBridge]: {
|
|
122
|
+
relayerFee: feeAmount,
|
|
123
|
+
blockNumber
|
|
124
|
+
} }
|
|
121
125
|
};
|
|
122
126
|
}
|
|
123
127
|
async waitForWithdrawalCompletion(args) {
|
|
@@ -52,6 +52,7 @@ var HotBridge$1 = class {
|
|
|
52
52
|
if (args.withdrawalParams.destinationMemo != null && args.withdrawalParams.destinationMemo !== "") throw new UnsupportedDestinationMemoError(assetInfo.blockchain, args.withdrawalParams.assetId);
|
|
53
53
|
const intents = [];
|
|
54
54
|
const feeAmount = getUnderlyingFee(args.feeEstimation, RouteEnum.HotBridge, "relayerFee");
|
|
55
|
+
const blockNumber = getUnderlyingFee(args.feeEstimation, RouteEnum.HotBridge, "blockNumber");
|
|
55
56
|
if (args.feeEstimation.quote !== null) intents.push({
|
|
56
57
|
intent: "token_diff",
|
|
57
58
|
diff: {
|
|
@@ -65,11 +66,11 @@ var HotBridge$1 = class {
|
|
|
65
66
|
const intent = await this.hotSdk.buildGaslessWithdrawIntent({
|
|
66
67
|
feeToken: "native",
|
|
67
68
|
feeAmount,
|
|
69
|
+
blockNumber,
|
|
68
70
|
chain: toHotNetworkId(assetInfo.blockchain),
|
|
69
71
|
token: isNative ? "native" : assetInfo.address,
|
|
70
72
|
amount,
|
|
71
|
-
receiver: args.withdrawalParams.destinationAddress
|
|
72
|
-
intentAccount: ""
|
|
73
|
+
receiver: args.withdrawalParams.destinationAddress
|
|
73
74
|
});
|
|
74
75
|
assert(intent.amounts[0] === amount.toString(), "Amount is not correct");
|
|
75
76
|
if (intent.amounts.length === 2) assert(intent.amounts[1] === feeAmount.toString(), "Amount is not correct");
|
|
@@ -95,7 +96,7 @@ var HotBridge$1 = class {
|
|
|
95
96
|
const assetInfo = this.parseAssetId(args.withdrawalParams.assetId);
|
|
96
97
|
assert(assetInfo != null, "Asset is not supported");
|
|
97
98
|
hotBlockchainInvariant(assetInfo.blockchain);
|
|
98
|
-
const { gasPrice: feeAmount } = await withTimeout(() => this.hotSdk.getGaslessWithdrawFee({
|
|
99
|
+
const { gasPrice: feeAmount, blockNumber } = await withTimeout(() => this.hotSdk.getGaslessWithdrawFee({
|
|
99
100
|
chain: toHotNetworkId(assetInfo.blockchain),
|
|
100
101
|
token: "native" in assetInfo ? "native" : assetInfo.address,
|
|
101
102
|
receiver: args.withdrawalParams.destinationAddress
|
|
@@ -116,7 +117,10 @@ var HotBridge$1 = class {
|
|
|
116
117
|
return {
|
|
117
118
|
amount: feeQuote ? BigInt(feeQuote.amount_in) : feeAmount,
|
|
118
119
|
quote: feeQuote,
|
|
119
|
-
underlyingFees: { [RouteEnum.HotBridge]: {
|
|
120
|
+
underlyingFees: { [RouteEnum.HotBridge]: {
|
|
121
|
+
relayerFee: feeAmount,
|
|
122
|
+
blockNumber
|
|
123
|
+
} }
|
|
120
124
|
};
|
|
121
125
|
}
|
|
122
126
|
async waitForWithdrawalCompletion(args) {
|
|
@@ -145,7 +145,7 @@ var OmniBridge = class {
|
|
|
145
145
|
return Promise.resolve(intents);
|
|
146
146
|
}
|
|
147
147
|
async validateWithdrawal(args) {
|
|
148
|
-
(0, __defuse_protocol_internal_utils.assert)(args.feeEstimation.amount > 0n, `
|
|
148
|
+
(0, __defuse_protocol_internal_utils.assert)(args.feeEstimation.amount > 0n, `Invalid Omni Bridge fee: expected > 0, got ${args.feeEstimation.amount}`);
|
|
149
149
|
const assetInfo = this.makeAssetInfo(args.assetId, args.routeConfig);
|
|
150
150
|
(0, __defuse_protocol_internal_utils.assert)(assetInfo !== null, `Asset ${args.assetId} is not supported by Omni Bridge`);
|
|
151
151
|
if (require_validateAddress.validateAddress(args.destinationAddress, assetInfo.blockchain) === false) throw new require_errors.InvalidDestinationAddressForWithdrawalError(args.destinationAddress, assetInfo.blockchain);
|
|
@@ -156,7 +156,7 @@ var OmniBridge = class {
|
|
|
156
156
|
const decimals = await this.getCachedTokenDecimals(destTokenAddress);
|
|
157
157
|
(0, __defuse_protocol_internal_utils.assert)(decimals !== null, `Failed to retrieve token decimals for address ${destTokenAddress} via OmniBridge contract.
|
|
158
158
|
Ensure the token is supported and the address is correct.`);
|
|
159
|
-
if ((0, omni_bridge_sdk.verifyTransferAmount)(args.amount
|
|
159
|
+
if ((0, omni_bridge_sdk.verifyTransferAmount)(args.amount, 0n, decimals.origin_decimals, decimals.decimals) === false) throw new require_errors.MinWithdrawalAmountError((0, omni_bridge_sdk.getMinimumTransferableAmount)(decimals.origin_decimals, decimals.decimals), args.amount, args.assetId);
|
|
160
160
|
const storageBalance = await require_omni_bridge_utils.getAccountOmniStorageBalance(this.nearProvider, __defuse_protocol_internal_utils.configsByEnvironment[this.env].contractID);
|
|
161
161
|
const intentsNearStorageBalance = storageBalance === null ? 0n : BigInt(storageBalance.available);
|
|
162
162
|
if (intentsNearStorageBalance <= require_omni_bridge_constants.MIN_ALLOWED_STORAGE_BALANCE_FOR_INTENTS_NEAR) throw new require_error.IntentsNearOmniAvailableBalanceTooLowError(intentsNearStorageBalance.toString());
|
|
@@ -143,7 +143,7 @@ var OmniBridge = class {
|
|
|
143
143
|
return Promise.resolve(intents);
|
|
144
144
|
}
|
|
145
145
|
async validateWithdrawal(args) {
|
|
146
|
-
assert(args.feeEstimation.amount > 0n, `
|
|
146
|
+
assert(args.feeEstimation.amount > 0n, `Invalid Omni Bridge fee: expected > 0, got ${args.feeEstimation.amount}`);
|
|
147
147
|
const assetInfo = this.makeAssetInfo(args.assetId, args.routeConfig);
|
|
148
148
|
assert(assetInfo !== null, `Asset ${args.assetId} is not supported by Omni Bridge`);
|
|
149
149
|
if (validateAddress(args.destinationAddress, assetInfo.blockchain) === false) throw new InvalidDestinationAddressForWithdrawalError(args.destinationAddress, assetInfo.blockchain);
|
|
@@ -154,7 +154,7 @@ var OmniBridge = class {
|
|
|
154
154
|
const decimals = await this.getCachedTokenDecimals(destTokenAddress);
|
|
155
155
|
assert(decimals !== null, `Failed to retrieve token decimals for address ${destTokenAddress} via OmniBridge contract.
|
|
156
156
|
Ensure the token is supported and the address is correct.`);
|
|
157
|
-
if (verifyTransferAmount(args.amount
|
|
157
|
+
if (verifyTransferAmount(args.amount, 0n, decimals.origin_decimals, decimals.decimals) === false) throw new MinWithdrawalAmountError(getMinimumTransferableAmount(decimals.origin_decimals, decimals.decimals), args.amount, args.assetId);
|
|
158
158
|
const storageBalance = await getAccountOmniStorageBalance(this.nearProvider, configsByEnvironment[this.env].contractID);
|
|
159
159
|
const intentsNearStorageBalance = storageBalance === null ? 0n : BigInt(storageBalance.available);
|
|
160
160
|
if (intentsNearStorageBalance <= MIN_ALLOWED_STORAGE_BALANCE_FOR_INTENTS_NEAR) throw new IntentsNearOmniAvailableBalanceTooLowError(intentsNearStorageBalance.toString());
|
|
@@ -219,6 +219,8 @@ interface RouteFeeStructures {
|
|
|
219
219
|
[RouteEnum.HotBridge]: {
|
|
220
220
|
/** Relayer fee for processing the withdrawal on destination chain, taken in base token of destination chain. */
|
|
221
221
|
relayerFee: bigint;
|
|
222
|
+
/** Block number at the time of fee estimation, required for building gasless withdraw intent. */
|
|
223
|
+
blockNumber: bigint;
|
|
222
224
|
};
|
|
223
225
|
[RouteEnum.PoaBridge]: {
|
|
224
226
|
/** Relayer fee for POA bridge transfers, taken in transferred token. */
|
|
@@ -219,6 +219,8 @@ interface RouteFeeStructures {
|
|
|
219
219
|
[RouteEnum.HotBridge]: {
|
|
220
220
|
/** Relayer fee for processing the withdrawal on destination chain, taken in base token of destination chain. */
|
|
221
221
|
relayerFee: bigint;
|
|
222
|
+
/** Block number at the time of fee estimation, required for building gasless withdraw intent. */
|
|
223
|
+
blockNumber: bigint;
|
|
222
224
|
};
|
|
223
225
|
[RouteEnum.PoaBridge]: {
|
|
224
226
|
/** Relayer fee for POA bridge transfers, taken in transferred token. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defuse-protocol/intents-sdk",
|
|
3
|
-
"version": "0.43.
|
|
3
|
+
"version": "0.43.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"typescript": "^5"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@hot-labs/omni-sdk": "2.
|
|
34
|
+
"@hot-labs/omni-sdk": "2.24.0",
|
|
35
35
|
"@isaacs/ttlcache": "^1.0.0",
|
|
36
36
|
"@lifeomic/attempt": "^3.0.0",
|
|
37
37
|
"@near-js/accounts": "^2.0.1",
|