@defuse-protocol/intents-sdk 0.41.0 → 0.41.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.
|
@@ -156,8 +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
|
-
|
|
160
|
-
if ((0, omni_bridge_sdk.verifyTransferAmount)(actualAmountWithFee, args.feeEstimation.amount, decimals.origin_decimals, decimals.decimals) === false) throw new require_errors.MinWithdrawalAmountError((0, omni_bridge_sdk.getMinimumTransferableAmount)(decimals.origin_decimals, decimals.decimals), actualAmountWithFee, args.assetId);
|
|
159
|
+
if ((0, omni_bridge_sdk.verifyTransferAmount)(args.amount + args.feeEstimation.amount, args.feeEstimation.amount, 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);
|
|
161
160
|
const storageBalance = await require_omni_bridge_utils.getAccountOmniStorageBalance(this.nearProvider, __defuse_protocol_internal_utils.configsByEnvironment[this.env].contractID);
|
|
162
161
|
const intentsNearStorageBalance = storageBalance === null ? 0n : BigInt(storageBalance.available);
|
|
163
162
|
if (intentsNearStorageBalance <= require_omni_bridge_constants.MIN_ALLOWED_STORAGE_BALANCE_FOR_INTENTS_NEAR) throw new require_error.IntentsNearOmniAvailableBalanceTooLowError(intentsNearStorageBalance.toString());
|
|
@@ -178,8 +177,8 @@ var OmniBridge = class {
|
|
|
178
177
|
const utxoProtocolFee = require_estimate_fee.getUnderlyingFee(args.feeEstimation, require_route_enum.RouteEnum.OmniBridge, "utxoProtocolFee");
|
|
179
178
|
(0, __defuse_protocol_internal_utils.assert)(utxoMaxGasFee !== void 0 && utxoMaxGasFee > 0n, `Invalid Omni Bridge utxo max gas fee: expected > 0, got ${utxoMaxGasFee}`);
|
|
180
179
|
(0, __defuse_protocol_internal_utils.assert)(utxoProtocolFee !== void 0 && utxoProtocolFee > 0n, `Invalid Omni Bridge utxo protocol fee: expected > 0, got ${utxoProtocolFee}`);
|
|
181
|
-
const actualAmountWithFee
|
|
182
|
-
if (actualAmountWithFee
|
|
180
|
+
const actualAmountWithFee = args.amount + utxoMaxGasFee + utxoProtocolFee;
|
|
181
|
+
if (actualAmountWithFee < minAmount) throw new require_errors.MinWithdrawalAmountError(minAmount, actualAmountWithFee, args.assetId);
|
|
183
182
|
}
|
|
184
183
|
}
|
|
185
184
|
async estimateWithdrawalFee(args) {
|
|
@@ -154,8 +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
|
-
|
|
158
|
-
if (verifyTransferAmount(actualAmountWithFee, args.feeEstimation.amount, decimals.origin_decimals, decimals.decimals) === false) throw new MinWithdrawalAmountError(getMinimumTransferableAmount(decimals.origin_decimals, decimals.decimals), actualAmountWithFee, args.assetId);
|
|
157
|
+
if (verifyTransferAmount(args.amount + args.feeEstimation.amount, args.feeEstimation.amount, decimals.origin_decimals, decimals.decimals) === false) throw new MinWithdrawalAmountError(getMinimumTransferableAmount(decimals.origin_decimals, decimals.decimals), args.amount, args.assetId);
|
|
159
158
|
const storageBalance = await getAccountOmniStorageBalance(this.nearProvider, configsByEnvironment[this.env].contractID);
|
|
160
159
|
const intentsNearStorageBalance = storageBalance === null ? 0n : BigInt(storageBalance.available);
|
|
161
160
|
if (intentsNearStorageBalance <= MIN_ALLOWED_STORAGE_BALANCE_FOR_INTENTS_NEAR) throw new IntentsNearOmniAvailableBalanceTooLowError(intentsNearStorageBalance.toString());
|
|
@@ -176,8 +175,8 @@ var OmniBridge = class {
|
|
|
176
175
|
const utxoProtocolFee = getUnderlyingFee(args.feeEstimation, RouteEnum.OmniBridge, "utxoProtocolFee");
|
|
177
176
|
assert(utxoMaxGasFee !== void 0 && utxoMaxGasFee > 0n, `Invalid Omni Bridge utxo max gas fee: expected > 0, got ${utxoMaxGasFee}`);
|
|
178
177
|
assert(utxoProtocolFee !== void 0 && utxoProtocolFee > 0n, `Invalid Omni Bridge utxo protocol fee: expected > 0, got ${utxoProtocolFee}`);
|
|
179
|
-
const actualAmountWithFee
|
|
180
|
-
if (actualAmountWithFee
|
|
178
|
+
const actualAmountWithFee = args.amount + utxoMaxGasFee + utxoProtocolFee;
|
|
179
|
+
if (actualAmountWithFee < minAmount) throw new MinWithdrawalAmountError(minAmount, actualAmountWithFee, args.assetId);
|
|
181
180
|
}
|
|
182
181
|
}
|
|
183
182
|
async estimateWithdrawalFee(args) {
|