@forevermoney/sdk 0.5.1 → 0.5.3
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 +19 -0
- package/README.md +65 -4
- package/dist/index.cjs +406 -197
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +88 -28
- package/dist/index.d.ts +88 -28
- package/dist/index.js +410 -201
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.3 — 2026-09-19
|
|
4
|
+
|
|
5
|
+
- Increased EVM-to-Subtensor CCIP destination execution gas from the spoke
|
|
6
|
+
gateways' 300,000 default to an explicit 3,500,000. A 900,000 manual
|
|
7
|
+
execution reached the gateway but still fell back to a claimable booking;
|
|
8
|
+
the same live liquid claim path estimates near 2,560,000 gas. Quotes and
|
|
9
|
+
transaction calldata now use the same exported
|
|
10
|
+
`EVM_TO_SUBTENSOR_DESTINATION_GAS_LIMIT` for zero-fee and partner-fee
|
|
11
|
+
bridges. Callers can override it per transaction with the optional
|
|
12
|
+
`destinationGasLimit` request field, without changing or republishing the
|
|
13
|
+
SDK.
|
|
14
|
+
- Added the explicit-gas `quoteBridgeToFinney` and `bridgeToFinney` overloads
|
|
15
|
+
to the public SpokeGateway ABI.
|
|
16
|
+
|
|
17
|
+
## 0.5.2 — 2026-09-16
|
|
18
|
+
|
|
19
|
+
- Added opt-in stake rounding adjustment to Subtensor bridge preparation, with an explicit disable option and adjusted amount/plan metadata. Searches only on `StrandedStake`, preserves minimum output, requotes candidates and checks source balances, minimum remainders and partner-fee allocations. Approval-required plans are explicitly marked as not yet simulated.
|
|
20
|
+
- Exported the same provider-neutral search (`estimateRoundedStake`), nested revert decoder and dust minimum helper so integrations do not need their own rounding implementation.
|
|
21
|
+
|
|
3
22
|
## 0.5.1 — 2026-09-16
|
|
4
23
|
|
|
5
24
|
- 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.
|
package/README.md
CHANGED
|
@@ -6,10 +6,10 @@ vault contracts.
|
|
|
6
6
|
The SDK owns the canonical production deployment: chain IDs, CCIP selectors,
|
|
7
7
|
contract addresses, ABIs, and protocol-specific amount conversion. An
|
|
8
8
|
integrator supplies only RPC transports and user input. The SDK never accepts a
|
|
9
|
-
private key, signs a transaction, or broadcasts a transaction.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
private key, signs a transaction, or broadcasts a transaction. Network fees are
|
|
10
|
+
charged separately. Subtensor-to-EVM requests accept an explicit minimum output
|
|
11
|
+
to account for native staking rounding; exact output remains the default.
|
|
12
|
+
SDK 0.5.2 also provides opt-in stake rounding preparation (see below).
|
|
13
13
|
|
|
14
14
|
Bridge plans use the current gateways in `contracts.gateway`. Retired gateways
|
|
15
15
|
remain under `contracts.legacyGateways` only so receipts and deliveries of
|
|
@@ -101,6 +101,11 @@ Liquid Base-to-Subtensor delivery requires at least `0.01 TAO` because the
|
|
|
101
101
|
destination vault must unstake the bridged position. The SDK rejects smaller
|
|
102
102
|
liquid deliveries with `AMOUNT_BELOW_MINIMUM` before quoting or planning them;
|
|
103
103
|
staked delivery does not use this liquid-unstaking minimum.
|
|
104
|
+
EVM-to-Subtensor plans quote and encode an explicit 3,500,000 destination gas
|
|
105
|
+
limit so the variable-cost Subtensor exit path can auto-execute through CCIP.
|
|
106
|
+
The policy is exported as `EVM_TO_SUBTENSOR_DESTINATION_GAS_LIMIT`. Pass a
|
|
107
|
+
positive bigint as `destinationGasLimit` to override it for one preparation or
|
|
108
|
+
plan; the SDK uses that value for both the fee quote and transaction calldata.
|
|
104
109
|
The network-fee buffer is 2% and the estimated-gas buffer is 50%; both policies
|
|
105
110
|
are exported as bigint basis-point constants and covered by property tests.
|
|
106
111
|
|
|
@@ -442,3 +447,59 @@ steps are in [`docs/releasing.md`](./docs/releasing.md).
|
|
|
442
447
|
### Minimum bridge output
|
|
443
448
|
|
|
444
449
|
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.
|
|
450
|
+
|
|
451
|
+
### Optional stake rounding adjustment
|
|
452
|
+
|
|
453
|
+
`client.bridge.prepareSubtensorToEvm` (and `prepareSubtensorToBase`) accepts
|
|
454
|
+
`stakeRounding: { enabled: true, positions, minStakeRao }`. Omit it, pass `false`,
|
|
455
|
+
or set `enabled: false` to preserve the exact requested input with no search.
|
|
456
|
+
Synchronous `build*Plan` methods never simulate or adjust amounts.
|
|
457
|
+
|
|
458
|
+
```ts
|
|
459
|
+
import { stakedMinimumOutput } from '@forevermoney/sdk'
|
|
460
|
+
|
|
461
|
+
const prepared = await client.bridge.prepareSubtensorToEvm({
|
|
462
|
+
evmChain: 'base',
|
|
463
|
+
asset: 'sn80',
|
|
464
|
+
source: 'staked',
|
|
465
|
+
sender,
|
|
466
|
+
recipient,
|
|
467
|
+
amountWei,
|
|
468
|
+
stakePulls,
|
|
469
|
+
minAmountOutWei: stakedMinimumOutput(amountWei, stakePulls.length),
|
|
470
|
+
stakeRounding: {
|
|
471
|
+
enabled: true,
|
|
472
|
+
positions, // [{ hotkey, stakeRao }], freshly read source balances
|
|
473
|
+
minStakeRao: 0n, // caller's minimum positive remainder per validator
|
|
474
|
+
},
|
|
475
|
+
})
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
Only `StrandedStake(bytes32,uint256)` triggers adjustment. The SDK reduces the
|
|
479
|
+
named validator's pull by one alpha base unit per attempt, for at most eight
|
|
480
|
+
reductions, re-quotes fees and simulates the exact candidate. It keeps the
|
|
481
|
+
**original absolute minimum output**, checks balances and remaining stake,
|
|
482
|
+
including the partner fee apportioned on top, and propagates unrelated errors.
|
|
483
|
+
The search stops if no valid candidate fits that budget. `stakedMinimumOutput`
|
|
484
|
+
provides an explicit dust tolerance of two base units per source plus two for
|
|
485
|
+
the deposit; tiny inputs retain an exact minimum. It is not a guarantee of
|
|
486
|
+
successful execution.
|
|
487
|
+
|
|
488
|
+
When enabled, `prepared.stakeRounding` reports `requestedAmountWei`, the actual
|
|
489
|
+
`amountWei`, `minAmountOutWei`, `pulls`, and `simulationComplete`. Display the
|
|
490
|
+
returned amount and use **the returned plan**, rather than rebuilding from the
|
|
491
|
+
original request. If approval is required, `simulationComplete` is false:
|
|
492
|
+
confirm approval, refresh balances, and prepare again before sending the bridge.
|
|
493
|
+
Revalidate before signing; if the amount changes again, show it for review.
|
|
494
|
+
Keep the original `minAmountOutWei` when re-preparing an adjusted amount so
|
|
495
|
+
successive attempts cannot gradually lower output protection. Never automatically
|
|
496
|
+
retry a broadcast transaction.
|
|
497
|
+
|
|
498
|
+
For custom ethers/wallet quote flows, the SDK also exports
|
|
499
|
+
`estimateRoundedStake({ amountWei, minAmountOutWei, pulls, positions,
|
|
500
|
+
minStakeRao, adjustRounding, partnerFeeBps, quoteAndEstimate, isActive })`.
|
|
501
|
+
`adjustRounding` defaults to true **for this explicitly invoked helper**; false
|
|
502
|
+
performs one exact estimate. Its callback must quote and estimate the supplied
|
|
503
|
+
candidate and minimum, and must never sign or broadcast. An optional `isActive`
|
|
504
|
+
callback stops obsolete work between requests. `strandedStakeSource(error)`
|
|
505
|
+
decodes nested RPC/ethers/viem errors for UI error messages.
|