@forevermoney/sdk 0.5.0 → 0.5.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/CHANGELOG.md +4 -0
- package/README.md +4 -0
- package/dist/index.cjs +15 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.1 — 2026-09-16
|
|
4
|
+
|
|
5
|
+
- Added optional `minAmountOutWei` to Subtensor-to-EVM bridge requests. Callers can explicitly bound output slippage, including staking rounding dust. Defaults to the input amount; rejects zero, negative, non-bigint, and above-input minima before RPC calls. The same minimum is used for gas estimation and final calldata, for single- and multi-validator routes with or without partner fees.
|
|
6
|
+
|
|
3
7
|
## 0.5.0 — 2026-09-16
|
|
4
8
|
|
|
5
9
|
- Staked bridges from Subtensor can pull from several validators. Pass
|
package/README.md
CHANGED
|
@@ -438,3 +438,7 @@ testing are documented in [`docs/testing.md`](./docs/testing.md).
|
|
|
438
438
|
|
|
439
439
|
Security reports should follow [`SECURITY.md`](./SECURITY.md). Maintainer release
|
|
440
440
|
steps are in [`docs/releasing.md`](./docs/releasing.md).
|
|
441
|
+
|
|
442
|
+
### Minimum bridge output
|
|
443
|
+
|
|
444
|
+
Subtensor-to-EVM builders and preparation methods accept optional `minAmountOutWei` (destination token units, 18 decimals, after partner fees). It must be positive and no greater than `amountWei`; omission preserves the exact-output default. Choose the minimum explicitly to cover your acceptable slippage or native staking rounding dust. The SDK uses the same value for gas estimation and final transaction calldata. For example, `minAmountOutWei: amountWei - 4n * EVM_WEI_PER_RAO` allows four native RAO of dust when the amount exceeds that budget. This does not change the input amount or approval amount.
|
package/dist/index.cjs
CHANGED
|
@@ -721,6 +721,17 @@ function stakePullsFor(input, amountRao) {
|
|
|
721
721
|
}
|
|
722
722
|
return resolveStakePulls(input.stakePulls, amountRao);
|
|
723
723
|
}
|
|
724
|
+
function minimumSubtensorOutput(input) {
|
|
725
|
+
const minimum = input.minAmountOutWei ?? input.amountWei;
|
|
726
|
+
assertNonNegativeAmount(minimum, "Minimum output");
|
|
727
|
+
if (minimum === 0n || minimum > input.amountWei) {
|
|
728
|
+
throw new ForeverMoneyError(
|
|
729
|
+
"INVALID_TRANSACTION_PLAN",
|
|
730
|
+
"Minimum output must be positive and no greater than the input amount."
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
return minimum;
|
|
734
|
+
}
|
|
724
735
|
function assertDelivery(value) {
|
|
725
736
|
if (value !== "liquid" && value !== "staked") {
|
|
726
737
|
throw new ForeverMoneyError(
|
|
@@ -999,6 +1010,7 @@ function buildSubtensorToEvmPlan(input) {
|
|
|
999
1010
|
assertAssetMode(input.asset, input.source);
|
|
1000
1011
|
const netuid = sourceNetuid(input);
|
|
1001
1012
|
assertSubtensorToEvmAmount(input.amountWei, input.source);
|
|
1013
|
+
const minAmountOutWei = minimumSubtensorOutput(input);
|
|
1002
1014
|
assertNonNegativeAmount(input.exactNetworkFeeWei, "Network fee");
|
|
1003
1015
|
const { subtensor } = foreverMoneyDeployment;
|
|
1004
1016
|
const evm = getForeverMoneyEvmDeployment(input.evmChain);
|
|
@@ -1063,7 +1075,7 @@ function buildSubtensorToEvmPlan(input) {
|
|
|
1063
1075
|
recipient,
|
|
1064
1076
|
taoAmount,
|
|
1065
1077
|
stakedAlphaRao,
|
|
1066
|
-
|
|
1078
|
+
minAmountOutWei,
|
|
1067
1079
|
partnerFee,
|
|
1068
1080
|
pulls
|
|
1069
1081
|
),
|
|
@@ -1163,6 +1175,7 @@ async function prepareSubtensorToEvm(provider, input) {
|
|
|
1163
1175
|
assertAssetMode(input.asset, input.source);
|
|
1164
1176
|
const netuid = sourceNetuid(input);
|
|
1165
1177
|
assertSubtensorToEvmAmount(input.amountWei, input.source);
|
|
1178
|
+
const minAmountOutWei = minimumSubtensorOutput(input);
|
|
1166
1179
|
const { subtensor } = foreverMoneyDeployment;
|
|
1167
1180
|
const evm = getForeverMoneyEvmDeployment(input.evmChain);
|
|
1168
1181
|
const partnerFee = resolvePartnerFee(
|
|
@@ -1216,7 +1229,7 @@ async function prepareSubtensorToEvm(provider, input) {
|
|
|
1216
1229
|
recipient,
|
|
1217
1230
|
taoAmount,
|
|
1218
1231
|
stakedAlphaRao,
|
|
1219
|
-
|
|
1232
|
+
minAmountOutWei,
|
|
1220
1233
|
partnerFee,
|
|
1221
1234
|
stakePullsFor(input, stakedAlphaRao)
|
|
1222
1235
|
),
|