@forevermoney/sdk 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +18 -11
- package/dist/index.cjs +40 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +40 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -9,9 +9,9 @@ declare const SUBTENSOR_CCIP_SELECTOR = 2135107236357186872n;
|
|
|
9
9
|
declare const RAO_PER_TAO = 1000000000n;
|
|
10
10
|
declare const EVM_WEI_PER_RAO = 1000000000n;
|
|
11
11
|
declare const SN80_NETUID = 80n;
|
|
12
|
-
declare const FOREVERMONEY_DEPLOYMENT_VERSION: "1.
|
|
12
|
+
declare const FOREVERMONEY_DEPLOYMENT_VERSION: "1.4.0";
|
|
13
13
|
declare const foreverMoneyDeployment: Readonly<{
|
|
14
|
-
version: "1.
|
|
14
|
+
version: "1.4.0";
|
|
15
15
|
base: Readonly<{
|
|
16
16
|
key: "base";
|
|
17
17
|
name: "Base";
|
|
@@ -40,6 +40,7 @@ declare const foreverMoneyDeployment: Readonly<{
|
|
|
40
40
|
gateway: `0x${string}`;
|
|
41
41
|
legacyGateways: readonly `0x${string}`[];
|
|
42
42
|
wrappedTao: `0x${string}`;
|
|
43
|
+
wrappedSn80: `0x${string}`;
|
|
43
44
|
ccipRouter: `0x${string}`;
|
|
44
45
|
ccipOffRampFromSubtensor: `0x${string}`;
|
|
45
46
|
}>;
|
|
@@ -91,6 +92,7 @@ interface TransactionPlan {
|
|
|
91
92
|
declare const MIN_LIQUID_EVM_TO_SUBTENSOR_WEI = 10000000000000000n;
|
|
92
93
|
declare const MIN_LIQUID_BASE_TO_SUBTENSOR_WEI = 10000000000000000n;
|
|
93
94
|
declare const MIN_LIQUID_SUBTENSOR_TO_EVM_WEI: bigint;
|
|
95
|
+
declare const EVM_TO_SUBTENSOR_DESTINATION_GAS_LIMIT = 3500000n;
|
|
94
96
|
type SubtensorDelivery = 'liquid' | 'staked';
|
|
95
97
|
type SubtensorSource = 'liquid' | 'staked';
|
|
96
98
|
type BridgeAsset = 'tao' | 'sn80';
|
|
@@ -121,6 +123,12 @@ interface EvmToSubtensorRequest {
|
|
|
121
123
|
readonly evmChain: ForeverMoneyEvmChain;
|
|
122
124
|
readonly asset?: BridgeAsset;
|
|
123
125
|
readonly partnerFee?: PartnerFee;
|
|
126
|
+
/**
|
|
127
|
+
* CCIP gas made available to the Subtensor receiver. Defaults to
|
|
128
|
+
* `EVM_TO_SUBTENSOR_DESTINATION_GAS_LIMIT`; set per transaction when the
|
|
129
|
+
* destination execution path needs a different budget.
|
|
130
|
+
*/
|
|
131
|
+
readonly destinationGasLimit?: bigint;
|
|
124
132
|
readonly sender: string;
|
|
125
133
|
readonly amountWei: bigint;
|
|
126
134
|
readonly destination: string;
|
|
@@ -252,12 +260,12 @@ declare function feeWithBuffer(fee: bigint): bigint;
|
|
|
252
260
|
declare function gasLimitWithBuffer(gasLimit: bigint): bigint;
|
|
253
261
|
|
|
254
262
|
declare const foreverMoneyAbis: Readonly<{
|
|
255
|
-
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
|
|
263
|
+
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 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)"];
|
|
256
264
|
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)"];
|
|
257
265
|
ccipExecution: readonly ["event ExecutionStateChanged(uint64 indexed sourceChainSelector,uint64 indexed sequenceNumber,bytes32 indexed messageId,bytes32 messageHash,uint8 state,bytes returnData,uint256 gasUsed)"];
|
|
258
266
|
ccipRouter: readonly ["function isOffRamp(uint64 sourceChainSelector,address offRamp) view returns (bool)"];
|
|
259
267
|
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)"];
|
|
260
|
-
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)"];
|
|
268
|
+
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 quoteBridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit,uint256 gasLimit) view returns (uint256 fee)", "function bridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit) payable returns (bytes32 messageId)", "function bridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit,uint256 gasLimit) 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)"];
|
|
261
269
|
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)"];
|
|
262
270
|
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)"];
|
|
263
271
|
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)"];
|
|
@@ -441,4 +449,4 @@ interface ViemTransactionRequest {
|
|
|
441
449
|
}
|
|
442
450
|
declare function toViemTransaction(transaction: PreparedTransaction): Readonly<ViemTransactionRequest>;
|
|
443
451
|
|
|
444
|
-
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 EstimateRoundedStakeRequest, 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 RoundedStakeEstimate, type RpcRequest, type RpcTransport, SN80_NETUID, SUBTENSOR_CCIP_SELECTOR, SUBTENSOR_CHAIN_ID, type StakePosition, type StakePull, type StakeRoundingOptions, type StakeRoundingResult, 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, estimateRoundedStake, evmChainFromBridgeDirection, evmToMirrorSS58, feeWithBuffer, foreverMoneyAbis, foreverMoneyDeployment, formatTaoAmount, gasLimitWithBuffer, getBridgeSourceStatus, getCcipDeliveryCheckpoint, getCcipDeliveryStatus, getForeverMoneyEvmDeployment, http, isBittensorSS58, isEvmToSubtensorDirection, normalizeEvmAddress, normalizeSS58, parseTaoAmount, partnerFeeCut, partnerFeeTaoTopUp, sourceChainId, ss58ToPublicKey, stakedMinimumOutput, strandedStakeSource, toEip1193Transaction, toEthersTransaction, toViemTransaction, vaultManagerFromCreationReceipt };
|
|
452
|
+
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_TO_SUBTENSOR_DESTINATION_GAS_LIMIT, EVM_WEI_PER_RAO, type Eip1193TransactionRequest, type EstimateRoundedStakeRequest, 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 RoundedStakeEstimate, type RpcRequest, type RpcTransport, SN80_NETUID, SUBTENSOR_CCIP_SELECTOR, SUBTENSOR_CHAIN_ID, type StakePosition, type StakePull, type StakeRoundingOptions, type StakeRoundingResult, 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, estimateRoundedStake, evmChainFromBridgeDirection, evmToMirrorSS58, feeWithBuffer, foreverMoneyAbis, foreverMoneyDeployment, formatTaoAmount, gasLimitWithBuffer, getBridgeSourceStatus, getCcipDeliveryCheckpoint, getCcipDeliveryStatus, getForeverMoneyEvmDeployment, http, isBittensorSS58, isEvmToSubtensorDirection, normalizeEvmAddress, normalizeSS58, parseTaoAmount, partnerFeeCut, partnerFeeTaoTopUp, sourceChainId, ss58ToPublicKey, stakedMinimumOutput, strandedStakeSource, toEip1193Transaction, toEthersTransaction, toViemTransaction, vaultManagerFromCreationReceipt };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,9 +9,9 @@ declare const SUBTENSOR_CCIP_SELECTOR = 2135107236357186872n;
|
|
|
9
9
|
declare const RAO_PER_TAO = 1000000000n;
|
|
10
10
|
declare const EVM_WEI_PER_RAO = 1000000000n;
|
|
11
11
|
declare const SN80_NETUID = 80n;
|
|
12
|
-
declare const FOREVERMONEY_DEPLOYMENT_VERSION: "1.
|
|
12
|
+
declare const FOREVERMONEY_DEPLOYMENT_VERSION: "1.4.0";
|
|
13
13
|
declare const foreverMoneyDeployment: Readonly<{
|
|
14
|
-
version: "1.
|
|
14
|
+
version: "1.4.0";
|
|
15
15
|
base: Readonly<{
|
|
16
16
|
key: "base";
|
|
17
17
|
name: "Base";
|
|
@@ -40,6 +40,7 @@ declare const foreverMoneyDeployment: Readonly<{
|
|
|
40
40
|
gateway: `0x${string}`;
|
|
41
41
|
legacyGateways: readonly `0x${string}`[];
|
|
42
42
|
wrappedTao: `0x${string}`;
|
|
43
|
+
wrappedSn80: `0x${string}`;
|
|
43
44
|
ccipRouter: `0x${string}`;
|
|
44
45
|
ccipOffRampFromSubtensor: `0x${string}`;
|
|
45
46
|
}>;
|
|
@@ -91,6 +92,7 @@ interface TransactionPlan {
|
|
|
91
92
|
declare const MIN_LIQUID_EVM_TO_SUBTENSOR_WEI = 10000000000000000n;
|
|
92
93
|
declare const MIN_LIQUID_BASE_TO_SUBTENSOR_WEI = 10000000000000000n;
|
|
93
94
|
declare const MIN_LIQUID_SUBTENSOR_TO_EVM_WEI: bigint;
|
|
95
|
+
declare const EVM_TO_SUBTENSOR_DESTINATION_GAS_LIMIT = 3500000n;
|
|
94
96
|
type SubtensorDelivery = 'liquid' | 'staked';
|
|
95
97
|
type SubtensorSource = 'liquid' | 'staked';
|
|
96
98
|
type BridgeAsset = 'tao' | 'sn80';
|
|
@@ -121,6 +123,12 @@ interface EvmToSubtensorRequest {
|
|
|
121
123
|
readonly evmChain: ForeverMoneyEvmChain;
|
|
122
124
|
readonly asset?: BridgeAsset;
|
|
123
125
|
readonly partnerFee?: PartnerFee;
|
|
126
|
+
/**
|
|
127
|
+
* CCIP gas made available to the Subtensor receiver. Defaults to
|
|
128
|
+
* `EVM_TO_SUBTENSOR_DESTINATION_GAS_LIMIT`; set per transaction when the
|
|
129
|
+
* destination execution path needs a different budget.
|
|
130
|
+
*/
|
|
131
|
+
readonly destinationGasLimit?: bigint;
|
|
124
132
|
readonly sender: string;
|
|
125
133
|
readonly amountWei: bigint;
|
|
126
134
|
readonly destination: string;
|
|
@@ -252,12 +260,12 @@ declare function feeWithBuffer(fee: bigint): bigint;
|
|
|
252
260
|
declare function gasLimitWithBuffer(gasLimit: bigint): bigint;
|
|
253
261
|
|
|
254
262
|
declare const foreverMoneyAbis: Readonly<{
|
|
255
|
-
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
|
|
263
|
+
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 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)"];
|
|
256
264
|
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)"];
|
|
257
265
|
ccipExecution: readonly ["event ExecutionStateChanged(uint64 indexed sourceChainSelector,uint64 indexed sequenceNumber,bytes32 indexed messageId,bytes32 messageHash,uint8 state,bytes returnData,uint256 gasUsed)"];
|
|
258
266
|
ccipRouter: readonly ["function isOffRamp(uint64 sourceChainSelector,address offRamp) view returns (bool)"];
|
|
259
267
|
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)"];
|
|
260
|
-
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)"];
|
|
268
|
+
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 quoteBridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit,uint256 gasLimit) view returns (uint256 fee)", "function bridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit) payable returns (bytes32 messageId)", "function bridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit,uint256 gasLimit) 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)"];
|
|
261
269
|
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)"];
|
|
262
270
|
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)"];
|
|
263
271
|
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)"];
|
|
@@ -441,4 +449,4 @@ interface ViemTransactionRequest {
|
|
|
441
449
|
}
|
|
442
450
|
declare function toViemTransaction(transaction: PreparedTransaction): Readonly<ViemTransactionRequest>;
|
|
443
451
|
|
|
444
|
-
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 EstimateRoundedStakeRequest, 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 RoundedStakeEstimate, type RpcRequest, type RpcTransport, SN80_NETUID, SUBTENSOR_CCIP_SELECTOR, SUBTENSOR_CHAIN_ID, type StakePosition, type StakePull, type StakeRoundingOptions, type StakeRoundingResult, 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, estimateRoundedStake, evmChainFromBridgeDirection, evmToMirrorSS58, feeWithBuffer, foreverMoneyAbis, foreverMoneyDeployment, formatTaoAmount, gasLimitWithBuffer, getBridgeSourceStatus, getCcipDeliveryCheckpoint, getCcipDeliveryStatus, getForeverMoneyEvmDeployment, http, isBittensorSS58, isEvmToSubtensorDirection, normalizeEvmAddress, normalizeSS58, parseTaoAmount, partnerFeeCut, partnerFeeTaoTopUp, sourceChainId, ss58ToPublicKey, stakedMinimumOutput, strandedStakeSource, toEip1193Transaction, toEthersTransaction, toViemTransaction, vaultManagerFromCreationReceipt };
|
|
452
|
+
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_TO_SUBTENSOR_DESTINATION_GAS_LIMIT, EVM_WEI_PER_RAO, type Eip1193TransactionRequest, type EstimateRoundedStakeRequest, 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 RoundedStakeEstimate, type RpcRequest, type RpcTransport, SN80_NETUID, SUBTENSOR_CCIP_SELECTOR, SUBTENSOR_CHAIN_ID, type StakePosition, type StakePull, type StakeRoundingOptions, type StakeRoundingResult, 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, estimateRoundedStake, evmChainFromBridgeDirection, evmToMirrorSS58, feeWithBuffer, foreverMoneyAbis, foreverMoneyDeployment, formatTaoAmount, gasLimitWithBuffer, getBridgeSourceStatus, getCcipDeliveryCheckpoint, getCcipDeliveryStatus, getForeverMoneyEvmDeployment, http, isBittensorSS58, isEvmToSubtensorDirection, normalizeEvmAddress, normalizeSS58, parseTaoAmount, partnerFeeCut, partnerFeeTaoTopUp, sourceChainId, ss58ToPublicKey, stakedMinimumOutput, strandedStakeSource, toEip1193Transaction, toEthersTransaction, toViemTransaction, vaultManagerFromCreationReceipt };
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var SUBTENSOR_CCIP_SELECTOR = 2135107236357186872n;
|
|
|
9
9
|
var RAO_PER_TAO = 1000000000n;
|
|
10
10
|
var EVM_WEI_PER_RAO = 1000000000n;
|
|
11
11
|
var SN80_NETUID = 80n;
|
|
12
|
-
var FOREVERMONEY_DEPLOYMENT_VERSION = "1.
|
|
12
|
+
var FOREVERMONEY_DEPLOYMENT_VERSION = "1.4.0";
|
|
13
13
|
var foreverMoneyDeployment = Object.freeze({
|
|
14
14
|
version: FOREVERMONEY_DEPLOYMENT_VERSION,
|
|
15
15
|
base: Object.freeze({
|
|
@@ -62,6 +62,9 @@ var foreverMoneyDeployment = Object.freeze({
|
|
|
62
62
|
wrappedTao: getAddress(
|
|
63
63
|
"0xf3081494B87e8D5fb7960f066E931D1D0e6E3d67"
|
|
64
64
|
),
|
|
65
|
+
wrappedSn80: getAddress(
|
|
66
|
+
"0x6f63d869011f95274498023b4abfc00b30c34378"
|
|
67
|
+
),
|
|
65
68
|
ccipRouter: getAddress(
|
|
66
69
|
"0x06fC836cf9839B1cd891C440A0a45242DA6Ae1c9"
|
|
67
70
|
),
|
|
@@ -572,7 +575,9 @@ var SPOKE_GATEWAY_ABI = Object.freeze([
|
|
|
572
575
|
"function maxIntegratorFeeBps() view returns (uint16)",
|
|
573
576
|
"function bridgeFeeBps() view returns (uint16)",
|
|
574
577
|
"function quoteBridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit) view returns (uint256 fee)",
|
|
578
|
+
"function quoteBridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit,uint256 gasLimit) view returns (uint256 fee)",
|
|
575
579
|
"function bridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit) payable returns (bytes32 messageId)",
|
|
580
|
+
"function bridgeToFinney(address token,uint256 amount,(bytes32 ss58,address evmFallback,bool wantLiquid,uint256 minTaoOut) exit,uint256 gasLimit) payable returns (bytes32 messageId)",
|
|
576
581
|
"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)",
|
|
577
582
|
"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)",
|
|
578
583
|
"event BridgedToFinney(address indexed token,address indexed sender,bytes32 indexed ss58,uint256 amount,bytes32 messageId)"
|
|
@@ -590,7 +595,6 @@ var ALPHA_GATEWAY_ABI = Object.freeze([
|
|
|
590
595
|
"function bridgeOutWithFee(uint64 destSelector,address token,address recipient,uint256 taoAmount,uint256 stakedAlphaRao,uint256 minTokenOut,(address recipient,uint16 bps) integrator) payable returns (bytes32 messageId)",
|
|
591
596
|
"function bridgeOutFromValidators(uint64 destSelector,address token,address recipient,uint256 taoAmount,(bytes32 validator,uint256 alphaRao)[] sources,uint256 minTokenOut) payable returns (bytes32 messageId)",
|
|
592
597
|
"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)",
|
|
593
|
-
"function minStakeRequired() view returns (uint256)",
|
|
594
598
|
"function MAX_STAKE_SOURCES() view returns (uint256)",
|
|
595
599
|
"function GATEWAY_COLDKEY() view returns (bytes32)",
|
|
596
600
|
"function claimLiquid(address token,uint256 minTaoOut,address to)",
|
|
@@ -677,6 +681,18 @@ var stakingAbi = parseAbi(STAKING_ABI);
|
|
|
677
681
|
var MIN_LIQUID_EVM_TO_SUBTENSOR_WEI = 10000000000000000n;
|
|
678
682
|
var MIN_LIQUID_BASE_TO_SUBTENSOR_WEI = MIN_LIQUID_EVM_TO_SUBTENSOR_WEI;
|
|
679
683
|
var MIN_LIQUID_SUBTENSOR_TO_EVM_WEI = 2000000n * EVM_WEI_PER_RAO;
|
|
684
|
+
var EVM_TO_SUBTENSOR_DESTINATION_GAS_LIMIT = 3500000n;
|
|
685
|
+
function resolveDestinationGasLimit(value) {
|
|
686
|
+
const gasLimit = value ?? EVM_TO_SUBTENSOR_DESTINATION_GAS_LIMIT;
|
|
687
|
+
if (typeof gasLimit !== "bigint" || gasLimit <= 0n) {
|
|
688
|
+
throw new ForeverMoneyError(
|
|
689
|
+
"INVALID_TRANSACTION_PLAN",
|
|
690
|
+
"Destination gas limit must be a positive bigint.",
|
|
691
|
+
{ destinationGasLimit: String(gasLimit) }
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
return gasLimit;
|
|
695
|
+
}
|
|
680
696
|
var MAX_PARTNER_FEE_BPS = 1e4;
|
|
681
697
|
var MAX_STAKE_PULLS = 16;
|
|
682
698
|
var NO_PARTNER_FEE = {
|
|
@@ -727,15 +743,9 @@ function bridgeAsset(evmChain, asset = "tao") {
|
|
|
727
743
|
'Asset must be "tao" or "sn80".'
|
|
728
744
|
);
|
|
729
745
|
}
|
|
730
|
-
if (asset === "sn80" && evmChain !== "base") {
|
|
731
|
-
throw new ForeverMoneyError(
|
|
732
|
-
"INVALID_TRANSACTION_PLAN",
|
|
733
|
-
"SN80 bridging is supported between Base and Subtensor."
|
|
734
|
-
);
|
|
735
|
-
}
|
|
736
746
|
const evm = getForeverMoneyEvmDeployment(evmChain);
|
|
737
747
|
return asset === "sn80" ? {
|
|
738
|
-
evmToken:
|
|
748
|
+
evmToken: evm.contracts.wrappedSn80,
|
|
739
749
|
subtensorToken: foreverMoneyDeployment.subtensor.contracts.wrappedSn80,
|
|
740
750
|
label: "SN80",
|
|
741
751
|
wrappedLabel: "SN80"
|
|
@@ -853,15 +863,15 @@ function partnerFeeSummary(charged, unit, fee) {
|
|
|
853
863
|
if (fee.bps === 0) return "";
|
|
854
864
|
return ` Partner fee: ${charged} wei of ${unit} (${fee.bps} bps) on top, paid to ${fee.recipient}.`;
|
|
855
865
|
}
|
|
856
|
-
function encodeSpokeBridge(token, amountWei, exit, fee) {
|
|
866
|
+
function encodeSpokeBridge(token, amountWei, exit, destinationGasLimit, fee) {
|
|
857
867
|
return fee.bps === 0 ? encodeFunctionData({
|
|
858
868
|
abi: spokeAbi,
|
|
859
869
|
functionName: "bridgeToFinney",
|
|
860
|
-
args: [token, amountWei, exit]
|
|
870
|
+
args: [token, amountWei, exit, destinationGasLimit]
|
|
861
871
|
}) : encodeFunctionData({
|
|
862
872
|
abi: spokeAbi,
|
|
863
873
|
functionName: "bridgeToFinneyWithFee",
|
|
864
|
-
args: [token, amountWei, exit,
|
|
874
|
+
args: [token, amountWei, exit, destinationGasLimit, fee]
|
|
865
875
|
});
|
|
866
876
|
}
|
|
867
877
|
function resolveStakePulls(pulls, amountRao) {
|
|
@@ -948,7 +958,7 @@ function encodeHubBridge(destSelector, token, recipient, taoAmount, stakedAlphaR
|
|
|
948
958
|
args: [...args, fee]
|
|
949
959
|
});
|
|
950
960
|
}
|
|
951
|
-
async function quoteSpokeWithFee(provider, gateway, token, amountWei, exit, fee) {
|
|
961
|
+
async function quoteSpokeWithFee(provider, gateway, token, amountWei, exit, destinationGasLimit, fee) {
|
|
952
962
|
const maxBps = await provider.readContract({
|
|
953
963
|
address: gateway,
|
|
954
964
|
abi: spokeAbi,
|
|
@@ -959,7 +969,7 @@ async function quoteSpokeWithFee(provider, gateway, token, amountWei, exit, fee)
|
|
|
959
969
|
address: gateway,
|
|
960
970
|
abi: spokeAbi,
|
|
961
971
|
functionName: "quoteBridgeToFinneyWithFee",
|
|
962
|
-
args: [token, amountWei, exit,
|
|
972
|
+
args: [token, amountWei, exit, destinationGasLimit, fee]
|
|
963
973
|
});
|
|
964
974
|
return networkFee;
|
|
965
975
|
}
|
|
@@ -1005,6 +1015,9 @@ function buildEvmToSubtensorPlan(input) {
|
|
|
1005
1015
|
assertBaseToSubtensorAmount(input.amountWei, input.delivery);
|
|
1006
1016
|
assertNonNegativeAmount(input.allowanceWei, "Token allowance");
|
|
1007
1017
|
assertNonNegativeAmount(input.exactNetworkFeeWei, "Network fee");
|
|
1018
|
+
const destinationGasLimit = resolveDestinationGasLimit(
|
|
1019
|
+
input.destinationGasLimit
|
|
1020
|
+
);
|
|
1008
1021
|
const destination = normalizeSS58(input.destination);
|
|
1009
1022
|
const exit = {
|
|
1010
1023
|
ss58: ss58ToPublicKey(destination),
|
|
@@ -1048,6 +1061,7 @@ function buildEvmToSubtensorPlan(input) {
|
|
|
1048
1061
|
asset.evmToken,
|
|
1049
1062
|
input.amountWei,
|
|
1050
1063
|
exit,
|
|
1064
|
+
destinationGasLimit,
|
|
1051
1065
|
partnerFee
|
|
1052
1066
|
),
|
|
1053
1067
|
value,
|
|
@@ -1163,6 +1177,9 @@ async function prepareEvmToSubtensor(provider, input) {
|
|
|
1163
1177
|
assertDelivery(input.delivery);
|
|
1164
1178
|
assertAssetMode(input.asset, input.delivery);
|
|
1165
1179
|
assertBaseToSubtensorAmount(input.amountWei, input.delivery);
|
|
1180
|
+
const destinationGasLimit = resolveDestinationGasLimit(
|
|
1181
|
+
input.destinationGasLimit
|
|
1182
|
+
);
|
|
1166
1183
|
const destination = normalizeSS58(input.destination);
|
|
1167
1184
|
const evm = getForeverMoneyEvmDeployment(input.evmChain);
|
|
1168
1185
|
const exit = {
|
|
@@ -1187,13 +1204,19 @@ async function prepareEvmToSubtensor(provider, input) {
|
|
|
1187
1204
|
address: evm.contracts.gateway,
|
|
1188
1205
|
abi: spokeAbi,
|
|
1189
1206
|
functionName: "quoteBridgeToFinney",
|
|
1190
|
-
args: [
|
|
1207
|
+
args: [
|
|
1208
|
+
asset.evmToken,
|
|
1209
|
+
input.amountWei,
|
|
1210
|
+
exit,
|
|
1211
|
+
destinationGasLimit
|
|
1212
|
+
]
|
|
1191
1213
|
}) : quoteSpokeWithFee(
|
|
1192
1214
|
provider,
|
|
1193
1215
|
evm.contracts.gateway,
|
|
1194
1216
|
asset.evmToken,
|
|
1195
1217
|
input.amountWei,
|
|
1196
1218
|
exit,
|
|
1219
|
+
destinationGasLimit,
|
|
1197
1220
|
partnerFee
|
|
1198
1221
|
)
|
|
1199
1222
|
]);
|
|
@@ -1203,6 +1226,7 @@ async function prepareEvmToSubtensor(provider, input) {
|
|
|
1203
1226
|
asset.evmToken,
|
|
1204
1227
|
input.amountWei,
|
|
1205
1228
|
exit,
|
|
1229
|
+
destinationGasLimit,
|
|
1206
1230
|
partnerFee
|
|
1207
1231
|
);
|
|
1208
1232
|
estimatedBridgeGas = await provider.estimateGas({
|
|
@@ -2418,6 +2442,7 @@ export {
|
|
|
2418
2442
|
BASE_CCIP_SELECTOR,
|
|
2419
2443
|
BASE_CHAIN_ID,
|
|
2420
2444
|
BASIS_POINTS,
|
|
2445
|
+
EVM_TO_SUBTENSOR_DESTINATION_GAS_LIMIT,
|
|
2421
2446
|
EVM_WEI_PER_RAO,
|
|
2422
2447
|
FOREVERMONEY_DEPLOYMENT_VERSION,
|
|
2423
2448
|
ForeverMoneyError,
|