@forevermoney/sdk 0.4.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,7 +16,7 @@ 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 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)"];
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)"];
@@ -36,9 +36,9 @@ declare const SUBTENSOR_CCIP_SELECTOR = 2135107236357186872n;
36
36
  declare const RAO_PER_TAO = 1000000000n;
37
37
  declare const EVM_WEI_PER_RAO = 1000000000n;
38
38
  declare const SN80_NETUID = 80n;
39
- declare const FOREVERMONEY_DEPLOYMENT_VERSION: "1.2.0";
39
+ declare const FOREVERMONEY_DEPLOYMENT_VERSION: "1.3.0";
40
40
  declare const foreverMoneyDeployment: Readonly<{
41
- version: "1.2.0";
41
+ version: "1.3.0";
42
42
  base: Readonly<{
43
43
  key: "base";
44
44
  name: "Base";
@@ -46,7 +46,7 @@ declare const foreverMoneyDeployment: Readonly<{
46
46
  ccipSelector: 15971525489660198786n;
47
47
  contracts: Readonly<{
48
48
  gateway: `0x${string}`;
49
- legacyGateway: `0x${string}`;
49
+ legacyGateways: readonly `0x${string}`[];
50
50
  wrappedTao: `0x${string}`;
51
51
  wrappedSn80: `0x${string}`;
52
52
  ccipRouter: `0x${string}`;
@@ -65,7 +65,7 @@ declare const foreverMoneyDeployment: Readonly<{
65
65
  ccipSelector: 6180753054346818345n;
66
66
  contracts: Readonly<{
67
67
  gateway: `0x${string}`;
68
- legacyGateway: `0x${string}`;
68
+ legacyGateways: readonly `0x${string}`[];
69
69
  wrappedTao: `0x${string}`;
70
70
  ccipRouter: `0x${string}`;
71
71
  ccipOffRampFromSubtensor: `0x${string}`;
@@ -76,7 +76,7 @@ declare const foreverMoneyDeployment: Readonly<{
76
76
  ccipSelector: 2135107236357186872n;
77
77
  contracts: Readonly<{
78
78
  gateway: `0x${string}`;
79
- legacyGateway: `0x${string}`;
79
+ legacyGateways: readonly `0x${string}`[];
80
80
  alphaVault: `0x${string}`;
81
81
  wrappedTao: `0x${string}`;
82
82
  wrappedSn80: `0x${string}`;
@@ -132,6 +132,18 @@ interface PartnerFee {
132
132
  readonly bps: number;
133
133
  }
134
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;
135
147
  interface EvmToSubtensorRequest {
136
148
  readonly evmChain: ForeverMoneyEvmChain;
137
149
  readonly asset?: BridgeAsset;
@@ -150,6 +162,14 @@ interface SubtensorToEvmRequest {
150
162
  readonly amountWei: bigint;
151
163
  readonly source: SubtensorSource;
152
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[];
153
173
  }
154
174
  type BaseToSubtensorRequest = Omit<EvmToSubtensorRequest, 'evmChain'>;
155
175
  type SubtensorToBaseRequest = Omit<SubtensorToEvmRequest, 'evmChain'>;
@@ -363,4 +383,4 @@ interface ViemTransactionRequest {
363
383
  }
364
384
  declare function toViemTransaction(transaction: PreparedTransaction): Readonly<ViemTransactionRequest>;
365
385
 
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 };
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,7 +16,7 @@ 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 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)"];
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)"];
@@ -36,9 +36,9 @@ declare const SUBTENSOR_CCIP_SELECTOR = 2135107236357186872n;
36
36
  declare const RAO_PER_TAO = 1000000000n;
37
37
  declare const EVM_WEI_PER_RAO = 1000000000n;
38
38
  declare const SN80_NETUID = 80n;
39
- declare const FOREVERMONEY_DEPLOYMENT_VERSION: "1.2.0";
39
+ declare const FOREVERMONEY_DEPLOYMENT_VERSION: "1.3.0";
40
40
  declare const foreverMoneyDeployment: Readonly<{
41
- version: "1.2.0";
41
+ version: "1.3.0";
42
42
  base: Readonly<{
43
43
  key: "base";
44
44
  name: "Base";
@@ -46,7 +46,7 @@ declare const foreverMoneyDeployment: Readonly<{
46
46
  ccipSelector: 15971525489660198786n;
47
47
  contracts: Readonly<{
48
48
  gateway: `0x${string}`;
49
- legacyGateway: `0x${string}`;
49
+ legacyGateways: readonly `0x${string}`[];
50
50
  wrappedTao: `0x${string}`;
51
51
  wrappedSn80: `0x${string}`;
52
52
  ccipRouter: `0x${string}`;
@@ -65,7 +65,7 @@ declare const foreverMoneyDeployment: Readonly<{
65
65
  ccipSelector: 6180753054346818345n;
66
66
  contracts: Readonly<{
67
67
  gateway: `0x${string}`;
68
- legacyGateway: `0x${string}`;
68
+ legacyGateways: readonly `0x${string}`[];
69
69
  wrappedTao: `0x${string}`;
70
70
  ccipRouter: `0x${string}`;
71
71
  ccipOffRampFromSubtensor: `0x${string}`;
@@ -76,7 +76,7 @@ declare const foreverMoneyDeployment: Readonly<{
76
76
  ccipSelector: 2135107236357186872n;
77
77
  contracts: Readonly<{
78
78
  gateway: `0x${string}`;
79
- legacyGateway: `0x${string}`;
79
+ legacyGateways: readonly `0x${string}`[];
80
80
  alphaVault: `0x${string}`;
81
81
  wrappedTao: `0x${string}`;
82
82
  wrappedSn80: `0x${string}`;
@@ -132,6 +132,18 @@ interface PartnerFee {
132
132
  readonly bps: number;
133
133
  }
134
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;
135
147
  interface EvmToSubtensorRequest {
136
148
  readonly evmChain: ForeverMoneyEvmChain;
137
149
  readonly asset?: BridgeAsset;
@@ -150,6 +162,14 @@ interface SubtensorToEvmRequest {
150
162
  readonly amountWei: bigint;
151
163
  readonly source: SubtensorSource;
152
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[];
153
173
  }
154
174
  type BaseToSubtensorRequest = Omit<EvmToSubtensorRequest, 'evmChain'>;
155
175
  type SubtensorToBaseRequest = Omit<SubtensorToEvmRequest, 'evmChain'>;
@@ -363,4 +383,4 @@ interface ViemTransactionRequest {
363
383
  }
364
384
  declare function toViemTransaction(transaction: PreparedTransaction): Readonly<ViemTransactionRequest>;
365
385
 
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 };
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.js CHANGED
@@ -93,7 +93,7 @@ var SUBTENSOR_CCIP_SELECTOR = 2135107236357186872n;
93
93
  var RAO_PER_TAO = 1000000000n;
94
94
  var EVM_WEI_PER_RAO = 1000000000n;
95
95
  var SN80_NETUID = 80n;
96
- var FOREVERMONEY_DEPLOYMENT_VERSION = "1.2.0";
96
+ var FOREVERMONEY_DEPLOYMENT_VERSION = "1.3.0";
97
97
  var foreverMoneyDeployment = Object.freeze({
98
98
  version: FOREVERMONEY_DEPLOYMENT_VERSION,
99
99
  base: Object.freeze({
@@ -103,9 +103,11 @@ var foreverMoneyDeployment = Object.freeze({
103
103
  ccipSelector: BASE_CCIP_SELECTOR,
104
104
  contracts: Object.freeze({
105
105
  gateway: getAddress2("0x1da2415229b614C787e145D1D7346eb496319C52"),
106
- legacyGateway: getAddress2(
107
- "0x5EF3d7D19e4b233a1A169DA0d5CB02ec6b160a2C"
108
- ),
106
+ // Retired gateways, oldest first; kept only to track transfers sent
107
+ // through them.
108
+ legacyGateways: [
109
+ getAddress2("0x5EF3d7D19e4b233a1A169DA0d5CB02ec6b160a2C")
110
+ ],
109
111
  wrappedTao: getAddress2(
110
112
  "0xf3081494b87e8d5fb7960f066e931d1d0e6e3d67"
111
113
  ),
@@ -138,9 +140,9 @@ var foreverMoneyDeployment = Object.freeze({
138
140
  ccipSelector: ROBINHOOD_CCIP_SELECTOR,
139
141
  contracts: Object.freeze({
140
142
  gateway: getAddress2("0xf27fdA637131E25B2A1b4865ED9597d881980c7E"),
141
- legacyGateway: getAddress2(
142
- "0x53Dcc4FE04193e489BE537F722F65317DB1E65d8"
143
- ),
143
+ legacyGateways: [
144
+ getAddress2("0x53Dcc4FE04193e489BE537F722F65317DB1E65d8")
145
+ ],
144
146
  wrappedTao: getAddress2(
145
147
  "0xf3081494B87e8D5fb7960f066E931D1D0e6E3d67"
146
148
  ),
@@ -156,10 +158,14 @@ var foreverMoneyDeployment = Object.freeze({
156
158
  chainId: SUBTENSOR_CHAIN_ID,
157
159
  ccipSelector: SUBTENSOR_CCIP_SELECTOR,
158
160
  contracts: Object.freeze({
159
- gateway: getAddress2("0xcd0C6d98D0A126B1c113d15b4c28F38321437787"),
160
- legacyGateway: getAddress2(
161
- "0x998f20Fea90bF7792774dECc7f994716442B1705"
162
- ),
161
+ // V5.1 AlphaGateway: multi-validator staked input (tao-bridge 485c898).
162
+ gateway: getAddress2("0xd5Fa238aa4177f6c1341491969d9cBeec94EEd69"),
163
+ // V4 and V5 hubs. The spokes still deliver to the V5 hub (their hub
164
+ // pointer is immutable), so it stays here for delivery tracking.
165
+ legacyGateways: [
166
+ getAddress2("0x998f20Fea90bF7792774dECc7f994716442B1705"),
167
+ getAddress2("0xcd0C6d98D0A126B1c113d15b4c28F38321437787")
168
+ ],
163
169
  alphaVault: getAddress2(
164
170
  "0x11837459896D96F821a8D88eC93a3C8D152033D4"
165
171
  ),
@@ -368,6 +374,11 @@ var ALPHA_GATEWAY_ABI = Object.freeze([
368
374
  "function integratorCut(uint256 amount,uint16 bps) pure returns (uint256)",
369
375
  "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)",
370
376
  "function bridgeOutWithFee(uint64 destSelector,address token,address recipient,uint256 taoAmount,uint256 stakedAlphaRao,uint256 minTokenOut,(address recipient,uint16 bps) integrator) payable returns (bytes32 messageId)",
377
+ "function bridgeOutFromValidators(uint64 destSelector,address token,address recipient,uint256 taoAmount,(bytes32 validator,uint256 alphaRao)[] sources,uint256 minTokenOut) payable returns (bytes32 messageId)",
378
+ "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)",
379
+ "function minStakeRequired() view returns (uint256)",
380
+ "function MAX_STAKE_SOURCES() view returns (uint256)",
381
+ "function GATEWAY_COLDKEY() view returns (bytes32)",
371
382
  "function claimLiquid(address token,uint256 minTaoOut,address to)",
372
383
  "function claimNative(address to)",
373
384
  "function claimStaked(address token,bytes32 destColdkey,address to)",
@@ -536,6 +547,7 @@ var MIN_LIQUID_EVM_TO_SUBTENSOR_WEI = 10000000000000000n;
536
547
  var MIN_LIQUID_BASE_TO_SUBTENSOR_WEI = MIN_LIQUID_EVM_TO_SUBTENSOR_WEI;
537
548
  var MIN_LIQUID_SUBTENSOR_TO_EVM_WEI = 2000000n * EVM_WEI_PER_RAO;
538
549
  var MAX_PARTNER_FEE_BPS = 1e4;
550
+ var MAX_STAKE_PULLS = 16;
539
551
  var NO_PARTNER_FEE = {
540
552
  recipient: "0x0000000000000000000000000000000000000000",
541
553
  bps: 0
@@ -629,6 +641,16 @@ function sourceNetuid(input) {
629
641
  }
630
642
  return netuid;
631
643
  }
644
+ function stakePullsFor(input, amountRao) {
645
+ if (input.stakePulls === void 0) return void 0;
646
+ if (input.source !== "staked") {
647
+ throw new ForeverMoneyError(
648
+ "INVALID_TRANSACTION_PLAN",
649
+ "Stake pulls are only valid for a staked source."
650
+ );
651
+ }
652
+ return resolveStakePulls(input.stakePulls, amountRao);
653
+ }
632
654
  function assertDelivery(value) {
633
655
  if (value !== "liquid" && value !== "staked") {
634
656
  throw new ForeverMoneyError(
@@ -700,7 +722,72 @@ function encodeSpokeBridge(token, amountWei, exit, fee) {
700
722
  args: [token, amountWei, exit, 0n, fee]
701
723
  });
702
724
  }
703
- function encodeHubBridge(destSelector, token, recipient, taoAmount, stakedAlphaRao, minTokenOut, fee) {
725
+ function resolveStakePulls(pulls, amountRao) {
726
+ if (pulls.length === 0 || pulls.length > MAX_STAKE_PULLS) {
727
+ throw new ForeverMoneyError(
728
+ "INVALID_TRANSACTION_PLAN",
729
+ `Between 1 and ${MAX_STAKE_PULLS} stake pulls are required.`,
730
+ { count: pulls.length }
731
+ );
732
+ }
733
+ const seen = /* @__PURE__ */ new Set();
734
+ let total = 0n;
735
+ const resolved = pulls.map((pull) => {
736
+ const validator = normalizeBytes32(pull.hotkey, "Stake pull hotkey");
737
+ if (validator === `0x${"0".repeat(64)}`) {
738
+ throw new ForeverMoneyError(
739
+ "INVALID_TRANSACTION_PLAN",
740
+ "Stake pull hotkey must not be zero."
741
+ );
742
+ }
743
+ const key = validator.toLowerCase();
744
+ if (seen.has(key)) {
745
+ throw new ForeverMoneyError(
746
+ "INVALID_TRANSACTION_PLAN",
747
+ "Stake pulls must not repeat a hotkey.",
748
+ { hotkey: validator }
749
+ );
750
+ }
751
+ seen.add(key);
752
+ if (typeof pull.amountRao !== "bigint" || pull.amountRao <= 0n) {
753
+ throw new ForeverMoneyError(
754
+ "INVALID_TRANSACTION_PLAN",
755
+ "Each stake pull must take a positive amount of RAO.",
756
+ { hotkey: validator }
757
+ );
758
+ }
759
+ total += pull.amountRao;
760
+ return { validator, alphaRao: pull.amountRao };
761
+ });
762
+ if (total !== amountRao) {
763
+ throw new ForeverMoneyError(
764
+ "INVALID_TRANSACTION_PLAN",
765
+ "Stake pulls must sum to the bridged amount.",
766
+ { pulledRao: total.toString(), amountRao: amountRao.toString() }
767
+ );
768
+ }
769
+ return resolved;
770
+ }
771
+ function encodeHubBridge(destSelector, token, recipient, taoAmount, stakedAlphaRao, minTokenOut, fee, pulls) {
772
+ if (pulls !== void 0) {
773
+ const args2 = [
774
+ destSelector,
775
+ token,
776
+ recipient,
777
+ taoAmount,
778
+ pulls,
779
+ minTokenOut
780
+ ];
781
+ return fee.bps === 0 ? encodeFunctionData({
782
+ abi: alphaAbi,
783
+ functionName: "bridgeOutFromValidators",
784
+ args: args2
785
+ }) : encodeFunctionData({
786
+ abi: alphaAbi,
787
+ functionName: "bridgeOutFromValidatorsWithFee",
788
+ args: [...args2, fee]
789
+ });
790
+ }
704
791
  const args = [
705
792
  destSelector,
706
793
  token,
@@ -890,6 +977,7 @@ function buildSubtensorToEvmPlan(input) {
890
977
  }
891
978
  const taoAmount = input.source === "liquid" ? input.amountWei : 0n;
892
979
  const stakedAlphaRao = input.source === "staked" ? amountRao : 0n;
980
+ const pulls = stakePullsFor(input, amountRao);
893
981
  const value = taoAmount + taoTopUp + feeWithBuffer(input.exactNetworkFeeWei);
894
982
  assertNonNegativeAmount(value, "Transaction value");
895
983
  steps.push(
@@ -906,7 +994,8 @@ function buildSubtensorToEvmPlan(input) {
906
994
  taoAmount,
907
995
  stakedAlphaRao,
908
996
  input.amountWei,
909
- partnerFee
997
+ partnerFee,
998
+ pulls
910
999
  ),
911
1000
  value,
912
1001
  input.estimatedBridgeGas === void 0 ? void 0 : gasLimitWithBuffer(input.estimatedBridgeGas)
@@ -1058,7 +1147,8 @@ async function prepareSubtensorToEvm(provider, input) {
1058
1147
  taoAmount,
1059
1148
  stakedAlphaRao,
1060
1149
  input.amountWei,
1061
- partnerFee
1150
+ partnerFee,
1151
+ stakePullsFor(input, stakedAlphaRao)
1062
1152
  ),
1063
1153
  value
1064
1154
  });
@@ -1673,12 +1763,12 @@ function bridgeMessageIdFromReceipt(direction, receipt) {
1673
1763
  );
1674
1764
  const evmToSubtensor = isEvmToSubtensorDirection(direction);
1675
1765
  const [addresses, contractAbi, eventName] = evmToSubtensor ? [
1676
- [evm.contracts.legacyGateway, evm.contracts.gateway],
1766
+ [...evm.contracts.legacyGateways, evm.contracts.gateway],
1677
1767
  spokeGatewayAbi,
1678
1768
  "BridgedToFinney"
1679
1769
  ] : [
1680
1770
  [
1681
- foreverMoneyDeployment.subtensor.contracts.legacyGateway,
1771
+ ...foreverMoneyDeployment.subtensor.contracts.legacyGateways,
1682
1772
  foreverMoneyDeployment.subtensor.contracts.gateway
1683
1773
  ],
1684
1774
  alphaGatewayAbi,
@@ -1840,7 +1930,7 @@ async function getCcipDeliveryStatus(provider, input) {
1840
1930
  );
1841
1931
  }
1842
1932
  const subtensorGateways = [
1843
- foreverMoneyDeployment.subtensor.contracts.legacyGateway,
1933
+ ...foreverMoneyDeployment.subtensor.contracts.legacyGateways,
1844
1934
  foreverMoneyDeployment.subtensor.contracts.gateway
1845
1935
  ];
1846
1936
  for (const log of receipt.logs) {
@@ -2142,6 +2232,7 @@ export {
2142
2232
  ForeverMoneyError,
2143
2233
  GAS_LIMIT_BUFFER_BPS,
2144
2234
  MAX_PARTNER_FEE_BPS,
2235
+ MAX_STAKE_PULLS,
2145
2236
  MIN_LIQUID_BASE_TO_SUBTENSOR_WEI,
2146
2237
  MIN_LIQUID_EVM_TO_SUBTENSOR_WEI,
2147
2238
  MIN_LIQUID_SUBTENSOR_TO_EVM_WEI,