@forevermoney/sdk 0.2.0 → 0.5.0

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/index.d.cts CHANGED
@@ -16,12 +16,12 @@ declare function feeWithBuffer(fee: bigint): bigint;
16
16
  declare function gasLimitWithBuffer(gasLimit: bigint): bigint;
17
17
 
18
18
  declare const foreverMoneyAbis: Readonly<{
19
- alphaGateway: readonly ["function ROUTER() view returns (address)", "function allowedLane(uint64 selector) view returns (bool)", "function quoteBridgeOut(uint64 destSelector,address token,address recipient,uint256 mintedAmount) view returns (uint256 fee)", "function bridgeOut(uint64 destSelector,address token,address recipient,uint256 taoAmount,uint256 stakedAlphaRao,uint256 minTokenOut) payable returns (bytes32 messageId)", "function claimLiquid(address token,uint256 minTaoOut,address to)", "function claimNative(address to)", "function claimStaked(address token,bytes32 destColdkey,address to)", "function claimToken(address token,address to)", "function claimableNative(address account) view returns (uint256)", "function claimableToken(address account,address token) view returns (uint256)", "event BridgedOut(uint64 destChainSelector,address indexed token,address indexed sender,address indexed recipient,uint256 minted,bytes32 messageId)", "event Claimable(address indexed token,address indexed user,uint256 native,uint256 wsn)", "event DeliveredLiquid(address indexed token,bytes32 indexed ss58,uint256 taoOut)", "event DeliveredStaked(address indexed token,bytes32 indexed ss58,uint256 alphaRao)"];
19
+ alphaGateway: readonly ["function ROUTER() view returns (address)", "function allowedLane(uint64 selector) view returns (bool)", "function maxIntegratorFeeBps() view returns (uint16)", "function bridgeFeeBps() view returns (uint16)", "function integratorTaoTopUp(uint256 taoAmount,uint16 bps) pure returns (uint256)", "function quoteBridgeOut(uint64 destSelector,address token,address recipient,uint256 mintedAmount) view returns (uint256 fee)", "function bridgeOut(uint64 destSelector,address token,address recipient,uint256 taoAmount,uint256 stakedAlphaRao,uint256 minTokenOut) payable returns (bytes32 messageId)", "function integratorCut(uint256 amount,uint16 bps) pure returns (uint256)", "function quoteBridgeOutWithFee(uint64 destSelector,address token,address recipient,uint256 mintedAmount,uint256 taoAmount,uint256 stakedAlphaRao,(address recipient,uint16 bps) integrator) view returns (uint256 fee,uint256 nativeTopUp,uint256 alphaTopUp,uint256 amountCrossing)", "function bridgeOutWithFee(uint64 destSelector,address token,address recipient,uint256 taoAmount,uint256 stakedAlphaRao,uint256 minTokenOut,(address recipient,uint16 bps) integrator) payable returns (bytes32 messageId)", "function bridgeOutFromValidators(uint64 destSelector,address token,address recipient,uint256 taoAmount,(bytes32 validator,uint256 alphaRao)[] sources,uint256 minTokenOut) payable returns (bytes32 messageId)", "function bridgeOutFromValidatorsWithFee(uint64 destSelector,address token,address recipient,uint256 taoAmount,(bytes32 validator,uint256 alphaRao)[] sources,uint256 minTokenOut,(address recipient,uint16 bps) integrator) payable returns (bytes32 messageId)", "function minStakeRequired() view returns (uint256)", "function MAX_STAKE_SOURCES() view returns (uint256)", "function GATEWAY_COLDKEY() view returns (bytes32)", "function claimLiquid(address token,uint256 minTaoOut,address to)", "function claimNative(address to)", "function claimStaked(address token,bytes32 destColdkey,address to)", "function claimToken(address token,address to)", "function claimableNative(address account) view returns (uint256)", "function claimableToken(address token,address account) view returns (uint256)", "event BridgedOut(uint64 destChainSelector,address indexed token,address indexed sender,address indexed recipient,uint256 minted,bytes32 messageId)", "event Claimable(address indexed token,address indexed user,uint256 native,uint256 wsn)", "event NotDelivered(uint64 indexed sourceChainSelector,address indexed token,uint256 amount,uint8 reason)", "event DeliveredLiquid(address indexed token,bytes32 indexed ss58,uint256 taoOut)", "event DeliveredStaked(address indexed token,bytes32 indexed ss58,uint256 alphaRao)"];
20
20
  alphaVault: readonly ["function isPaused() view returns (bool)", "function pausedUntil() view returns (uint256)", "function isListed(address token) view returns (bool)", "function backing(address token) view returns (uint256 stakedAlpha)", "function positionOf(address token) view returns (bytes32 validator,uint256 netuid)"];
21
21
  ccipExecution: readonly ["event ExecutionStateChanged(uint64 indexed sourceChainSelector,uint64 indexed sequenceNumber,bytes32 indexed messageId,bytes32 messageHash,uint8 state,bytes returnData,uint256 gasUsed)"];
22
22
  ccipRouter: readonly ["function isOffRamp(uint64 sourceChainSelector,address offRamp) view returns (bool)"];
23
23
  erc20: readonly ["function allowance(address owner,address spender) view returns (uint256)", "function approve(address spender,uint256 amount) returns (bool)", "function balanceOf(address account) view returns (uint256)"];
24
- spokeGateway: readonly ["function ROUTER() view returns (address)", "function BITTENSOR_SELECTOR() view returns (uint64)", "function SUBTENSOR_GATEWAY() view returns (address)", "function quoteBridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit) view returns (uint256 fee)", "function bridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit) payable returns (bytes32 messageId)", "event BridgedToFinney(address indexed token,address indexed sender,bytes32 indexed ss58,uint256 amount,bytes32 messageId)"];
24
+ spokeGateway: readonly ["function ROUTER() view returns (address)", "function BITTENSOR_SELECTOR() view returns (uint64)", "function SUBTENSOR_GATEWAY() view returns (address)", "function maxIntegratorFeeBps() view returns (uint16)", "function bridgeFeeBps() view returns (uint16)", "function quoteBridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit) view returns (uint256 fee)", "function bridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit) payable returns (bytes32 messageId)", "function quoteBridgeToFinneyWithFee(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit,uint256 gasLimit,(address recipient,uint16 bps) integrator) view returns (uint256 fee,uint256 cut,uint256 amountCrossing)", "function bridgeToFinneyWithFee(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit,uint256 gasLimit,(address recipient,uint16 bps) integrator) payable returns (bytes32 messageId)", "event BridgedToFinney(address indexed token,address indexed sender,bytes32 indexed ss58,uint256 amount,bytes32 messageId)"];
25
25
  staking: readonly ["function allowance(address sourceAddress,address spenderAddress,uint256 netuid) view returns (uint256)", "function approve(address spenderAddress,uint256 netuid,uint256 absoluteAmount)", "function getStake(bytes32 hotkey,bytes32 coldkey,uint256 netuid) view returns (uint256)"];
26
26
  vaultFactory: readonly ["function create(address owner,bytes32 associatedMiner,address akAddress,address poolManager,address poolAddress,address positionManagerImpl,(address token,uint256 amount)[] stashTokens) payable returns (address manager)", "event SnLiquidityManagerCreated(address indexed manager,address indexed owner,bytes32 associatedMiner,address akAddress,address poolAddress,address poolManager,address positionManager)"];
27
27
  vaultManager: readonly ["function claimFees(address akAddress)", "function topUpAk(address akAddress,address token,uint256 amount) payable", "function withdrawFromAkAndPositions(address akAddress,uint256 amount0,uint256 amount1,uint256[] decreaseTokenIds,bool unwrapETH)", "function stake(address akAddress,bytes data)", "function unstake(address akAddress,bytes data)", "function owner() view returns (address)", "event AKStashTopUp(address akAddress,address token,uint256 amount)", "event AKStashWithdraw(address akAddress,address token,uint256 amount)"];
@@ -35,9 +35,10 @@ declare const ROBINHOOD_CCIP_SELECTOR = 6180753054346818345n;
35
35
  declare const SUBTENSOR_CCIP_SELECTOR = 2135107236357186872n;
36
36
  declare const RAO_PER_TAO = 1000000000n;
37
37
  declare const EVM_WEI_PER_RAO = 1000000000n;
38
- declare const FOREVERMONEY_DEPLOYMENT_VERSION: "1.1.0";
38
+ declare const SN80_NETUID = 80n;
39
+ declare const FOREVERMONEY_DEPLOYMENT_VERSION: "1.3.0";
39
40
  declare const foreverMoneyDeployment: Readonly<{
40
- version: "1.1.0";
41
+ version: "1.3.0";
41
42
  base: Readonly<{
42
43
  key: "base";
43
44
  name: "Base";
@@ -45,7 +46,9 @@ declare const foreverMoneyDeployment: Readonly<{
45
46
  ccipSelector: 15971525489660198786n;
46
47
  contracts: Readonly<{
47
48
  gateway: `0x${string}`;
49
+ legacyGateways: readonly `0x${string}`[];
48
50
  wrappedTao: `0x${string}`;
51
+ wrappedSn80: `0x${string}`;
49
52
  ccipRouter: `0x${string}`;
50
53
  ccipOffRampFromSubtensor: `0x${string}`;
51
54
  vaultFactory: `0x${string}`;
@@ -62,6 +65,7 @@ declare const foreverMoneyDeployment: Readonly<{
62
65
  ccipSelector: 6180753054346818345n;
63
66
  contracts: Readonly<{
64
67
  gateway: `0x${string}`;
68
+ legacyGateways: readonly `0x${string}`[];
65
69
  wrappedTao: `0x${string}`;
66
70
  ccipRouter: `0x${string}`;
67
71
  ccipOffRampFromSubtensor: `0x${string}`;
@@ -72,8 +76,10 @@ declare const foreverMoneyDeployment: Readonly<{
72
76
  ccipSelector: 2135107236357186872n;
73
77
  contracts: Readonly<{
74
78
  gateway: `0x${string}`;
79
+ legacyGateways: readonly `0x${string}`[];
75
80
  alphaVault: `0x${string}`;
76
81
  wrappedTao: `0x${string}`;
82
+ wrappedSn80: `0x${string}`;
77
83
  ccipRouter: `0x${string}`;
78
84
  ccipOffRampFromBase: `0x${string}`;
79
85
  ccipOffRampFromRobinhood: `0x${string}`;
@@ -111,10 +117,37 @@ interface TransactionPlan {
111
117
 
112
118
  declare const MIN_LIQUID_EVM_TO_SUBTENSOR_WEI = 10000000000000000n;
113
119
  declare const MIN_LIQUID_BASE_TO_SUBTENSOR_WEI = 10000000000000000n;
120
+ declare const MIN_LIQUID_SUBTENSOR_TO_EVM_WEI: bigint;
114
121
  type SubtensorDelivery = 'liquid' | 'staked';
115
122
  type SubtensorSource = 'liquid' | 'staked';
123
+ type BridgeAsset = 'tao' | 'sn80';
124
+ /**
125
+ * Optional partner (integrator) fee, charged ON TOP of the bridged amount and
126
+ * paid to `recipient` on the source chain. The full `amountWei` still crosses.
127
+ * `bps` is in basis points (1 = 0.01%); the gateway caps it at
128
+ * `maxIntegratorFeeBps`, which `prepare*` reads and enforces.
129
+ */
130
+ interface PartnerFee {
131
+ readonly recipient: string;
132
+ readonly bps: number;
133
+ }
134
+ declare const MAX_PARTNER_FEE_BPS = 10000;
135
+ /**
136
+ * One staked position to pull from when bridging staked alpha from Subtensor:
137
+ * the validator hotkey the caller's stake sits on and how much of it to take.
138
+ * The gateway re-delegates every pull to the token's canonical validator
139
+ * before depositing, so stake with any validator can be bridged.
140
+ */
141
+ interface StakePull {
142
+ readonly hotkey: string;
143
+ readonly amountRao: bigint;
144
+ }
145
+ /** Gateway limit on positions per bridge (`AlphaGateway.MAX_STAKE_SOURCES`). */
146
+ declare const MAX_STAKE_PULLS = 16;
116
147
  interface EvmToSubtensorRequest {
117
148
  readonly evmChain: ForeverMoneyEvmChain;
149
+ readonly asset?: BridgeAsset;
150
+ readonly partnerFee?: PartnerFee;
118
151
  readonly sender: string;
119
152
  readonly amountWei: bigint;
120
153
  readonly destination: string;
@@ -122,19 +155,39 @@ interface EvmToSubtensorRequest {
122
155
  }
123
156
  interface SubtensorToEvmRequest {
124
157
  readonly evmChain: ForeverMoneyEvmChain;
158
+ readonly asset?: BridgeAsset;
159
+ readonly partnerFee?: PartnerFee;
125
160
  readonly sender: string;
126
161
  readonly recipient: string;
127
162
  readonly amountWei: bigint;
128
163
  readonly source: SubtensorSource;
129
164
  readonly netuid?: bigint;
165
+ /**
166
+ * For a staked source: the positions to pull, summing to `amountWei` in
167
+ * RAO. Omit when the stake already sits on the token's canonical validator.
168
+ * With a partner fee, the cut is charged on top and spread across the pulls
169
+ * in proportion to their amounts, so each position must hold its amount
170
+ * plus its share of the cut.
171
+ */
172
+ readonly stakePulls?: readonly StakePull[];
130
173
  }
131
174
  type BaseToSubtensorRequest = Omit<EvmToSubtensorRequest, 'evmChain'>;
132
175
  type SubtensorToBaseRequest = Omit<SubtensorToEvmRequest, 'evmChain'>;
133
176
  interface BridgePreparation {
134
177
  readonly exactNetworkFeeWei: bigint;
135
178
  readonly transactionValueWei: bigint;
179
+ /**
180
+ * Extra the sender pays for the partner fee, in the units of the source leg:
181
+ * token wei for an EVM source, alpha (as 18-decimal wei) for a staked source,
182
+ * TAO wei for a liquid source. Zero when no partner fee is set.
183
+ */
184
+ readonly partnerFeeWei: bigint;
136
185
  readonly plan: TransactionPlan;
137
186
  }
187
+ /** `bps` of `amount`, rounded down: the extra token (spoke) or alpha (hub) pulled on top. */
188
+ declare function partnerFeeCut(amount: bigint, bps: number): bigint;
189
+ /** Extra native TAO a liquid Subtensor source carries for the partner, rounded up to a whole RAO. */
190
+ declare function partnerFeeTaoTopUp(taoAmount: bigint, bps: number): bigint;
138
191
  interface BuildEvmToSubtensorPlanRequest extends EvmToSubtensorRequest {
139
192
  readonly allowanceWei: bigint;
140
193
  readonly exactNetworkFeeWei: bigint;
@@ -294,7 +347,7 @@ interface ForeverMoneyClient {
294
347
  }
295
348
  declare function createForeverMoneyClient(options: ForeverMoneyClientOptions): ForeverMoneyClient;
296
349
 
297
- type ForeverMoneyErrorCode = 'AMOUNT_BELOW_MINIMUM' | 'AMOUNT_NOT_WHOLE_RAO' | 'AMOUNT_ZERO' | 'CHAIN_MISMATCH' | 'INVALID_ADDRESS' | 'INVALID_BYTES32' | 'INVALID_PROVIDER_RESPONSE' | 'INVALID_SS58' | 'INVALID_TRANSACTION_PLAN' | 'MISSING_TRANSPORT' | 'RPC_ERROR' | 'SIMULATION_REVERTED';
350
+ type ForeverMoneyErrorCode = 'AMOUNT_BELOW_MINIMUM' | 'AMOUNT_NOT_WHOLE_RAO' | 'AMOUNT_ZERO' | 'CHAIN_MISMATCH' | 'INVALID_ADDRESS' | 'INVALID_BYTES32' | 'INVALID_PARTNER_FEE' | 'INVALID_PROVIDER_RESPONSE' | 'INVALID_SS58' | 'INVALID_TRANSACTION_PLAN' | 'MISSING_TRANSPORT' | 'RPC_ERROR' | 'SIMULATION_REVERTED';
298
351
  declare class ForeverMoneyError extends Error {
299
352
  readonly code: ForeverMoneyErrorCode;
300
353
  readonly details: Readonly<Record<string, unknown>> | undefined;
@@ -330,4 +383,4 @@ interface ViemTransactionRequest {
330
383
  }
331
384
  declare function toViemTransaction(transaction: PreparedTransaction): Readonly<ViemTransactionRequest>;
332
385
 
333
- export { BASE_CCIP_SELECTOR, BASE_CHAIN_ID, BASIS_POINTS, type BaseToSubtensorRequest, type BridgeDirection, type BridgePreparation, type BridgeSourceStatus, type BridgeSourceStatusRequest, type BridgeSourceTransactionStatus, type BuildBaseToSubtensorPlanRequest, type BuildEvmToSubtensorPlanRequest, type BuildSubtensorToBasePlanRequest, type BuildSubtensorToEvmPlanRequest, type CcipDeliveryCheckpoint, type CcipDeliveryStatus, type CcipDeliveryStatusRequest, type CreateVaultRequest, type DepositVaultRequest, EVM_WEI_PER_RAO, type Eip1193TransactionRequest, type EthersCompatibleTransactionRequest, type EvmToSubtensorRequest, FOREVERMONEY_DEPLOYMENT_VERSION, type ForeverMoneyClient, type ForeverMoneyClientOptions, type ForeverMoneyDeployment, ForeverMoneyError, type ForeverMoneyErrorCode, type ForeverMoneyEvmChain, GAS_LIMIT_BUFFER_BPS, type HttpTransportOptions, type LegacyRpcProvider, MIN_LIQUID_BASE_TO_SUBTENSOR_WEI, MIN_LIQUID_EVM_TO_SUBTENSOR_WEI, NETWORK_FEE_BUFFER_BPS, type PreparedTransaction, RAO_PER_TAO, ROBINHOOD_CCIP_SELECTOR, ROBINHOOD_CHAIN_ID, type ReceiptLog, type RpcRequest, type RpcTransport, SUBTENSOR_CCIP_SELECTOR, SUBTENSOR_CHAIN_ID, type SubtensorDelivery, type SubtensorSource, type SubtensorToBaseRequest, type SubtensorToEvmRequest, type TrackingProvider, type TransactionAction, type TransactionPlan, type TransactionReceiptLike, type TransactionStep, type TransactionStepKind, type VaultStashToken, type VaultTokenAllowance, type ViemTransactionRequest, type WithdrawVaultRequest, assertWholeRao, bridgeMessageIdFromReceipt, buildBaseToSubtensorPlan, buildClaimVaultFeesPlan, buildCreateVaultPlan, buildDepositVaultPlan, buildEvmToSubtensorPlan, buildSetVaultStakingPlan, buildSubtensorToBasePlan, buildSubtensorToEvmPlan, buildWithdrawVaultPlan, createForeverMoneyClient, destinationChainId, evmChainFromBridgeDirection, evmToMirrorSS58, feeWithBuffer, foreverMoneyAbis, foreverMoneyDeployment, formatTaoAmount, gasLimitWithBuffer, getBridgeSourceStatus, getCcipDeliveryCheckpoint, getCcipDeliveryStatus, getForeverMoneyEvmDeployment, http, isBittensorSS58, isEvmToSubtensorDirection, normalizeEvmAddress, normalizeSS58, parseTaoAmount, sourceChainId, ss58ToPublicKey, toEip1193Transaction, toEthersTransaction, toViemTransaction, vaultManagerFromCreationReceipt };
386
+ export { BASE_CCIP_SELECTOR, BASE_CHAIN_ID, BASIS_POINTS, type BaseToSubtensorRequest, type BridgeAsset, type BridgeDirection, type BridgePreparation, type BridgeSourceStatus, type BridgeSourceStatusRequest, type BridgeSourceTransactionStatus, type BuildBaseToSubtensorPlanRequest, type BuildEvmToSubtensorPlanRequest, type BuildSubtensorToBasePlanRequest, type BuildSubtensorToEvmPlanRequest, type CcipDeliveryCheckpoint, type CcipDeliveryStatus, type CcipDeliveryStatusRequest, type CreateVaultRequest, type DepositVaultRequest, EVM_WEI_PER_RAO, type Eip1193TransactionRequest, type EthersCompatibleTransactionRequest, type EvmToSubtensorRequest, FOREVERMONEY_DEPLOYMENT_VERSION, type ForeverMoneyClient, type ForeverMoneyClientOptions, type ForeverMoneyDeployment, ForeverMoneyError, type ForeverMoneyErrorCode, type ForeverMoneyEvmChain, GAS_LIMIT_BUFFER_BPS, type HttpTransportOptions, type LegacyRpcProvider, MAX_PARTNER_FEE_BPS, MAX_STAKE_PULLS, MIN_LIQUID_BASE_TO_SUBTENSOR_WEI, MIN_LIQUID_EVM_TO_SUBTENSOR_WEI, MIN_LIQUID_SUBTENSOR_TO_EVM_WEI, NETWORK_FEE_BUFFER_BPS, type PartnerFee, type PreparedTransaction, RAO_PER_TAO, ROBINHOOD_CCIP_SELECTOR, ROBINHOOD_CHAIN_ID, type ReceiptLog, type RpcRequest, type RpcTransport, SN80_NETUID, SUBTENSOR_CCIP_SELECTOR, SUBTENSOR_CHAIN_ID, type StakePull, type SubtensorDelivery, type SubtensorSource, type SubtensorToBaseRequest, type SubtensorToEvmRequest, type TrackingProvider, type TransactionAction, type TransactionPlan, type TransactionReceiptLike, type TransactionStep, type TransactionStepKind, type VaultStashToken, type VaultTokenAllowance, type ViemTransactionRequest, type WithdrawVaultRequest, assertWholeRao, bridgeMessageIdFromReceipt, buildBaseToSubtensorPlan, buildClaimVaultFeesPlan, buildCreateVaultPlan, buildDepositVaultPlan, buildEvmToSubtensorPlan, buildSetVaultStakingPlan, buildSubtensorToBasePlan, buildSubtensorToEvmPlan, buildWithdrawVaultPlan, createForeverMoneyClient, destinationChainId, evmChainFromBridgeDirection, evmToMirrorSS58, feeWithBuffer, foreverMoneyAbis, foreverMoneyDeployment, formatTaoAmount, gasLimitWithBuffer, getBridgeSourceStatus, getCcipDeliveryCheckpoint, getCcipDeliveryStatus, getForeverMoneyEvmDeployment, http, isBittensorSS58, isEvmToSubtensorDirection, normalizeEvmAddress, normalizeSS58, parseTaoAmount, partnerFeeCut, partnerFeeTaoTopUp, sourceChainId, ss58ToPublicKey, toEip1193Transaction, toEthersTransaction, toViemTransaction, vaultManagerFromCreationReceipt };
package/dist/index.d.ts CHANGED
@@ -16,12 +16,12 @@ declare function feeWithBuffer(fee: bigint): bigint;
16
16
  declare function gasLimitWithBuffer(gasLimit: bigint): bigint;
17
17
 
18
18
  declare const foreverMoneyAbis: Readonly<{
19
- alphaGateway: readonly ["function ROUTER() view returns (address)", "function allowedLane(uint64 selector) view returns (bool)", "function quoteBridgeOut(uint64 destSelector,address token,address recipient,uint256 mintedAmount) view returns (uint256 fee)", "function bridgeOut(uint64 destSelector,address token,address recipient,uint256 taoAmount,uint256 stakedAlphaRao,uint256 minTokenOut) payable returns (bytes32 messageId)", "function claimLiquid(address token,uint256 minTaoOut,address to)", "function claimNative(address to)", "function claimStaked(address token,bytes32 destColdkey,address to)", "function claimToken(address token,address to)", "function claimableNative(address account) view returns (uint256)", "function claimableToken(address account,address token) view returns (uint256)", "event BridgedOut(uint64 destChainSelector,address indexed token,address indexed sender,address indexed recipient,uint256 minted,bytes32 messageId)", "event Claimable(address indexed token,address indexed user,uint256 native,uint256 wsn)", "event DeliveredLiquid(address indexed token,bytes32 indexed ss58,uint256 taoOut)", "event DeliveredStaked(address indexed token,bytes32 indexed ss58,uint256 alphaRao)"];
19
+ alphaGateway: readonly ["function ROUTER() view returns (address)", "function allowedLane(uint64 selector) view returns (bool)", "function maxIntegratorFeeBps() view returns (uint16)", "function bridgeFeeBps() view returns (uint16)", "function integratorTaoTopUp(uint256 taoAmount,uint16 bps) pure returns (uint256)", "function quoteBridgeOut(uint64 destSelector,address token,address recipient,uint256 mintedAmount) view returns (uint256 fee)", "function bridgeOut(uint64 destSelector,address token,address recipient,uint256 taoAmount,uint256 stakedAlphaRao,uint256 minTokenOut) payable returns (bytes32 messageId)", "function integratorCut(uint256 amount,uint16 bps) pure returns (uint256)", "function quoteBridgeOutWithFee(uint64 destSelector,address token,address recipient,uint256 mintedAmount,uint256 taoAmount,uint256 stakedAlphaRao,(address recipient,uint16 bps) integrator) view returns (uint256 fee,uint256 nativeTopUp,uint256 alphaTopUp,uint256 amountCrossing)", "function bridgeOutWithFee(uint64 destSelector,address token,address recipient,uint256 taoAmount,uint256 stakedAlphaRao,uint256 minTokenOut,(address recipient,uint16 bps) integrator) payable returns (bytes32 messageId)", "function bridgeOutFromValidators(uint64 destSelector,address token,address recipient,uint256 taoAmount,(bytes32 validator,uint256 alphaRao)[] sources,uint256 minTokenOut) payable returns (bytes32 messageId)", "function bridgeOutFromValidatorsWithFee(uint64 destSelector,address token,address recipient,uint256 taoAmount,(bytes32 validator,uint256 alphaRao)[] sources,uint256 minTokenOut,(address recipient,uint16 bps) integrator) payable returns (bytes32 messageId)", "function minStakeRequired() view returns (uint256)", "function MAX_STAKE_SOURCES() view returns (uint256)", "function GATEWAY_COLDKEY() view returns (bytes32)", "function claimLiquid(address token,uint256 minTaoOut,address to)", "function claimNative(address to)", "function claimStaked(address token,bytes32 destColdkey,address to)", "function claimToken(address token,address to)", "function claimableNative(address account) view returns (uint256)", "function claimableToken(address token,address account) view returns (uint256)", "event BridgedOut(uint64 destChainSelector,address indexed token,address indexed sender,address indexed recipient,uint256 minted,bytes32 messageId)", "event Claimable(address indexed token,address indexed user,uint256 native,uint256 wsn)", "event NotDelivered(uint64 indexed sourceChainSelector,address indexed token,uint256 amount,uint8 reason)", "event DeliveredLiquid(address indexed token,bytes32 indexed ss58,uint256 taoOut)", "event DeliveredStaked(address indexed token,bytes32 indexed ss58,uint256 alphaRao)"];
20
20
  alphaVault: readonly ["function isPaused() view returns (bool)", "function pausedUntil() view returns (uint256)", "function isListed(address token) view returns (bool)", "function backing(address token) view returns (uint256 stakedAlpha)", "function positionOf(address token) view returns (bytes32 validator,uint256 netuid)"];
21
21
  ccipExecution: readonly ["event ExecutionStateChanged(uint64 indexed sourceChainSelector,uint64 indexed sequenceNumber,bytes32 indexed messageId,bytes32 messageHash,uint8 state,bytes returnData,uint256 gasUsed)"];
22
22
  ccipRouter: readonly ["function isOffRamp(uint64 sourceChainSelector,address offRamp) view returns (bool)"];
23
23
  erc20: readonly ["function allowance(address owner,address spender) view returns (uint256)", "function approve(address spender,uint256 amount) returns (bool)", "function balanceOf(address account) view returns (uint256)"];
24
- spokeGateway: readonly ["function ROUTER() view returns (address)", "function BITTENSOR_SELECTOR() view returns (uint64)", "function SUBTENSOR_GATEWAY() view returns (address)", "function quoteBridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit) view returns (uint256 fee)", "function bridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit) payable returns (bytes32 messageId)", "event BridgedToFinney(address indexed token,address indexed sender,bytes32 indexed ss58,uint256 amount,bytes32 messageId)"];
24
+ spokeGateway: readonly ["function ROUTER() view returns (address)", "function BITTENSOR_SELECTOR() view returns (uint64)", "function SUBTENSOR_GATEWAY() view returns (address)", "function maxIntegratorFeeBps() view returns (uint16)", "function bridgeFeeBps() view returns (uint16)", "function quoteBridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit) view returns (uint256 fee)", "function bridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit) payable returns (bytes32 messageId)", "function quoteBridgeToFinneyWithFee(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit,uint256 gasLimit,(address recipient,uint16 bps) integrator) view returns (uint256 fee,uint256 cut,uint256 amountCrossing)", "function bridgeToFinneyWithFee(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit,uint256 gasLimit,(address recipient,uint16 bps) integrator) payable returns (bytes32 messageId)", "event BridgedToFinney(address indexed token,address indexed sender,bytes32 indexed ss58,uint256 amount,bytes32 messageId)"];
25
25
  staking: readonly ["function allowance(address sourceAddress,address spenderAddress,uint256 netuid) view returns (uint256)", "function approve(address spenderAddress,uint256 netuid,uint256 absoluteAmount)", "function getStake(bytes32 hotkey,bytes32 coldkey,uint256 netuid) view returns (uint256)"];
26
26
  vaultFactory: readonly ["function create(address owner,bytes32 associatedMiner,address akAddress,address poolManager,address poolAddress,address positionManagerImpl,(address token,uint256 amount)[] stashTokens) payable returns (address manager)", "event SnLiquidityManagerCreated(address indexed manager,address indexed owner,bytes32 associatedMiner,address akAddress,address poolAddress,address poolManager,address positionManager)"];
27
27
  vaultManager: readonly ["function claimFees(address akAddress)", "function topUpAk(address akAddress,address token,uint256 amount) payable", "function withdrawFromAkAndPositions(address akAddress,uint256 amount0,uint256 amount1,uint256[] decreaseTokenIds,bool unwrapETH)", "function stake(address akAddress,bytes data)", "function unstake(address akAddress,bytes data)", "function owner() view returns (address)", "event AKStashTopUp(address akAddress,address token,uint256 amount)", "event AKStashWithdraw(address akAddress,address token,uint256 amount)"];
@@ -35,9 +35,10 @@ declare const ROBINHOOD_CCIP_SELECTOR = 6180753054346818345n;
35
35
  declare const SUBTENSOR_CCIP_SELECTOR = 2135107236357186872n;
36
36
  declare const RAO_PER_TAO = 1000000000n;
37
37
  declare const EVM_WEI_PER_RAO = 1000000000n;
38
- declare const FOREVERMONEY_DEPLOYMENT_VERSION: "1.1.0";
38
+ declare const SN80_NETUID = 80n;
39
+ declare const FOREVERMONEY_DEPLOYMENT_VERSION: "1.3.0";
39
40
  declare const foreverMoneyDeployment: Readonly<{
40
- version: "1.1.0";
41
+ version: "1.3.0";
41
42
  base: Readonly<{
42
43
  key: "base";
43
44
  name: "Base";
@@ -45,7 +46,9 @@ declare const foreverMoneyDeployment: Readonly<{
45
46
  ccipSelector: 15971525489660198786n;
46
47
  contracts: Readonly<{
47
48
  gateway: `0x${string}`;
49
+ legacyGateways: readonly `0x${string}`[];
48
50
  wrappedTao: `0x${string}`;
51
+ wrappedSn80: `0x${string}`;
49
52
  ccipRouter: `0x${string}`;
50
53
  ccipOffRampFromSubtensor: `0x${string}`;
51
54
  vaultFactory: `0x${string}`;
@@ -62,6 +65,7 @@ declare const foreverMoneyDeployment: Readonly<{
62
65
  ccipSelector: 6180753054346818345n;
63
66
  contracts: Readonly<{
64
67
  gateway: `0x${string}`;
68
+ legacyGateways: readonly `0x${string}`[];
65
69
  wrappedTao: `0x${string}`;
66
70
  ccipRouter: `0x${string}`;
67
71
  ccipOffRampFromSubtensor: `0x${string}`;
@@ -72,8 +76,10 @@ declare const foreverMoneyDeployment: Readonly<{
72
76
  ccipSelector: 2135107236357186872n;
73
77
  contracts: Readonly<{
74
78
  gateway: `0x${string}`;
79
+ legacyGateways: readonly `0x${string}`[];
75
80
  alphaVault: `0x${string}`;
76
81
  wrappedTao: `0x${string}`;
82
+ wrappedSn80: `0x${string}`;
77
83
  ccipRouter: `0x${string}`;
78
84
  ccipOffRampFromBase: `0x${string}`;
79
85
  ccipOffRampFromRobinhood: `0x${string}`;
@@ -111,10 +117,37 @@ interface TransactionPlan {
111
117
 
112
118
  declare const MIN_LIQUID_EVM_TO_SUBTENSOR_WEI = 10000000000000000n;
113
119
  declare const MIN_LIQUID_BASE_TO_SUBTENSOR_WEI = 10000000000000000n;
120
+ declare const MIN_LIQUID_SUBTENSOR_TO_EVM_WEI: bigint;
114
121
  type SubtensorDelivery = 'liquid' | 'staked';
115
122
  type SubtensorSource = 'liquid' | 'staked';
123
+ type BridgeAsset = 'tao' | 'sn80';
124
+ /**
125
+ * Optional partner (integrator) fee, charged ON TOP of the bridged amount and
126
+ * paid to `recipient` on the source chain. The full `amountWei` still crosses.
127
+ * `bps` is in basis points (1 = 0.01%); the gateway caps it at
128
+ * `maxIntegratorFeeBps`, which `prepare*` reads and enforces.
129
+ */
130
+ interface PartnerFee {
131
+ readonly recipient: string;
132
+ readonly bps: number;
133
+ }
134
+ declare const MAX_PARTNER_FEE_BPS = 10000;
135
+ /**
136
+ * One staked position to pull from when bridging staked alpha from Subtensor:
137
+ * the validator hotkey the caller's stake sits on and how much of it to take.
138
+ * The gateway re-delegates every pull to the token's canonical validator
139
+ * before depositing, so stake with any validator can be bridged.
140
+ */
141
+ interface StakePull {
142
+ readonly hotkey: string;
143
+ readonly amountRao: bigint;
144
+ }
145
+ /** Gateway limit on positions per bridge (`AlphaGateway.MAX_STAKE_SOURCES`). */
146
+ declare const MAX_STAKE_PULLS = 16;
116
147
  interface EvmToSubtensorRequest {
117
148
  readonly evmChain: ForeverMoneyEvmChain;
149
+ readonly asset?: BridgeAsset;
150
+ readonly partnerFee?: PartnerFee;
118
151
  readonly sender: string;
119
152
  readonly amountWei: bigint;
120
153
  readonly destination: string;
@@ -122,19 +155,39 @@ interface EvmToSubtensorRequest {
122
155
  }
123
156
  interface SubtensorToEvmRequest {
124
157
  readonly evmChain: ForeverMoneyEvmChain;
158
+ readonly asset?: BridgeAsset;
159
+ readonly partnerFee?: PartnerFee;
125
160
  readonly sender: string;
126
161
  readonly recipient: string;
127
162
  readonly amountWei: bigint;
128
163
  readonly source: SubtensorSource;
129
164
  readonly netuid?: bigint;
165
+ /**
166
+ * For a staked source: the positions to pull, summing to `amountWei` in
167
+ * RAO. Omit when the stake already sits on the token's canonical validator.
168
+ * With a partner fee, the cut is charged on top and spread across the pulls
169
+ * in proportion to their amounts, so each position must hold its amount
170
+ * plus its share of the cut.
171
+ */
172
+ readonly stakePulls?: readonly StakePull[];
130
173
  }
131
174
  type BaseToSubtensorRequest = Omit<EvmToSubtensorRequest, 'evmChain'>;
132
175
  type SubtensorToBaseRequest = Omit<SubtensorToEvmRequest, 'evmChain'>;
133
176
  interface BridgePreparation {
134
177
  readonly exactNetworkFeeWei: bigint;
135
178
  readonly transactionValueWei: bigint;
179
+ /**
180
+ * Extra the sender pays for the partner fee, in the units of the source leg:
181
+ * token wei for an EVM source, alpha (as 18-decimal wei) for a staked source,
182
+ * TAO wei for a liquid source. Zero when no partner fee is set.
183
+ */
184
+ readonly partnerFeeWei: bigint;
136
185
  readonly plan: TransactionPlan;
137
186
  }
187
+ /** `bps` of `amount`, rounded down: the extra token (spoke) or alpha (hub) pulled on top. */
188
+ declare function partnerFeeCut(amount: bigint, bps: number): bigint;
189
+ /** Extra native TAO a liquid Subtensor source carries for the partner, rounded up to a whole RAO. */
190
+ declare function partnerFeeTaoTopUp(taoAmount: bigint, bps: number): bigint;
138
191
  interface BuildEvmToSubtensorPlanRequest extends EvmToSubtensorRequest {
139
192
  readonly allowanceWei: bigint;
140
193
  readonly exactNetworkFeeWei: bigint;
@@ -294,7 +347,7 @@ interface ForeverMoneyClient {
294
347
  }
295
348
  declare function createForeverMoneyClient(options: ForeverMoneyClientOptions): ForeverMoneyClient;
296
349
 
297
- type ForeverMoneyErrorCode = 'AMOUNT_BELOW_MINIMUM' | 'AMOUNT_NOT_WHOLE_RAO' | 'AMOUNT_ZERO' | 'CHAIN_MISMATCH' | 'INVALID_ADDRESS' | 'INVALID_BYTES32' | 'INVALID_PROVIDER_RESPONSE' | 'INVALID_SS58' | 'INVALID_TRANSACTION_PLAN' | 'MISSING_TRANSPORT' | 'RPC_ERROR' | 'SIMULATION_REVERTED';
350
+ type ForeverMoneyErrorCode = 'AMOUNT_BELOW_MINIMUM' | 'AMOUNT_NOT_WHOLE_RAO' | 'AMOUNT_ZERO' | 'CHAIN_MISMATCH' | 'INVALID_ADDRESS' | 'INVALID_BYTES32' | 'INVALID_PARTNER_FEE' | 'INVALID_PROVIDER_RESPONSE' | 'INVALID_SS58' | 'INVALID_TRANSACTION_PLAN' | 'MISSING_TRANSPORT' | 'RPC_ERROR' | 'SIMULATION_REVERTED';
298
351
  declare class ForeverMoneyError extends Error {
299
352
  readonly code: ForeverMoneyErrorCode;
300
353
  readonly details: Readonly<Record<string, unknown>> | undefined;
@@ -330,4 +383,4 @@ interface ViemTransactionRequest {
330
383
  }
331
384
  declare function toViemTransaction(transaction: PreparedTransaction): Readonly<ViemTransactionRequest>;
332
385
 
333
- export { BASE_CCIP_SELECTOR, BASE_CHAIN_ID, BASIS_POINTS, type BaseToSubtensorRequest, type BridgeDirection, type BridgePreparation, type BridgeSourceStatus, type BridgeSourceStatusRequest, type BridgeSourceTransactionStatus, type BuildBaseToSubtensorPlanRequest, type BuildEvmToSubtensorPlanRequest, type BuildSubtensorToBasePlanRequest, type BuildSubtensorToEvmPlanRequest, type CcipDeliveryCheckpoint, type CcipDeliveryStatus, type CcipDeliveryStatusRequest, type CreateVaultRequest, type DepositVaultRequest, EVM_WEI_PER_RAO, type Eip1193TransactionRequest, type EthersCompatibleTransactionRequest, type EvmToSubtensorRequest, FOREVERMONEY_DEPLOYMENT_VERSION, type ForeverMoneyClient, type ForeverMoneyClientOptions, type ForeverMoneyDeployment, ForeverMoneyError, type ForeverMoneyErrorCode, type ForeverMoneyEvmChain, GAS_LIMIT_BUFFER_BPS, type HttpTransportOptions, type LegacyRpcProvider, MIN_LIQUID_BASE_TO_SUBTENSOR_WEI, MIN_LIQUID_EVM_TO_SUBTENSOR_WEI, NETWORK_FEE_BUFFER_BPS, type PreparedTransaction, RAO_PER_TAO, ROBINHOOD_CCIP_SELECTOR, ROBINHOOD_CHAIN_ID, type ReceiptLog, type RpcRequest, type RpcTransport, SUBTENSOR_CCIP_SELECTOR, SUBTENSOR_CHAIN_ID, type SubtensorDelivery, type SubtensorSource, type SubtensorToBaseRequest, type SubtensorToEvmRequest, type TrackingProvider, type TransactionAction, type TransactionPlan, type TransactionReceiptLike, type TransactionStep, type TransactionStepKind, type VaultStashToken, type VaultTokenAllowance, type ViemTransactionRequest, type WithdrawVaultRequest, assertWholeRao, bridgeMessageIdFromReceipt, buildBaseToSubtensorPlan, buildClaimVaultFeesPlan, buildCreateVaultPlan, buildDepositVaultPlan, buildEvmToSubtensorPlan, buildSetVaultStakingPlan, buildSubtensorToBasePlan, buildSubtensorToEvmPlan, buildWithdrawVaultPlan, createForeverMoneyClient, destinationChainId, evmChainFromBridgeDirection, evmToMirrorSS58, feeWithBuffer, foreverMoneyAbis, foreverMoneyDeployment, formatTaoAmount, gasLimitWithBuffer, getBridgeSourceStatus, getCcipDeliveryCheckpoint, getCcipDeliveryStatus, getForeverMoneyEvmDeployment, http, isBittensorSS58, isEvmToSubtensorDirection, normalizeEvmAddress, normalizeSS58, parseTaoAmount, sourceChainId, ss58ToPublicKey, toEip1193Transaction, toEthersTransaction, toViemTransaction, vaultManagerFromCreationReceipt };
386
+ export { BASE_CCIP_SELECTOR, BASE_CHAIN_ID, BASIS_POINTS, type BaseToSubtensorRequest, type BridgeAsset, type BridgeDirection, type BridgePreparation, type BridgeSourceStatus, type BridgeSourceStatusRequest, type BridgeSourceTransactionStatus, type BuildBaseToSubtensorPlanRequest, type BuildEvmToSubtensorPlanRequest, type BuildSubtensorToBasePlanRequest, type BuildSubtensorToEvmPlanRequest, type CcipDeliveryCheckpoint, type CcipDeliveryStatus, type CcipDeliveryStatusRequest, type CreateVaultRequest, type DepositVaultRequest, EVM_WEI_PER_RAO, type Eip1193TransactionRequest, type EthersCompatibleTransactionRequest, type EvmToSubtensorRequest, FOREVERMONEY_DEPLOYMENT_VERSION, type ForeverMoneyClient, type ForeverMoneyClientOptions, type ForeverMoneyDeployment, ForeverMoneyError, type ForeverMoneyErrorCode, type ForeverMoneyEvmChain, GAS_LIMIT_BUFFER_BPS, type HttpTransportOptions, type LegacyRpcProvider, MAX_PARTNER_FEE_BPS, MAX_STAKE_PULLS, MIN_LIQUID_BASE_TO_SUBTENSOR_WEI, MIN_LIQUID_EVM_TO_SUBTENSOR_WEI, MIN_LIQUID_SUBTENSOR_TO_EVM_WEI, NETWORK_FEE_BUFFER_BPS, type PartnerFee, type PreparedTransaction, RAO_PER_TAO, ROBINHOOD_CCIP_SELECTOR, ROBINHOOD_CHAIN_ID, type ReceiptLog, type RpcRequest, type RpcTransport, SN80_NETUID, SUBTENSOR_CCIP_SELECTOR, SUBTENSOR_CHAIN_ID, type StakePull, type SubtensorDelivery, type SubtensorSource, type SubtensorToBaseRequest, type SubtensorToEvmRequest, type TrackingProvider, type TransactionAction, type TransactionPlan, type TransactionReceiptLike, type TransactionStep, type TransactionStepKind, type VaultStashToken, type VaultTokenAllowance, type ViemTransactionRequest, type WithdrawVaultRequest, assertWholeRao, bridgeMessageIdFromReceipt, buildBaseToSubtensorPlan, buildClaimVaultFeesPlan, buildCreateVaultPlan, buildDepositVaultPlan, buildEvmToSubtensorPlan, buildSetVaultStakingPlan, buildSubtensorToBasePlan, buildSubtensorToEvmPlan, buildWithdrawVaultPlan, createForeverMoneyClient, destinationChainId, evmChainFromBridgeDirection, evmToMirrorSS58, feeWithBuffer, foreverMoneyAbis, foreverMoneyDeployment, formatTaoAmount, gasLimitWithBuffer, getBridgeSourceStatus, getCcipDeliveryCheckpoint, getCcipDeliveryStatus, getForeverMoneyEvmDeployment, http, isBittensorSS58, isEvmToSubtensorDirection, normalizeEvmAddress, normalizeSS58, parseTaoAmount, partnerFeeCut, partnerFeeTaoTopUp, sourceChainId, ss58ToPublicKey, toEip1193Transaction, toEthersTransaction, toViemTransaction, vaultManagerFromCreationReceipt };