@defuse-protocol/intents-sdk 0.58.2 → 0.59.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/omni-bridge/omni-bridge-constants.cjs +2 -0
- package/dist/src/bridges/omni-bridge/omni-bridge-constants.js +2 -1
- package/dist/src/bridges/omni-bridge/omni-bridge.cjs +4 -2
- package/dist/src/bridges/omni-bridge/omni-bridge.js +5 -3
- package/dist/src/core/withdrawal-watcher.cjs +1 -1
- package/dist/src/core/withdrawal-watcher.js +1 -1
- package/package.json +3 -3
|
@@ -5,8 +5,10 @@ const OMNI_BRIDGE_CONTRACT = "omni.bridge.near";
|
|
|
5
5
|
const MIN_STORAGE_BALANCE_FOR_INTENTS_NEAR = 500000000000000000000000n;
|
|
6
6
|
const MIN_GAS_AMOUNT = "37400000000000";
|
|
7
7
|
const INTENTS_STORAGE_BALANCE_CACHE_KEY = "INTENTS_STORAGE_BALANCE";
|
|
8
|
+
const FEE_SUBSIDIZED_TOKENS = ["nep141:lsd-usdt.rhealab.near"];
|
|
8
9
|
|
|
9
10
|
//#endregion
|
|
11
|
+
exports.FEE_SUBSIDIZED_TOKENS = FEE_SUBSIDIZED_TOKENS;
|
|
10
12
|
exports.INTENTS_STORAGE_BALANCE_CACHE_KEY = INTENTS_STORAGE_BALANCE_CACHE_KEY;
|
|
11
13
|
exports.MIN_GAS_AMOUNT = MIN_GAS_AMOUNT;
|
|
12
14
|
exports.MIN_STORAGE_BALANCE_FOR_INTENTS_NEAR = MIN_STORAGE_BALANCE_FOR_INTENTS_NEAR;
|
|
@@ -4,6 +4,7 @@ const OMNI_BRIDGE_CONTRACT = "omni.bridge.near";
|
|
|
4
4
|
const MIN_STORAGE_BALANCE_FOR_INTENTS_NEAR = 500000000000000000000000n;
|
|
5
5
|
const MIN_GAS_AMOUNT = "37400000000000";
|
|
6
6
|
const INTENTS_STORAGE_BALANCE_CACHE_KEY = "INTENTS_STORAGE_BALANCE";
|
|
7
|
+
const FEE_SUBSIDIZED_TOKENS = ["nep141:lsd-usdt.rhealab.near"];
|
|
7
8
|
|
|
8
9
|
//#endregion
|
|
9
|
-
export { INTENTS_STORAGE_BALANCE_CACHE_KEY, MIN_GAS_AMOUNT, MIN_STORAGE_BALANCE_FOR_INTENTS_NEAR, NEAR_NATIVE_ASSET_ID, OMNI_BRIDGE_CONTRACT };
|
|
10
|
+
export { FEE_SUBSIDIZED_TOKENS, INTENTS_STORAGE_BALANCE_CACHE_KEY, MIN_GAS_AMOUNT, MIN_STORAGE_BALANCE_FOR_INTENTS_NEAR, NEAR_NATIVE_ASSET_ID, OMNI_BRIDGE_CONTRACT };
|
|
@@ -152,7 +152,8 @@ var OmniBridge = class {
|
|
|
152
152
|
return Promise.resolve(intents);
|
|
153
153
|
}
|
|
154
154
|
async validateWithdrawal(args) {
|
|
155
|
-
|
|
155
|
+
const isFeeSubsidized = require_omni_bridge_constants.FEE_SUBSIDIZED_TOKENS.includes(args.assetId);
|
|
156
|
+
if (!isFeeSubsidized) (0, _defuse_protocol_internal_utils.assert)(args.feeEstimation.amount > 0n, `Invalid Omni Bridge fee: expected > 0, got ${args.feeEstimation.amount}`);
|
|
156
157
|
const assetInfo = this.makeAssetInfo(args.assetId, args.routeConfig);
|
|
157
158
|
(0, _defuse_protocol_internal_utils.assert)(assetInfo !== null, `Asset ${args.assetId} is not supported by Omni Bridge`);
|
|
158
159
|
if (require_validateAddress.validateAddress(args.destinationAddress, assetInfo.blockchain) === false) throw new require_errors.InvalidDestinationAddressForWithdrawalError(args.destinationAddress, assetInfo.blockchain);
|
|
@@ -167,7 +168,7 @@ var OmniBridge = class {
|
|
|
167
168
|
const intentsStorageBalance = await this.getCachedIntentsStorageBalance();
|
|
168
169
|
if (intentsStorageBalance <= require_omni_bridge_constants.MIN_STORAGE_BALANCE_FOR_INTENTS_NEAR) throw new require_error.IntentsNearOmniAvailableBalanceTooLowError(intentsStorageBalance.toString());
|
|
169
170
|
const utxoChainWithdrawal = require_omni_bridge_utils.isUtxoChain(omniChainKind);
|
|
170
|
-
if (utxoChainWithdrawal
|
|
171
|
+
if (!utxoChainWithdrawal && !isFeeSubsidized) {
|
|
171
172
|
const relayerFee = require_estimate_fee.getUnderlyingFee(args.feeEstimation, require_route_enum.RouteEnum.OmniBridge, "relayerFee");
|
|
172
173
|
(0, _defuse_protocol_internal_utils.assert)(require_estimate_fee.getUnderlyingFee(args.feeEstimation, require_route_enum.RouteEnum.OmniBridge, "relayerFee") > 0n, `Invalid Omni Bridge relayer fee for non UTXO chain withdrawal: expected > 0, got ${relayerFee}`);
|
|
173
174
|
}
|
|
@@ -197,6 +198,7 @@ var OmniBridge = class {
|
|
|
197
198
|
errorInstance: new require_error.OmniWithdrawalApiFeeRequestTimeoutError()
|
|
198
199
|
});
|
|
199
200
|
if (fee.native_token_fee === null || fee.native_token_fee < 0n) throw new require_error.InvalidFeeValueError(args.withdrawalParams.assetId, fee.native_token_fee);
|
|
201
|
+
if (require_omni_bridge_constants.FEE_SUBSIDIZED_TOKENS.includes(args.withdrawalParams.assetId)) fee.native_token_fee = 0n;
|
|
200
202
|
const underlyingFees = {
|
|
201
203
|
relayerFee: fee.native_token_fee,
|
|
202
204
|
storageDepositFee: 0n
|
|
@@ -5,7 +5,7 @@ import { parseDefuseAssetId } from "../../lib/parse-defuse-asset-id.js";
|
|
|
5
5
|
import { validateAddress } from "../../lib/validateAddress.js";
|
|
6
6
|
import { BridgeNameEnum } from "../../constants/bridge-name-enum.js";
|
|
7
7
|
import { InsufficientUtxoForOmniBridgeWithdrawalError, IntentsNearOmniAvailableBalanceTooLowError, InvalidFeeValueError, OmniWithdrawalApiFeeRequestTimeoutError, TokenNotFoundInDestinationChainError } from "./error.js";
|
|
8
|
-
import { INTENTS_STORAGE_BALANCE_CACHE_KEY, MIN_STORAGE_BALANCE_FOR_INTENTS_NEAR, NEAR_NATIVE_ASSET_ID, OMNI_BRIDGE_CONTRACT } from "./omni-bridge-constants.js";
|
|
8
|
+
import { FEE_SUBSIDIZED_TOKENS, INTENTS_STORAGE_BALANCE_CACHE_KEY, MIN_STORAGE_BALANCE_FOR_INTENTS_NEAR, NEAR_NATIVE_ASSET_ID, OMNI_BRIDGE_CONTRACT } from "./omni-bridge-constants.js";
|
|
9
9
|
import { POA_TOKENS_ROUTABLE_THROUGH_OMNI_BRIDGE } from "../../constants/poa-tokens-routable-through-omni-bridge.js";
|
|
10
10
|
import { caip2ToChainKind, chainKindToCaip2, createWithdrawIntentsPrimitive, getAccountOmniStorageBalance, getBridgedToken, getTokenDecimals, isUtxoChain, poaContractIdToChainKind, validateOmniToken } from "./omni-bridge-utils.js";
|
|
11
11
|
import { assert, getNearNep141MinStorageBalance, getNearNep141StorageBalance, withTimeout } from "@defuse-protocol/internal-utils";
|
|
@@ -150,7 +150,8 @@ var OmniBridge = class {
|
|
|
150
150
|
return Promise.resolve(intents);
|
|
151
151
|
}
|
|
152
152
|
async validateWithdrawal(args) {
|
|
153
|
-
|
|
153
|
+
const isFeeSubsidized = FEE_SUBSIDIZED_TOKENS.includes(args.assetId);
|
|
154
|
+
if (!isFeeSubsidized) assert(args.feeEstimation.amount > 0n, `Invalid Omni Bridge fee: expected > 0, got ${args.feeEstimation.amount}`);
|
|
154
155
|
const assetInfo = this.makeAssetInfo(args.assetId, args.routeConfig);
|
|
155
156
|
assert(assetInfo !== null, `Asset ${args.assetId} is not supported by Omni Bridge`);
|
|
156
157
|
if (validateAddress(args.destinationAddress, assetInfo.blockchain) === false) throw new InvalidDestinationAddressForWithdrawalError(args.destinationAddress, assetInfo.blockchain);
|
|
@@ -165,7 +166,7 @@ var OmniBridge = class {
|
|
|
165
166
|
const intentsStorageBalance = await this.getCachedIntentsStorageBalance();
|
|
166
167
|
if (intentsStorageBalance <= MIN_STORAGE_BALANCE_FOR_INTENTS_NEAR) throw new IntentsNearOmniAvailableBalanceTooLowError(intentsStorageBalance.toString());
|
|
167
168
|
const utxoChainWithdrawal = isUtxoChain(omniChainKind);
|
|
168
|
-
if (utxoChainWithdrawal
|
|
169
|
+
if (!utxoChainWithdrawal && !isFeeSubsidized) {
|
|
169
170
|
const relayerFee = getUnderlyingFee(args.feeEstimation, RouteEnum.OmniBridge, "relayerFee");
|
|
170
171
|
assert(getUnderlyingFee(args.feeEstimation, RouteEnum.OmniBridge, "relayerFee") > 0n, `Invalid Omni Bridge relayer fee for non UTXO chain withdrawal: expected > 0, got ${relayerFee}`);
|
|
171
172
|
}
|
|
@@ -195,6 +196,7 @@ var OmniBridge = class {
|
|
|
195
196
|
errorInstance: new OmniWithdrawalApiFeeRequestTimeoutError()
|
|
196
197
|
});
|
|
197
198
|
if (fee.native_token_fee === null || fee.native_token_fee < 0n) throw new InvalidFeeValueError(args.withdrawalParams.assetId, fee.native_token_fee);
|
|
199
|
+
if (FEE_SUBSIDIZED_TOKENS.includes(args.withdrawalParams.assetId)) fee.native_token_fee = 0n;
|
|
198
200
|
const underlyingFees = {
|
|
199
201
|
relayerFee: fee.native_token_fee,
|
|
200
202
|
storageDepositFee: 0n
|
|
@@ -3,7 +3,7 @@ const require_withdrawal_timing = require('../constants/withdrawal-timing.cjs');
|
|
|
3
3
|
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
4
4
|
|
|
5
5
|
//#region src/core/withdrawal-watcher.ts
|
|
6
|
-
const MAX_CONSECUTIVE_ERRORS =
|
|
6
|
+
const MAX_CONSECUTIVE_ERRORS = 5;
|
|
7
7
|
async function watchWithdrawal(args) {
|
|
8
8
|
const stats = require_withdrawal_timing.getWithdrawalStatsForChain({
|
|
9
9
|
chain: args.wid.landingChain,
|
|
@@ -2,7 +2,7 @@ import { getWithdrawalStatsForChain } from "../constants/withdrawal-timing.js";
|
|
|
2
2
|
import { BaseError, POLL_PENDING, PollTimeoutError, poll } from "@defuse-protocol/internal-utils";
|
|
3
3
|
|
|
4
4
|
//#region src/core/withdrawal-watcher.ts
|
|
5
|
-
const MAX_CONSECUTIVE_ERRORS =
|
|
5
|
+
const MAX_CONSECUTIVE_ERRORS = 5;
|
|
6
6
|
async function watchWithdrawal(args) {
|
|
7
7
|
const stats = getWithdrawalStatsForChain({
|
|
8
8
|
chain: args.wid.landingChain,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defuse-protocol/intents-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.59.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"ripple-address-codec": "^5.0.0",
|
|
46
46
|
"valibot": "^1.0.0",
|
|
47
47
|
"viem": "^2.0.0",
|
|
48
|
-
"@defuse-protocol/contract-types": "0.6.
|
|
49
|
-
"@defuse-protocol/internal-utils": "0.
|
|
48
|
+
"@defuse-protocol/contract-types": "0.6.3",
|
|
49
|
+
"@defuse-protocol/internal-utils": "0.31.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"tsdown": "0.19.0"
|