diff --git a/contract-tests/src/subtensor.ts b/contract-tests/src/subtensor.ts index f5829c76aa..2b3b5d8be1 100644 --- a/contract-tests/src/subtensor.ts +++ b/contract-tests/src/subtensor.ts @@ -419,4 +419,22 @@ export async function setNetworkLastLockCost(api: TypedApi, defau const valueOnChain = await api.query.SubtensorModule.NetworkLastLockCost.getValue() assert.equal(defaultNetworkLastLockCost, valueOnChain) +} + + +export async function getStake(api: TypedApi, hotkey: string, coldkey: string, netuid: number): Promise { + const value = (await api.query.SubtensorModule.AlphaV2.getValue(hotkey, coldkey, netuid)); + + const mantissa = value.mantissa; + const exponent = value.exponent; + + let result: bigint; + + if (exponent >= 0) { + result = mantissa * BigInt(10) ** exponent; + } else { + result = mantissa / BigInt(10) ** -exponent; + } + + return result; } \ No newline at end of file diff --git a/contract-tests/test/alphaPool.test.ts b/contract-tests/test/alphaPool.test.ts index 361e1213bb..f3ec5dde66 100644 --- a/contract-tests/test/alphaPool.test.ts +++ b/contract-tests/test/alphaPool.test.ts @@ -9,7 +9,7 @@ import { PublicClient } from "viem"; import { TypedApi } from "polkadot-api"; import { ALPHA_POOL_CONTRACT_ABI, ALPHA_POOL_CONTRACT_BYTECODE } from "../src/contracts/alphaPool"; import { convertH160ToPublicKey, convertH160ToSS58, convertPublicKeyToSs58, toViemAddress } from "../src/address-utils"; -import { forceSetBalanceToEthAddress, disableWhiteListCheck, addNewSubnetwork, forceSetBalanceToSs58Address, startCall, burnedRegister } from "../src/subtensor"; +import { forceSetBalanceToEthAddress, disableWhiteListCheck, addNewSubnetwork, forceSetBalanceToSs58Address, startCall, burnedRegister, getStake } from "../src/subtensor"; import { ethers } from "ethers" import { tao } from "../src/balance-math"; import { ISTAKING_V2_ADDRESS, IStakingV2ABI } from "../src/contracts/staking"; @@ -46,7 +46,7 @@ describe("bridge token contract deployment", () => { let netuid = (await api.query.SubtensorModule.TotalNetworks.getValue()) - 1 // the unit in V2 is RAO, not ETH let stakeBalance = tao(20) - const stakeBefore = await api.query.SubtensorModule.Alpha.getValue(convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet.address), netuid) + const stakeBefore = await getStake(api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet.address), netuid) const contract = new ethers.Contract(ISTAKING_V2_ADDRESS, IStakingV2ABI, wallet); const tx = await contract.addStake(hotkey.publicKey, stakeBalance.toString(), netuid) await tx.wait() @@ -56,7 +56,7 @@ describe("bridge token contract deployment", () => { ); assert.ok(stakeFromContract > stakeBefore) - const stakeAfter = await api.query.SubtensorModule.Alpha.getValue(convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet.address), netuid) + const stakeAfter = await getStake(api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet.address), netuid) assert.ok(stakeAfter > stakeBefore) assert.ok(stakeFromContract > tao(20)) }) @@ -66,7 +66,7 @@ describe("bridge token contract deployment", () => { let netuid = (await api.query.SubtensorModule.TotalNetworks.getValue()) - 1 const stakingPrecompile = new ethers.Contract(ISTAKING_V2_ADDRESS, IStakingV2ABI, wallet); - const stakeBeforeDeposit = await api.query.SubtensorModule.Alpha.getValue(convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet.address), netuid) + const stakeBeforeDeposit = await getStake(api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet.address), netuid) const contractFactory = new ethers.ContractFactory(ALPHA_POOL_CONTRACT_ABI, ALPHA_POOL_CONTRACT_BYTECODE, wallet) const contract = await contractFactory.deploy(hotkey.publicKey) @@ -103,11 +103,11 @@ describe("bridge token contract deployment", () => { await depositAlphaTx.wait() // compare wallet stake - const stakeAftereDeposit = await api.query.SubtensorModule.Alpha.getValue(convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet.address), netuid) + const stakeAftereDeposit = await getStake(api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet.address), netuid) assert.ok(stakeAftereDeposit < stakeBeforeDeposit) // check the contract stake - const ContractStake = await api.query.SubtensorModule.Alpha.getValue(convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(contractAddress), netuid) + const ContractStake = await getStake(api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(contractAddress), netuid) assert.ok(ContractStake > 0) // check the wallet alpha balance in contract, the actual swapped alpha could be less than alphaAmount in deposit call diff --git a/contract-tests/test/precompileWrapper.direct-call.test.ts b/contract-tests/test/precompileWrapper.direct-call.test.ts index 5d63dfbb44..fa1354f3ce 100644 --- a/contract-tests/test/precompileWrapper.direct-call.test.ts +++ b/contract-tests/test/precompileWrapper.direct-call.test.ts @@ -10,6 +10,7 @@ import { startCall, disableWhiteListCheck, forceSetBalanceToEthAddress, + getStake, } from "../src/subtensor"; import { ethers } from "ethers"; @@ -147,7 +148,8 @@ describe("PrecompileWrapper - Direct Call Tests", () => { it("Should add stake via wrapper", async () => { const stakeAmount = tao(2); - const stakeBefore = await api.query.SubtensorModule.Alpha.getValue( + const stakeBefore = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wrapperAddress), netuid @@ -161,7 +163,8 @@ describe("PrecompileWrapper - Direct Call Tests", () => { ); await addStakeTx.wait(); - const stakeAfter = await api.query.SubtensorModule.Alpha.getValue( + const stakeAfter = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wrapperAddress), netuid @@ -171,7 +174,8 @@ describe("PrecompileWrapper - Direct Call Tests", () => { it("Should remove stake via wrapper", async () => { const removeAmount = tao(1); - const stakeBefore = await api.query.SubtensorModule.Alpha.getValue( + const stakeBefore = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wrapperAddress), netuid @@ -184,7 +188,8 @@ describe("PrecompileWrapper - Direct Call Tests", () => { ); await removeStakeTx.wait(); - const stakeAfter = await api.query.SubtensorModule.Alpha.getValue( + const stakeAfter = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wrapperAddress), netuid diff --git a/contract-tests/test/staking.precompile.add-remove.test.ts b/contract-tests/test/staking.precompile.add-remove.test.ts index d7dfcb0d3d..9eef7d4dbf 100644 --- a/contract-tests/test/staking.precompile.add-remove.test.ts +++ b/contract-tests/test/staking.precompile.add-remove.test.ts @@ -11,6 +11,7 @@ import { forceSetBalanceToEthAddress, forceSetBalanceToSs58Address, addNewSubnetwork, burnedRegister, sendProxyCall, startCall, + getStake, } from "../src/subtensor" import { ETH_LOCAL_URL } from "../src/config"; import { ISTAKING_ADDRESS, ISTAKING_V2_ADDRESS, IStakingABI, IStakingV2ABI } from "../src/contracts/staking" @@ -54,7 +55,7 @@ describe("Test neuron precompile add remove stake", () => { let netuid = (await api.query.SubtensorModule.TotalNetworks.getValue()) - 1 // ETH unit let stakeBalance = raoToEth(tao(20)) - const stakeBefore = await api.query.SubtensorModule.Alpha.getValue(convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet1.address), netuid) + const stakeBefore = await getStake(api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet1.address), netuid) const contract = new ethers.Contract(ISTAKING_ADDRESS, IStakingABI, wallet1); const tx = await contract.addStake(hotkey.publicKey, netuid, { value: stakeBalance.toString() }) await tx.wait() @@ -64,7 +65,7 @@ describe("Test neuron precompile add remove stake", () => { ); assert.ok(stakeFromContract > stakeBefore) - const stakeAfter = await api.query.SubtensorModule.Alpha.getValue(convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet1.address), netuid) + const stakeAfter = await getStake(api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet1.address), netuid) assert.ok(stakeAfter > stakeBefore) }) @@ -72,7 +73,7 @@ describe("Test neuron precompile add remove stake", () => { let netuid = (await api.query.SubtensorModule.TotalNetworks.getValue()) - 1 // the unit in V2 is RAO, not ETH let stakeBalance = tao(20) - const stakeBefore = await api.query.SubtensorModule.Alpha.getValue(convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet2.address), netuid) + const stakeBefore = await getStake(api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet2.address), netuid) const contract = new ethers.Contract(ISTAKING_V2_ADDRESS, IStakingV2ABI, wallet2); const tx = await contract.addStake(hotkey.publicKey, stakeBalance.toString(), netuid) await tx.wait() @@ -82,7 +83,7 @@ describe("Test neuron precompile add remove stake", () => { ); assert.ok(stakeFromContract > stakeBefore) - const stakeAfter = await api.query.SubtensorModule.Alpha.getValue(convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet2.address), netuid) + const stakeAfter = await getStake(api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet2.address), netuid) assert.ok(stakeAfter > stakeBefore) }) @@ -90,7 +91,7 @@ describe("Test neuron precompile add remove stake", () => { // wrong netuid let netuid = 12345; let stakeBalance = raoToEth(tao(20)) - const stakeBefore = await api.query.SubtensorModule.Alpha.getValue(convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet1.address), netuid) + const stakeBefore = await getStake(api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet1.address), netuid) const contract = new ethers.Contract(ISTAKING_ADDRESS, IStakingABI, wallet1); try { const tx = await contract.addStake(hotkey.publicKey, netuid, { value: stakeBalance.toString() }) @@ -104,7 +105,7 @@ describe("Test neuron precompile add remove stake", () => { await contract.getStake(hotkey.publicKey, convertH160ToPublicKey(wallet1.address), netuid) ); assert.equal(stakeFromContract, stakeBefore) - const stakeAfter = await api.query.SubtensorModule.Alpha.getValue(convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet1.address), netuid) + const stakeAfter = await getStake(api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet1.address), netuid) assert.equal(stakeAfter, stakeBefore) }); @@ -113,7 +114,7 @@ describe("Test neuron precompile add remove stake", () => { let netuid = 12345; // the unit in V2 is RAO, not ETH let stakeBalance = tao(20) - const stakeBefore = await api.query.SubtensorModule.Alpha.getValue(convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet2.address), netuid) + const stakeBefore = await getStake(api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet2.address), netuid) const contract = new ethers.Contract(ISTAKING_V2_ADDRESS, IStakingV2ABI, wallet2); try { @@ -128,7 +129,7 @@ describe("Test neuron precompile add remove stake", () => { await contract.getStake(hotkey.publicKey, convertH160ToPublicKey(wallet2.address), netuid) ); assert.equal(stakeFromContract, stakeBefore) - const stakeAfter = await api.query.SubtensorModule.Alpha.getValue(convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet2.address), netuid) + const stakeAfter = await getStake(api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet2.address), netuid) assert.equal(stakeAfter, stakeBefore) }) @@ -248,7 +249,8 @@ describe("Test neuron precompile add remove stake", () => { assert.equal(proxiesAfterAdd[0][0].delegate, convertPublicKeyToSs58(proxy.publicKey)) - let stakeBefore = await api.query.SubtensorModule.Alpha.getValue( + let stakeBefore = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid @@ -261,7 +263,8 @@ describe("Test neuron precompile add remove stake", () => { }) await sendProxyCall(api, call.decodedCall, ss58Address, proxy) - let stakeAfter = await api.query.SubtensorModule.Alpha.getValue( + let stakeAfter = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid @@ -306,7 +309,8 @@ describe("Test neuron precompile add remove stake", () => { assert.equal(proxiesAfterAdd[0][0].delegate, convertPublicKeyToSs58(proxy.publicKey)) - let stakeBefore = await api.query.SubtensorModule.Alpha.getValue( + let stakeBefore = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid @@ -320,7 +324,8 @@ describe("Test neuron precompile add remove stake", () => { await sendProxyCall(api, call.decodedCall, ss58Address, proxy) - let stakeAfter = await api.query.SubtensorModule.Alpha.getValue( + let stakeAfter = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid diff --git a/contract-tests/test/staking.precompile.burn-alpha.test.ts b/contract-tests/test/staking.precompile.burn-alpha.test.ts index 825587602e..f98c988b52 100644 --- a/contract-tests/test/staking.precompile.burn-alpha.test.ts +++ b/contract-tests/test/staking.precompile.burn-alpha.test.ts @@ -10,6 +10,7 @@ import { convertH160ToPublicKey } from "../src/address-utils" import { forceSetBalanceToEthAddress, forceSetBalanceToSs58Address, addNewSubnetwork, burnedRegister, startCall, + getStake, } from "../src/subtensor" import { ISTAKING_V2_ADDRESS, IStakingV2ABI } from "../src/contracts/staking" @@ -72,7 +73,8 @@ describe("Test staking precompile burn alpha", () => { let netuid = (await api.query.SubtensorModule.TotalNetworks.getValue()) - 1 // Get current stake - const currentStake = await api.query.SubtensorModule.Alpha.getValue( + const currentStake = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), convertH160ToSS58(wallet1.address), netuid diff --git a/contract-tests/test/staking.precompile.full-limit.test.ts b/contract-tests/test/staking.precompile.full-limit.test.ts index 156fd38f25..faf09d65fd 100644 --- a/contract-tests/test/staking.precompile.full-limit.test.ts +++ b/contract-tests/test/staking.precompile.full-limit.test.ts @@ -12,6 +12,7 @@ import { addStake, forceSetBalanceToEthAddress, forceSetBalanceToSs58Address, + getStake, startCall, } from "../src/subtensor"; import { ethers } from "ethers"; @@ -51,7 +52,8 @@ describe("Test staking precompile add remove limit methods", () => { let netuid = (await api.query.SubtensorModule.TotalNetworks.getValue()) - 1; let ss58Address = convertH160ToSS58(wallet1.address); - const alpha = await api.query.SubtensorModule.Alpha.getValue( + const alpha = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid, @@ -72,7 +74,8 @@ describe("Test staking precompile add remove limit methods", () => { ); await tx.wait(); - const alphaAfterAddStake = await api.query.SubtensorModule.Alpha.getValue( + const alphaAfterAddStake = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid, @@ -85,7 +88,8 @@ describe("Test staking precompile add remove limit methods", () => { let netuid = (await api.query.SubtensorModule.TotalNetworks.getValue()) - 1; let ss58Address = convertH160ToSS58(wallet1.address); - const alpha = await api.query.SubtensorModule.Alpha.getValue( + const alpha = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid, @@ -104,7 +108,8 @@ describe("Test staking precompile add remove limit methods", () => { ); await tx.wait(); - const alphaAfterRemoveStake = await api.query.SubtensorModule.Alpha.getValue( + const alphaAfterRemoveStake = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid, @@ -120,7 +125,8 @@ describe("Test staking precompile add remove limit methods", () => { let netuid = (await api.query.SubtensorModule.TotalNetworks.getValue()) - 1; let ss58Address = convertH160ToSS58(wallet2.address); - const alpha = await api.query.SubtensorModule.Alpha.getValue( + const alpha = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid, @@ -141,7 +147,8 @@ describe("Test staking precompile add remove limit methods", () => { ); await tx.wait(); - const alphaAfterAddStake = await api.query.SubtensorModule.Alpha.getValue( + const alphaAfterAddStake = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid, @@ -154,7 +161,8 @@ describe("Test staking precompile add remove limit methods", () => { let netuid = (await api.query.SubtensorModule.TotalNetworks.getValue()) - 1; let ss58Address = convertH160ToSS58(wallet2.address); - const alpha = await api.query.SubtensorModule.Alpha.getValue( + const alpha = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid, @@ -172,7 +180,8 @@ describe("Test staking precompile add remove limit methods", () => { ); await tx.wait(); - const alphaAfterRemoveStake = await api.query.SubtensorModule.Alpha.getValue( + const alphaAfterRemoveStake = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid, diff --git a/contract-tests/test/staking.precompile.limit.test.ts b/contract-tests/test/staking.precompile.limit.test.ts index 759aaecce2..eff1394911 100644 --- a/contract-tests/test/staking.precompile.limit.test.ts +++ b/contract-tests/test/staking.precompile.limit.test.ts @@ -12,6 +12,7 @@ import { addStake, forceSetBalanceToEthAddress, forceSetBalanceToSs58Address, + getStake, startCall, } from "../src/subtensor"; import { ethers } from "ethers"; @@ -47,7 +48,8 @@ describe("Test staking precompile add remove limit methods", () => { let netuid = (await api.query.SubtensorModule.TotalNetworks.getValue()) - 1; let ss58Address = convertH160ToSS58(wallet1.address); - const alpha = await api.query.SubtensorModule.Alpha.getValue( + const alpha = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid, @@ -68,7 +70,8 @@ describe("Test staking precompile add remove limit methods", () => { ); await tx.wait(); - const alphaAfterAddStake = await api.query.SubtensorModule.Alpha.getValue( + const alphaAfterAddStake = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid, @@ -81,7 +84,8 @@ describe("Test staking precompile add remove limit methods", () => { let netuid = (await api.query.SubtensorModule.TotalNetworks.getValue()) - 1; let ss58Address = convertH160ToSS58(wallet1.address); - const alpha = await api.query.SubtensorModule.Alpha.getValue( + const alpha = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid, @@ -102,7 +106,8 @@ describe("Test staking precompile add remove limit methods", () => { ); await tx.wait(); - const alphaAfterRemoveStake = await api.query.SubtensorModule.Alpha.getValue( + const alphaAfterRemoveStake = await getStake( + api, convertPublicKeyToSs58(hotkey.publicKey), ss58Address, netuid, diff --git a/contract-tests/test/staking.precompile.reward.test.ts b/contract-tests/test/staking.precompile.reward.test.ts index d04620c91b..31e15c6225 100644 --- a/contract-tests/test/staking.precompile.reward.test.ts +++ b/contract-tests/test/staking.precompile.reward.test.ts @@ -9,7 +9,8 @@ import { setTxRateLimit, setTempo, setWeightsSetRateLimit, setSubnetOwnerCut, setMinDelegateTake, setActivityCutoff, addStake, setWeight, rootRegister, startCall, - disableAdminFreezeWindowAndOwnerHyperparamRateLimit + disableAdminFreezeWindowAndOwnerHyperparamRateLimit, + getStake } from "../src/subtensor" describe("Test neuron precompile reward", () => { @@ -63,7 +64,8 @@ describe("Test neuron precompile reward", () => { await addStake(api, netuid, convertPublicKeyToSs58(validator.publicKey), tao(100), coldkey) - const miner_alpha_before_emission = await api.query.SubtensorModule.Alpha.getValue( + const miner_alpha_before_emission = await getStake( + api, convertPublicKeyToSs58(miner.publicKey), convertPublicKeyToSs58(coldkey.publicKey), netuid @@ -87,7 +89,8 @@ describe("Test neuron precompile reward", () => { index = 0; while (index < 60) { - let miner_current_alpha = await api.query.SubtensorModule.Alpha.getValue( + let miner_current_alpha = await getStake( + api, convertPublicKeyToSs58(miner.publicKey), convertPublicKeyToSs58(coldkey.publicKey), netuid diff --git a/contract-tests/test/subnet.precompile.hyperparameter.test.ts b/contract-tests/test/subnet.precompile.hyperparameter.test.ts index 75d361a77f..2c9355ec40 100644 --- a/contract-tests/test/subnet.precompile.hyperparameter.test.ts +++ b/contract-tests/test/subnet.precompile.hyperparameter.test.ts @@ -517,7 +517,7 @@ describe("Test the Subnet precompile contract", () => { // const tx = await contract.setAlphaValues(netuid, newValue[0], newValue[1]); // await tx.wait(); - // let onchainValue = await api.query.SubtensorModule.AlphaValues.getValue(netuid) + // let onchainValue = await api.query.SubtensorModule.AlphaV2Values.getValue(netuid) // let value = await contract.getAlphaValues(netuid) // let valueFromContract = [Number(value[0]), Number(value[1])] diff --git a/e2e/shared/staking.ts b/e2e/shared/staking.ts index 96241f64e9..408d18a619 100644 --- a/e2e/shared/staking.ts +++ b/e2e/shared/staking.ts @@ -152,8 +152,20 @@ export async function getStake( coldkey: string, netuid: number, ): Promise { - const raw = await api.query.SubtensorModule.Alpha.getValue(hotkey, coldkey, netuid); - return u64f64ToInt(raw); + const value = (await api.query.SubtensorModule.AlphaV2.getValue(hotkey, coldkey, netuid)); + + const mantissa = value.mantissa; + const exponent = value.exponent; + + let result: bigint; + + if (exponent >= 0) { + result = mantissa * BigInt(10) ** exponent; + } else { + result = mantissa / BigInt(10) ** -exponent; + } + + return result; } /** diff --git a/e2e/staking/test/move-stake.test.ts b/e2e/staking/test/move-stake.test.ts index 292d8d8ded..5c61002062 100644 --- a/e2e/staking/test/move-stake.test.ts +++ b/e2e/staking/test/move-stake.test.ts @@ -10,7 +10,6 @@ import { addStake, moveStake, getStake, - getStakeRaw, tao, log, } from "e2e-shared"; @@ -53,7 +52,7 @@ describe("▶ move_stake extrinsic", () => { // Move stake to destination hotkey on different subnet // Use raw U64F64 value for the extrinsic - const originStakeRaw = await getStakeRaw(api, originHotkeyAddress, coldkeyAddress, netuid1); + const originStakeRaw = await getStake(api, originHotkeyAddress, coldkeyAddress, netuid1); const moveAmount = originStakeRaw / 2n; await moveStake(api, coldkey, originHotkeyAddress, destinationHotkeyAddress, netuid1, netuid2, moveAmount); @@ -103,7 +102,7 @@ describe("▶ move_stake extrinsic", () => { // Move stake to destination hotkey on the same subnet // Use raw U64F64 value for the extrinsic - const originStakeRaw = await getStakeRaw(api, originHotkeyAddress, coldkeyAddress, netuid); + const originStakeRaw = await getStake(api, originHotkeyAddress, coldkeyAddress, netuid); const moveAmount = originStakeRaw / 2n; await moveStake(api, coldkey, originHotkeyAddress, destinationHotkeyAddress, netuid, netuid, moveAmount); diff --git a/e2e/staking/test/remove-stake.test.ts b/e2e/staking/test/remove-stake.test.ts index db9f5aa150..e7eb4c7437 100644 --- a/e2e/staking/test/remove-stake.test.ts +++ b/e2e/staking/test/remove-stake.test.ts @@ -10,7 +10,6 @@ import { addStake, removeStake, getStake, - getStakeRaw, tao, log, } from "e2e-shared"; @@ -42,7 +41,7 @@ describe("▶ remove_stake extrinsic", () => { expect(stakeBefore, "Should have stake before removal").toBeGreaterThan(0n); // Remove stake (amount is in alpha units - use raw U64F64 value) - const stakeRaw = await getStakeRaw(api, hotkeyAddress, coldkeyAddress, netuid); + const stakeRaw = await getStake(api, hotkeyAddress, coldkeyAddress, netuid); const unstakeAmount = stakeRaw / 2n; await removeStake(api, coldkey, hotkeyAddress, netuid, unstakeAmount); diff --git a/e2e/staking/test/swap-stake-limit.test.ts b/e2e/staking/test/swap-stake-limit.test.ts index 316ddff051..0b60ea113b 100644 --- a/e2e/staking/test/swap-stake-limit.test.ts +++ b/e2e/staking/test/swap-stake-limit.test.ts @@ -10,7 +10,6 @@ import { addStake, swapStakeLimit, getStake, - getStakeRaw, tao, log, } from "e2e-shared"; @@ -54,7 +53,7 @@ describe("▶ swap_stake_limit extrinsic", () => { // Swap stake with limit price (0.99 TAO relative price limit, allow partial fills) // Use raw U64F64 value for the extrinsic - const stake1Raw = await getStakeRaw(api, hotkey1Address, coldkeyAddress, netuid1); + const stake1Raw = await getStake(api, hotkey1Address, coldkeyAddress, netuid1); const swapAmount = stake1Raw / 2n; const limitPrice = (tao(1) * 99n) / 100n; // 0.99 TAO await swapStakeLimit(api, coldkey, hotkey1Address, netuid1, netuid2, swapAmount, limitPrice, true); @@ -109,7 +108,7 @@ describe("▶ swap_stake_limit extrinsic", () => { // Swap stake with limit price (fill or kill mode - allow_partial = false) // Use raw U64F64 value for the extrinsic - const stake1Raw = await getStakeRaw(api, hotkey1Address, coldkeyAddress, netuid1); + const stake1Raw = await getStake(api, hotkey1Address, coldkeyAddress, netuid1); const swapAmount = stake1Raw / 2n; const limitPrice = tao(1) / 10n; // 0.1 TAO - permissive limit to allow slippage await swapStakeLimit(api, coldkey, hotkey1Address, netuid1, netuid2, swapAmount, limitPrice, false); diff --git a/e2e/staking/test/swap-stake.test.ts b/e2e/staking/test/swap-stake.test.ts index 44a818dd81..aa284bd9a4 100644 --- a/e2e/staking/test/swap-stake.test.ts +++ b/e2e/staking/test/swap-stake.test.ts @@ -10,7 +10,7 @@ import { addStake, swapStake, getStake, - getStakeRaw, + getStake, tao, log, } from "e2e-shared"; @@ -54,7 +54,7 @@ describe("▶ swap_stake extrinsic", () => { // Swap half the stake from subnet1 to subnet2 // Use raw U64F64 value for the extrinsic - const stake1Raw = await getStakeRaw(api, hotkey1Address, coldkeyAddress, netuid1); + const stake1Raw = await getStake(api, hotkey1Address, coldkeyAddress, netuid1); const swapAmount = stake1Raw / 2n; await swapStake(api, coldkey, hotkey1Address, netuid1, netuid2, swapAmount); diff --git a/e2e/staking/test/transfer-stake.test.ts b/e2e/staking/test/transfer-stake.test.ts index 330ca0b8d9..b8daf665d7 100644 --- a/e2e/staking/test/transfer-stake.test.ts +++ b/e2e/staking/test/transfer-stake.test.ts @@ -9,7 +9,6 @@ import { addStake, transferStake, getStake, - getStakeRaw, tao, log, } from "e2e-shared"; @@ -55,7 +54,7 @@ describe("▶ transfer_stake extrinsic", () => { // Transfer stake to destination coldkey on a different subnet // Use raw U64F64 value for the extrinsic - const originStakeRaw = await getStakeRaw(api, hotkey1Address, originColdkeyAddress, netuid1); + const originStakeRaw = await getStake(api, hotkey1Address, originColdkeyAddress, netuid1); const transferAmount = originStakeRaw / 2n; await transferStake( api, @@ -110,7 +109,7 @@ describe("▶ transfer_stake extrinsic", () => { // Transfer stake to destination coldkey // Use raw U64F64 value for the extrinsic, transfer half to avoid AmountTooLow error - const originStakeRaw = await getStakeRaw(api, hotkeyAddress, originColdkeyAddress, netuid); + const originStakeRaw = await getStake(api, hotkeyAddress, originColdkeyAddress, netuid); const transferAmount = originStakeRaw / 2n; await transferStake(api, originColdkey, destinationColdkeyAddress, hotkeyAddress, netuid, netuid, transferAmount);