Collects Uniswap V3 protocol fees and stakes them on Bittensor SN10.
yarn installNote: Requires Node.js 22+ for Hardhat 3
- Derive the treasury coldkey from the treasury EVM address:
Copy the output (a 32-byte hex string) into the
yarn derive:coldkey 0xd7370E4E7637b040EA1C2EB6a13447fC65448C23
treasuryColdkeyfield. - Populate
ignition/parameters.jsonwith:poolAddress– the Uniswap V3 pooltreasuryAddress– the treasury EVM accounttreasuryColdkey– the derived value from step 1stakingHotkey– the validator hotkey
- Deploy with Ignition:
yarn hardhat ignition deploy ./ignition/modules/Buyback.ts \ --network bittensor_mainnet \ --parameters ignition/parameters.json
Treasury workflow:
- Collect protocol fees from Uniswap pool (external)
- Send collected tokens to Buyback contract
- Call
buyback(limitPriceRao, allowPartial)to:- Swap token1 → token0 if needed
- Stake tokens to the configured hotkey via the staking precompile
- Call
collectStake()to move the accumulated stake to the treasury coldkey
- Start a Hardhat fork of Bittensor mainnet (for example:
yarn hardhat node --fork $BITTENSOR_RPC --fork-block-number <block>). - In a separate terminal run the suite against that fork:
yarn hardhat test --network localhost. - The tests interact with the real Uniswap pool, so keep the fork in sync with the block used above.
If you deploy manually without Ignition, call:
setTreasury(address, bytes32)with the treasury address and derived coldkey.setStakingHotkey(bytes32)with the validator hotkey.setBuybackColdkey(bytes32)with the coldkey derived from the Buyback contract address.
- @openzeppelin/contracts 5.4.0
- @uniswap/v3-core
- Hardhat 3 Beta