@forevermoney/sdk 0.2.0 → 0.4.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 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.2.0";
39
40
  declare const foreverMoneyDeployment: Readonly<{
40
- version: "1.1.0";
41
+ version: "1.2.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
+ legacyGateway: `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
+ legacyGateway: `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
+ legacyGateway: `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,25 @@ 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;
116
135
  interface EvmToSubtensorRequest {
117
136
  readonly evmChain: ForeverMoneyEvmChain;
137
+ readonly asset?: BridgeAsset;
138
+ readonly partnerFee?: PartnerFee;
118
139
  readonly sender: string;
119
140
  readonly amountWei: bigint;
120
141
  readonly destination: string;
@@ -122,6 +143,8 @@ interface EvmToSubtensorRequest {
122
143
  }
123
144
  interface SubtensorToEvmRequest {
124
145
  readonly evmChain: ForeverMoneyEvmChain;
146
+ readonly asset?: BridgeAsset;
147
+ readonly partnerFee?: PartnerFee;
125
148
  readonly sender: string;
126
149
  readonly recipient: string;
127
150
  readonly amountWei: bigint;
@@ -133,8 +156,18 @@ type SubtensorToBaseRequest = Omit<SubtensorToEvmRequest, 'evmChain'>;
133
156
  interface BridgePreparation {
134
157
  readonly exactNetworkFeeWei: bigint;
135
158
  readonly transactionValueWei: bigint;
159
+ /**
160
+ * Extra the sender pays for the partner fee, in the units of the source leg:
161
+ * token wei for an EVM source, alpha (as 18-decimal wei) for a staked source,
162
+ * TAO wei for a liquid source. Zero when no partner fee is set.
163
+ */
164
+ readonly partnerFeeWei: bigint;
136
165
  readonly plan: TransactionPlan;
137
166
  }
167
+ /** `bps` of `amount`, rounded down: the extra token (spoke) or alpha (hub) pulled on top. */
168
+ declare function partnerFeeCut(amount: bigint, bps: number): bigint;
169
+ /** Extra native TAO a liquid Subtensor source carries for the partner, rounded up to a whole RAO. */
170
+ declare function partnerFeeTaoTopUp(taoAmount: bigint, bps: number): bigint;
138
171
  interface BuildEvmToSubtensorPlanRequest extends EvmToSubtensorRequest {
139
172
  readonly allowanceWei: bigint;
140
173
  readonly exactNetworkFeeWei: bigint;
@@ -294,7 +327,7 @@ interface ForeverMoneyClient {
294
327
  }
295
328
  declare function createForeverMoneyClient(options: ForeverMoneyClientOptions): ForeverMoneyClient;
296
329
 
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';
330
+ 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
331
  declare class ForeverMoneyError extends Error {
299
332
  readonly code: ForeverMoneyErrorCode;
300
333
  readonly details: Readonly<Record<string, unknown>> | undefined;
@@ -330,4 +363,4 @@ interface ViemTransactionRequest {
330
363
  }
331
364
  declare function toViemTransaction(transaction: PreparedTransaction): Readonly<ViemTransactionRequest>;
332
365
 
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 };
366
+ 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, 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 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 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.2.0";
39
40
  declare const foreverMoneyDeployment: Readonly<{
40
- version: "1.1.0";
41
+ version: "1.2.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
+ legacyGateway: `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
+ legacyGateway: `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
+ legacyGateway: `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,25 @@ 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;
116
135
  interface EvmToSubtensorRequest {
117
136
  readonly evmChain: ForeverMoneyEvmChain;
137
+ readonly asset?: BridgeAsset;
138
+ readonly partnerFee?: PartnerFee;
118
139
  readonly sender: string;
119
140
  readonly amountWei: bigint;
120
141
  readonly destination: string;
@@ -122,6 +143,8 @@ interface EvmToSubtensorRequest {
122
143
  }
123
144
  interface SubtensorToEvmRequest {
124
145
  readonly evmChain: ForeverMoneyEvmChain;
146
+ readonly asset?: BridgeAsset;
147
+ readonly partnerFee?: PartnerFee;
125
148
  readonly sender: string;
126
149
  readonly recipient: string;
127
150
  readonly amountWei: bigint;
@@ -133,8 +156,18 @@ type SubtensorToBaseRequest = Omit<SubtensorToEvmRequest, 'evmChain'>;
133
156
  interface BridgePreparation {
134
157
  readonly exactNetworkFeeWei: bigint;
135
158
  readonly transactionValueWei: bigint;
159
+ /**
160
+ * Extra the sender pays for the partner fee, in the units of the source leg:
161
+ * token wei for an EVM source, alpha (as 18-decimal wei) for a staked source,
162
+ * TAO wei for a liquid source. Zero when no partner fee is set.
163
+ */
164
+ readonly partnerFeeWei: bigint;
136
165
  readonly plan: TransactionPlan;
137
166
  }
167
+ /** `bps` of `amount`, rounded down: the extra token (spoke) or alpha (hub) pulled on top. */
168
+ declare function partnerFeeCut(amount: bigint, bps: number): bigint;
169
+ /** Extra native TAO a liquid Subtensor source carries for the partner, rounded up to a whole RAO. */
170
+ declare function partnerFeeTaoTopUp(taoAmount: bigint, bps: number): bigint;
138
171
  interface BuildEvmToSubtensorPlanRequest extends EvmToSubtensorRequest {
139
172
  readonly allowanceWei: bigint;
140
173
  readonly exactNetworkFeeWei: bigint;
@@ -294,7 +327,7 @@ interface ForeverMoneyClient {
294
327
  }
295
328
  declare function createForeverMoneyClient(options: ForeverMoneyClientOptions): ForeverMoneyClient;
296
329
 
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';
330
+ 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
331
  declare class ForeverMoneyError extends Error {
299
332
  readonly code: ForeverMoneyErrorCode;
300
333
  readonly details: Readonly<Record<string, unknown>> | undefined;
@@ -330,4 +363,4 @@ interface ViemTransactionRequest {
330
363
  }
331
364
  declare function toViemTransaction(transaction: PreparedTransaction): Readonly<ViemTransactionRequest>;
332
365
 
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 };
366
+ 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, 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 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 };