@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/dist/index.d.cts
CHANGED
|
@@ -154,6 +154,11 @@ interface EvmToSubtensorRequest {
|
|
|
154
154
|
readonly delivery: SubtensorDelivery;
|
|
155
155
|
}
|
|
156
156
|
interface SubtensorToEvmRequest {
|
|
157
|
+
/** Minimum destination-token output in 18-decimal wei, after partner fees.
|
|
158
|
+
* Defaults to amountWei. Must be positive and no greater than amountWei.
|
|
159
|
+
* Callers choose their tolerance explicitly, including staking rounding dust.
|
|
160
|
+
*/
|
|
161
|
+
readonly minAmountOutWei?: bigint;
|
|
157
162
|
readonly evmChain: ForeverMoneyEvmChain;
|
|
158
163
|
readonly asset?: BridgeAsset;
|
|
159
164
|
readonly partnerFee?: PartnerFee;
|
package/dist/index.d.ts
CHANGED
|
@@ -154,6 +154,11 @@ interface EvmToSubtensorRequest {
|
|
|
154
154
|
readonly delivery: SubtensorDelivery;
|
|
155
155
|
}
|
|
156
156
|
interface SubtensorToEvmRequest {
|
|
157
|
+
/** Minimum destination-token output in 18-decimal wei, after partner fees.
|
|
158
|
+
* Defaults to amountWei. Must be positive and no greater than amountWei.
|
|
159
|
+
* Callers choose their tolerance explicitly, including staking rounding dust.
|
|
160
|
+
*/
|
|
161
|
+
readonly minAmountOutWei?: bigint;
|
|
157
162
|
readonly evmChain: ForeverMoneyEvmChain;
|
|
158
163
|
readonly asset?: BridgeAsset;
|
|
159
164
|
readonly partnerFee?: PartnerFee;
|
package/dist/index.js
CHANGED
|
@@ -651,6 +651,17 @@ function stakePullsFor(input, amountRao) {
|
|
|
651
651
|
}
|
|
652
652
|
return resolveStakePulls(input.stakePulls, amountRao);
|
|
653
653
|
}
|
|
654
|
+
function minimumSubtensorOutput(input) {
|
|
655
|
+
const minimum = input.minAmountOutWei ?? input.amountWei;
|
|
656
|
+
assertNonNegativeAmount(minimum, "Minimum output");
|
|
657
|
+
if (minimum === 0n || minimum > input.amountWei) {
|
|
658
|
+
throw new ForeverMoneyError(
|
|
659
|
+
"INVALID_TRANSACTION_PLAN",
|
|
660
|
+
"Minimum output must be positive and no greater than the input amount."
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
return minimum;
|
|
664
|
+
}
|
|
654
665
|
function assertDelivery(value) {
|
|
655
666
|
if (value !== "liquid" && value !== "staked") {
|
|
656
667
|
throw new ForeverMoneyError(
|
|
@@ -929,6 +940,7 @@ function buildSubtensorToEvmPlan(input) {
|
|
|
929
940
|
assertAssetMode(input.asset, input.source);
|
|
930
941
|
const netuid = sourceNetuid(input);
|
|
931
942
|
assertSubtensorToEvmAmount(input.amountWei, input.source);
|
|
943
|
+
const minAmountOutWei = minimumSubtensorOutput(input);
|
|
932
944
|
assertNonNegativeAmount(input.exactNetworkFeeWei, "Network fee");
|
|
933
945
|
const { subtensor } = foreverMoneyDeployment;
|
|
934
946
|
const evm = getForeverMoneyEvmDeployment(input.evmChain);
|
|
@@ -993,7 +1005,7 @@ function buildSubtensorToEvmPlan(input) {
|
|
|
993
1005
|
recipient,
|
|
994
1006
|
taoAmount,
|
|
995
1007
|
stakedAlphaRao,
|
|
996
|
-
|
|
1008
|
+
minAmountOutWei,
|
|
997
1009
|
partnerFee,
|
|
998
1010
|
pulls
|
|
999
1011
|
),
|
|
@@ -1093,6 +1105,7 @@ async function prepareSubtensorToEvm(provider, input) {
|
|
|
1093
1105
|
assertAssetMode(input.asset, input.source);
|
|
1094
1106
|
const netuid = sourceNetuid(input);
|
|
1095
1107
|
assertSubtensorToEvmAmount(input.amountWei, input.source);
|
|
1108
|
+
const minAmountOutWei = minimumSubtensorOutput(input);
|
|
1096
1109
|
const { subtensor } = foreverMoneyDeployment;
|
|
1097
1110
|
const evm = getForeverMoneyEvmDeployment(input.evmChain);
|
|
1098
1111
|
const partnerFee = resolvePartnerFee(
|
|
@@ -1146,7 +1159,7 @@ async function prepareSubtensorToEvm(provider, input) {
|
|
|
1146
1159
|
recipient,
|
|
1147
1160
|
taoAmount,
|
|
1148
1161
|
stakedAlphaRao,
|
|
1149
|
-
|
|
1162
|
+
minAmountOutWei,
|
|
1150
1163
|
partnerFee,
|
|
1151
1164
|
stakePullsFor(input, stakedAlphaRao)
|
|
1152
1165
|
),
|