From f95f542e91985eb3ef29de2f0ebc670c878a575c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0ulovsk=C3=BD?= Date: Thu, 27 Jun 2024 14:01:06 +0200 Subject: [PATCH] Upgrade to uniswap v3 --- contracts/.env.example | 17 +- contracts/foundry.toml | 4 +- contracts/lib/forge-std | 2 +- contracts/package.json | 2 +- contracts/script/Deploy.s.sol | 5 +- contracts/script/TestCreateBeef.s.sol | 39 +++ contracts/script/TestQuote.s.sol | 29 ++ contracts/src/Beef.sol | 75 +++-- contracts/src/Slaughterhouse.sol | 14 +- contracts/test/Beef.t.sol | 1 - contracts/test/Slaughterhouse.t.sol | 4 +- contracts/yarn.lock | 172 ++++++++++- src/abi/beef.ts | 209 +++----------- src/abi/quoterAbi.ts | 147 ++++++++++ src/abi/slaughterhouse.ts | 125 ++------ src/abi/uniswapV2Pair.ts | 376 ------------------------- src/abi/uniswapV2Router.ts | 340 ---------------------- src/app/beef/new/page.tsx | 8 +- src/components/providers/Providers.tsx | 1 + src/constants.ts | 10 +- src/hooks/mutations.ts | 66 ++--- src/utils/chain.ts | 3 +- 22 files changed, 555 insertions(+), 1094 deletions(-) create mode 100644 contracts/script/TestCreateBeef.s.sol create mode 100644 contracts/script/TestQuote.s.sol create mode 100644 src/abi/quoterAbi.ts delete mode 100644 src/abi/uniswapV2Pair.ts delete mode 100644 src/abi/uniswapV2Router.ts diff --git a/contracts/.env.example b/contracts/.env.example index 688fc92..7ace7ec 100644 --- a/contracts/.env.example +++ b/contracts/.env.example @@ -1,10 +1,11 @@ -LOCALCHAIN_DEPLOYER_PK=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 -WETH_ADDRESS=0x24fe7807089e321395172633aA9c4bBa4Ac4a357 -WSTETH_ADDRESS=0xeAc0CE2994032302f72c078b678c09CcA515AD49 -UNIV2ROUTER_ADDRESS=0x6682375ebc1df04676c0c5050934272368e6e883 +export LOCALCHAIN_DEPLOYER_PK= +export WETH_ADDRESS=0x4200000000000000000000000000000000000006 +export WSTETH_ADDRESS=0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 +export UNIROUTER_ADDRESS= RPC_URL= -DEPLOYER_PRIVATE_KEY= -CONTRACT_OWNER_ADDRESS= +export DEPLOYER_PRIVATE_KEY= +export CONTRACT_OWNER_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 ETHERSCAN_API_KEY= -PROTOCOL_REWARD_BASIS_POINTS= -ARBITERS_REWARD_BASIS_POINTS= \ No newline at end of file +export PROTOCOL_REWARD_BASIS_POINTS=100 +export ARBITERS_REWARD_BASIS_POINTS=300 + diff --git a/contracts/foundry.toml b/contracts/foundry.toml index cd4e7cd..cad08dc 100644 --- a/contracts/foundry.toml +++ b/contracts/foundry.toml @@ -6,7 +6,9 @@ libs = ["lib"] remappings = [ '@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/', '@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/', - '@uniswap/v2-periphery/contracts/=node_modules/@uniswap/v2-periphery/contracts/' + '@uniswap/v3-periphery/contracts/=node_modules/@uniswap/v3-periphery/contracts/', + '@uniswap/v3-core/contracts/=node_modules/@uniswap/v3-core/contracts/', + '@uniswap/swap-router-contracts/contracts/=node_modules/@uniswap/swap-router-contracts/contracts/' ] # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options diff --git a/contracts/lib/forge-std b/contracts/lib/forge-std index 978ac6f..52715a2 160000 --- a/contracts/lib/forge-std +++ b/contracts/lib/forge-std @@ -1 +1 @@ -Subproject commit 978ac6fadb62f5f0b723c996f64be52eddba6801 +Subproject commit 52715a217dc51d0de15877878ab8213f6cbbbab5 diff --git a/contracts/package.json b/contracts/package.json index d992e41..7dc2fae 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -16,6 +16,6 @@ "devDependencies": { "@openzeppelin/contracts": "^5.0.1", "@openzeppelin/contracts-upgradeable": "^5.0.1", - "@uniswap/v2-periphery": "^1.1.0-beta.0" + "@uniswap/swap-router-contracts": "^1.3.1" } } diff --git a/contracts/script/Deploy.s.sol b/contracts/script/Deploy.s.sol index 14a0289..9c2c008 100644 --- a/contracts/script/Deploy.s.sol +++ b/contracts/script/Deploy.s.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.13; import {Script, console2} from "forge-std/Script.sol"; import {Slaughterhouse} from "../src/Slaughterhouse.sol"; +import '@uniswap/v3-periphery/contracts/interfaces/IQuoterV2.sol'; contract Deploy is Script { function setUp() public {} @@ -11,7 +12,7 @@ contract Deploy is Script { function run() public { address WETH = vm.envAddress("WETH_ADDRESS"); address WSTETH = vm.envAddress("WSTETH_ADDRESS"); - address uniswapV2Router = vm.envAddress("UNIV2ROUTER_ADDRESS"); + address uniswapRouter = vm.envAddress("UNIROUTER_ADDRESS"); address initialOwner = vm.envAddress("CONTRACT_OWNER_ADDRESS"); uint256 protocolRewardBasisPoints = vm.envUint("PROTOCOL_REWARD_BASIS_POINTS"); uint256 arbitersRewardBasisPoints = vm.envUint("ARBITERS_REWARD_BASIS_POINTS"); @@ -20,7 +21,7 @@ contract Deploy is Script { Slaughterhouse slaughterhouse = new Slaughterhouse( WETH, WSTETH, - uniswapV2Router, + uniswapRouter, initialOwner, protocolRewardBasisPoints, arbitersRewardBasisPoints diff --git a/contracts/script/TestCreateBeef.s.sol b/contracts/script/TestCreateBeef.s.sol new file mode 100644 index 0000000..608effa --- /dev/null +++ b/contracts/script/TestCreateBeef.s.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import {Script, console2} from "forge-std/Script.sol"; + +import {Slaughterhouse} from "../src/Slaughterhouse.sol"; +import {Beef} from "../src/Beef.sol"; + +contract Deploy is Script { + function setUp() public {} + + function run() public { + address WETH = vm.envAddress("WETH_ADDRESS"); + address WSTETH = vm.envAddress("WSTETH_ADDRESS"); + address uniswapRouter = vm.envAddress("UNIROUTER_ADDRESS"); + address initialOwner = vm.envAddress("CONTRACT_OWNER_ADDRESS"); + uint256 protocolRewardBasisPoints = vm.envUint("PROTOCOL_REWARD_BASIS_POINTS"); + uint256 arbitersRewardBasisPoints = vm.envUint("ARBITERS_REWARD_BASIS_POINTS"); + vm.broadcast(); + + address[] memory arbitersArray = new address[](3); + arbitersArray[0] = address(0x70997970C51812dc3A010C7d01b50e0d17dc79C8); + arbitersArray[1] = address(0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65); + arbitersArray[2] = address(0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc); + Beef.ConstructorParams memory params = Beef.ConstructorParams({ + owner: address(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266), + wager: 1 ether, + challenger: address(0x90F79bf6EB2c4f870365E785982E1f101E93b906), + settleStart: block.timestamp + 1 hours, + joinDeadline: block.timestamp + 1 days, + staking: true, + title: "test", + description: "test2", + arbiters: arbitersArray + }); +address payable slaughterhouse = payable(0x457cCf29090fe5A24c19c1bc95F492168C0EaFdb); + Slaughterhouse(slaughterhouse).packageBeef{value: 1 ether}(params, 0.1 ether); + } +} diff --git a/contracts/script/TestQuote.s.sol b/contracts/script/TestQuote.s.sol new file mode 100644 index 0000000..30ff748 --- /dev/null +++ b/contracts/script/TestQuote.s.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import {Script, console2} from "forge-std/Script.sol"; + +import '@uniswap/v3-periphery/contracts/interfaces/IQuoterV2.sol'; + +contract TestQuote is Script { + function setUp() public {} + + function run() public { + address WETH = vm.envAddress("WETH_ADDRESS"); + address WSTETH = vm.envAddress("WSTETH_ADDRESS"); + vm.broadcast(); + + address qa = address(0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a); + IQuoterV2.QuoteExactInputSingleParams memory params = IQuoterV2.QuoteExactInputSingleParams({ + tokenIn: WETH, + tokenOut: WSTETH, + fee: 100, + amountIn: 1 ether, + sqrtPriceLimitX96: 0 + }); + uint amountOut; + (amountOut,,,) = IQuoterV2(qa).quoteExactInputSingle(params); + + console2.log("Quote: ", amountOut); + } +} diff --git a/contracts/src/Beef.sol b/contracts/src/Beef.sol index 75505d0..2a17198 100644 --- a/contracts/src/Beef.sol +++ b/contracts/src/Beef.sol @@ -5,9 +5,19 @@ import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; -import {IUniswapV2Router02} from "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol"; +import '@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol'; +import "@uniswap/swap-router-contracts/contracts/interfaces/IV3SwapRouter.sol"; import {Slaughterhouse} from "./Slaughterhouse.sol"; +/// @title Interface for WETH9 +interface IWETH9 is IERC20 { + /// @notice Deposit ether to get wrapped ether + function deposit() external payable; + + /// @notice Withdraw wrapped ether to get ether + function withdraw(uint256) external; +} + contract Beef is OwnableUpgradeable { using Address for address; @@ -67,9 +77,9 @@ contract Beef is OwnableUpgradeable { // @notice Flag indicating if the beef is staking - the underlying ETH had been staked for wstETH and is earning staking yield. bool public staking; - // @notice Address of the Uniswap V2 Router. - IUniswapV2Router02 public uniswapV2Router; - IERC20 public WETH; + // @notice Address of the Uniswap V3 Router. + IV3SwapRouter public swapRouter; + IWETH9 public WETH9; IERC20 public WSTETH; uint128 public resultYes; @@ -152,7 +162,7 @@ contract Beef is OwnableUpgradeable { uint256 amountOutMin, address _weth, address _wsteth, - address _uniswapV2Router, + address _swapRouter, address payable _slaughterhouse, uint256 _protocolRewardBasisPoints, uint256 _arbitersRewardBasisPoints @@ -171,9 +181,9 @@ contract Beef is OwnableUpgradeable { arbiters = params.arbiters; joinDeadline = params.joinDeadline; staking = params.staking; - WETH = IERC20(_weth); + WETH9 = IWETH9(_weth); WSTETH = IERC20(_wsteth); - uniswapV2Router = IUniswapV2Router02(_uniswapV2Router); + swapRouter = IV3SwapRouter(_swapRouter); slaughterhouse = Slaughterhouse(_slaughterhouse); protocolRewardBasisPoints = _protocolRewardBasisPoints; arbitersRewardBasisPoints = _arbitersRewardBasisPoints; @@ -370,23 +380,46 @@ contract Beef is OwnableUpgradeable { } function _stakeBeef(uint256 amountOutMin) internal { - address[] memory path; - path = new address[](2); - path[0] = address(WETH); - path[1] = address(WSTETH); - uniswapV2Router.swapExactETHForTokens{value: address(this).balance}( - amountOutMin, path, address(this), block.timestamp - ); + WETH9.deposit{value: address(this).balance}(); + + uint256 wethBalance = WETH9.balanceOf(address(this)); + + TransferHelper.safeApprove(address(WETH9), address(swapRouter), wethBalance); + + IV3SwapRouter.ExactInputSingleParams memory params = + IV3SwapRouter.ExactInputSingleParams({ + tokenIn: address(WETH9), + tokenOut: address(WSTETH), + fee: 100, // 0.01% + recipient: address(this), + amountIn: wethBalance, + amountOutMinimum: amountOutMin, + sqrtPriceLimitX96: 0 + }); + + swapRouter.exactInputSingle(params); } function _unstakeBeef(uint256 amountOutMin) internal { - address[] memory path; - path = new address[](2); - path[0] = address(WSTETH); - path[1] = address(WETH); - uint256 amountIn = IERC20(WSTETH).balanceOf(address(this)); - WSTETH.approve(address(uniswapV2Router), amountIn); - uniswapV2Router.swapExactTokensForETH(amountIn, amountOutMin, path, address(this), block.timestamp); + uint256 wstethBalance = WSTETH.balanceOf(address(this)); + + TransferHelper.safeApprove(address(WSTETH), address(swapRouter), wstethBalance); + + IV3SwapRouter.ExactInputSingleParams memory params = IV3SwapRouter.ExactInputSingleParams({ + tokenIn: address(WSTETH), + tokenOut: address(WETH9), + fee: 100, // 0.01% + recipient: address(this), + amountIn: wstethBalance, + amountOutMinimum: amountOutMin, + sqrtPriceLimitX96: 0 + }); + + swapRouter.exactInputSingle(params); + + uint256 wethBalance = WETH9.balanceOf(address(this)); + + WETH9.withdraw(wethBalance); } function _transferEth(address recipient, uint256 amount) internal { diff --git a/contracts/src/Slaughterhouse.sol b/contracts/src/Slaughterhouse.sol index 0b679bd..5f365b9 100644 --- a/contracts/src/Slaughterhouse.sol +++ b/contracts/src/Slaughterhouse.sol @@ -24,11 +24,11 @@ contract Slaughterhouse is Ownable2Step { uint256 public arbitersRewardBasisPoints; // @notice The address of Wrapped ETH - address public WETH; + address public WETH9; // @notice The address of Wrapped Staked ETH address public WSTETH; - // @notice The address of Uniswap V2 Router (for swapping WETH/WSTETH) - address public uniswapV2Router; + // @notice The address of Uniswap V3 Router (for swapping WETH9/WSTETH) + address public uniswapV3Router; error InvalidBasisPoints(uint256 totalBasisPoints, uint256 providedBasisPoints); error ZeroBalance(); @@ -42,15 +42,15 @@ contract Slaughterhouse is Ownable2Step { constructor( address _weth, address _wsteth, - address _uniswapV2Router, + address _uniswapV3Router, address initialOwner, uint256 _protocolRewardBasisPoints, uint256 _arbitersRewardBasisPoints ) Ownable(initialOwner) { beefImplementation = address(new Beef()); - WETH = _weth; + WETH9 = _weth; WSTETH = _wsteth; - uniswapV2Router = _uniswapV2Router; + uniswapV3Router = _uniswapV3Router; protocolRewardBasisPoints = _protocolRewardBasisPoints; arbitersRewardBasisPoints = _arbitersRewardBasisPoints; } @@ -94,7 +94,7 @@ contract Slaughterhouse is Ownable2Step { returns (address payable) { address payable beef = payable(Clones.clone(beefImplementation)); - Beef(beef).initialize{value: msg.value}(params, amountOutMin, WETH, WSTETH, uniswapV2Router, payable(this), protocolRewardBasisPoints, arbitersRewardBasisPoints); + Beef(beef).initialize{value: msg.value}(params, amountOutMin, WETH9, WSTETH, uniswapV3Router, payable(this), protocolRewardBasisPoints, arbitersRewardBasisPoints); beefs.push(beef); emit BeefPackaged(beef, params.owner, params.challenger); return beef; diff --git a/contracts/test/Beef.t.sol b/contracts/test/Beef.t.sol index 8a58701..5332a43 100644 --- a/contracts/test/Beef.t.sol +++ b/contracts/test/Beef.t.sol @@ -4,7 +4,6 @@ pragma solidity ^0.8.13; import {Test, console} from "forge-std/Test.sol"; import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; -import {IUniswapV2Router02} from "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol"; import {Beef} from "../src/Beef.sol"; import {Slaughterhouse} from "../src/Slaughterhouse.sol"; diff --git a/contracts/test/Slaughterhouse.t.sol b/contracts/test/Slaughterhouse.t.sol index aa18a0e..2e82bdf 100644 --- a/contracts/test/Slaughterhouse.t.sol +++ b/contracts/test/Slaughterhouse.t.sol @@ -52,9 +52,9 @@ contract SlaughterhouseTest is Test { assertEq(beef.arbiters(2), params.arbiters[2], "Beef arbiter 2 mismatch"); assertEq(beef.joinDeadline(), params.joinDeadline, "Beef joinDeadline mismatch"); assertEq(beef.staking(), params.staking, "Beef staking mismatch"); - assertEq(address(beef.WETH()), WETH, "Beef WETH mismatch"); + assertEq(address(beef.WETH9()), WETH, "Beef WETH mismatch"); assertEq(address(beef.WSTETH()), WSTETH, "Beef WSTETH mismatch"); - assertEq(address(beef.uniswapV2Router()), uniswapV2Router, "Beef uniswapV2Router mismatch"); + assertEq(address(beef.swapRouter()), uniswapV2Router, "Beef uniswapV2Router mismatch"); assertEq(beef.protocolRewardBasisPoints(), slaughterhouse.protocolRewardBasisPoints(), "Beef protocolRewardsBasisPoints mismatch"); assertEq(beef.arbitersRewardBasisPoints(), slaughterhouse.arbitersRewardBasisPoints(), "Beef arbitersRewardsBasisPoints mismatch"); assertEq(beef.totalBasisPoints(), slaughterhouse.totalBasisPoints(), "Beef totalBasisPoints mismatch"); diff --git a/contracts/yarn.lock b/contracts/yarn.lock index f8c0c1d..d2ea7b9 100644 --- a/contracts/yarn.lock +++ b/contracts/yarn.lock @@ -7,25 +7,169 @@ resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-5.0.2.tgz#3e5321a2ecdd0b206064356798c21225b6ec7105" integrity sha512-0MmkHSHiW2NRFiT9/r5Lu4eJq5UJ4/tzlOgYXNAIj/ONkQTVnz22pLxDvp4C4uZ9he7ZFvGn3Driptn1/iU7tQ== +"@openzeppelin/contracts@3.4.2-solc-0.7": + version "3.4.2-solc-0.7" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.2-solc-0.7.tgz#38f4dbab672631034076ccdf2f3201fab1726635" + integrity sha512-W6QmqgkADuFcTLzHL8vVoNBtkwjvQRpYIAom7KiUNoLKghyx3FgH0GBjt8NRvigV1ZmMOBllvE1By1C+bi8WpA== + "@openzeppelin/contracts@^5.0.1": version "5.0.2" resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-5.0.2.tgz#b1d03075e49290d06570b2fd42154d76c2a5d210" integrity sha512-ytPc6eLGcHHnapAZ9S+5qsdomhjo6QBHTDRRBFfTxXIpsicMhVPouPgmUPebZZZGX7vt9USA+Z+0M0dSVtSUEA== -"@uniswap/lib@1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@uniswap/lib/-/lib-1.1.1.tgz#0afd29601846c16e5d082866cbb24a9e0758e6bc" - integrity sha512-2yK7sLpKIT91TiS5sewHtOa7YuM8IuBXVl4GZv2jZFys4D2sY7K5vZh6MqD25TPA95Od+0YzCVq6cTF2IKrOmg== +"@uniswap/lib@^4.0.1-alpha": + version "4.0.1-alpha" + resolved "https://registry.yarnpkg.com/@uniswap/lib/-/lib-4.0.1-alpha.tgz#2881008e55f075344675b3bca93f020b028fbd02" + integrity sha512-f6UIliwBbRsgVLxIaBANF6w09tYqc6Y/qXdsrbEmXHyFA7ILiKrIwRFXe1yOg8M3cksgVsO9N7yuL2DdCGQKBA== + +"@uniswap/swap-router-contracts@^1.3.1": + version "1.3.1" + resolved "https://registry.yarnpkg.com/@uniswap/swap-router-contracts/-/swap-router-contracts-1.3.1.tgz#0ebbb93eb578625618ed9489872de381f9c66fb4" + integrity sha512-mh/YNbwKb7Mut96VuEtL+Z5bRe0xVIbjjiryn+iMMrK2sFKhR4duk/86mEz0UO5gSx4pQIw9G5276P5heY/7Rg== + dependencies: + "@openzeppelin/contracts" "3.4.2-solc-0.7" + "@uniswap/v2-core" "^1.0.1" + "@uniswap/v3-core" "^1.0.0" + "@uniswap/v3-periphery" "^1.4.4" + dotenv "^14.2.0" + hardhat-watcher "^2.1.1" + +"@uniswap/v2-core@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@uniswap/v2-core/-/v2-core-1.0.1.tgz#af8f508bf183204779938969e2e54043e147d425" + integrity sha512-MtybtkUPSyysqLY2U210NBDeCHX+ltHt3oADGdjqoThZaFRDKwM6k1Nb3F0A3hk5hwuQvytFWhrWHOEq6nVJ8Q== + +"@uniswap/v3-core@^1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@uniswap/v3-core/-/v3-core-1.0.1.tgz#b6d2bdc6ba3c3fbd610bdc502395d86cd35264a0" + integrity sha512-7pVk4hEm00j9tc71Y9+ssYpO6ytkeI0y7WE9P6UcmNzhxPePwyAxImuhVsTqWK9YFvzgtvzJHi64pBl4jUzKMQ== + +"@uniswap/v3-periphery@^1.4.4": + version "1.4.4" + resolved "https://registry.yarnpkg.com/@uniswap/v3-periphery/-/v3-periphery-1.4.4.tgz#d2756c23b69718173c5874f37fd4ad57d2f021b7" + integrity sha512-S4+m+wh8HbWSO3DKk4LwUCPZJTpCugIsHrWR86m/OrUyvSqGDTXKFfc2sMuGXCZrD1ZqO3rhQsKgdWg3Hbb2Kw== + dependencies: + "@openzeppelin/contracts" "3.4.2-solc-0.7" + "@uniswap/lib" "^4.0.1-alpha" + "@uniswap/v2-core" "^1.0.1" + "@uniswap/v3-core" "^1.0.0" + base64-sol "1.0.1" + +anymatch@~3.1.2: + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +base64-sol@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/base64-sol/-/base64-sol-1.0.1.tgz#91317aa341f0bc763811783c5729f1c2574600f6" + integrity sha512-ld3cCNMeXt4uJXmLZBHFGMvVpK9KsLVEhPpFRXnvSVAqABKbuNZg/+dsq3NuM+wxFLb/UrVkz7m1ciWmkMfTbg== + +binary-extensions@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522" + integrity sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw== + +braces@~3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" + integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== + dependencies: + fill-range "^7.1.1" + +chokidar@^3.5.3: + version "3.6.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.6.0.tgz#197c6cc669ef2a8dc5e7b4d97ee4e092c3eb0d5b" + integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + +dotenv@^14.2.0: + version "14.3.2" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-14.3.2.tgz#7c30b3a5f777c79a3429cb2db358eef6751e8369" + integrity sha512-vwEppIphpFdvaMCaHfCEv9IgwcxMljMw2TnAQBB4VWPvzXQLTb82jwmdOKzlEVUL3gNFT4l4TPKO+Bn+sqcrVQ== -"@uniswap/v2-core@1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@uniswap/v2-core/-/v2-core-1.0.0.tgz#e0fab91a7d53e8cafb5326ae4ca18351116b0844" - integrity sha512-BJiXrBGnN8mti7saW49MXwxDBRFiWemGetE58q8zgfnPPzQKq55ADltEILqOt6VFZ22kVeVKbF8gVd8aY3l7pA== +fill-range@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" + integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg== + dependencies: + to-regex-range "^5.0.1" + +fsevents@~2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + +glob-parent@~5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +hardhat-watcher@^2.1.1: + version "2.5.0" + resolved "https://registry.yarnpkg.com/hardhat-watcher/-/hardhat-watcher-2.5.0.tgz#3ee76c3cb5b99f2875b78d176207745aa484ed4a" + integrity sha512-Su2qcSMIo2YO2PrmJ0/tdkf+6pSt8zf9+4URR5edMVti6+ShI8T3xhPrwugdyTOFuyj8lKHrcTZNKUFYowYiyA== + dependencies: + chokidar "^3.5.3" + +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +picomatch@^2.0.4, picomatch@^2.2.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== + dependencies: + picomatch "^2.2.1" -"@uniswap/v2-periphery@^1.1.0-beta.0": - version "1.1.0-beta.0" - resolved "https://registry.yarnpkg.com/@uniswap/v2-periphery/-/v2-periphery-1.1.0-beta.0.tgz#20a4ccfca22f1a45402303aedb5717b6918ebe6d" - integrity sha512-6dkwAMKza8nzqYiXEr2D86dgW3TTavUvCR0w2Tu33bAbM8Ah43LKAzH7oKKPRT5VJQaMi1jtkGs1E8JPor1n5g== +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== dependencies: - "@uniswap/lib" "1.1.1" - "@uniswap/v2-core" "1.0.0" + is-number "^7.0.0" diff --git a/src/abi/beef.ts b/src/abi/beef.ts index 8b04e6b..4c7e6e5 100644 --- a/src/abi/beef.ts +++ b/src/abi/beef.ts @@ -3,9 +3,9 @@ export const beefAbi = [ { type: "fallback", stateMutability: "payable" }, { type: "function", - name: "WETH", + name: "WETH9", inputs: [], - outputs: [{ name: "", type: "address", internalType: "contract IERC20" }], + outputs: [{ name: "", type: "address", internalType: "contract IWETH9" }], stateMutability: "view", }, { @@ -15,13 +15,7 @@ export const beefAbi = [ outputs: [{ name: "", type: "address", internalType: "contract IERC20" }], stateMutability: "view", }, - { - type: "function", - name: "arbiterAttend", - inputs: [], - outputs: [], - stateMutability: "nonpayable", - }, + { type: "function", name: "arbiterAttend", inputs: [], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "arbiters", @@ -99,16 +93,8 @@ export const beefAbi = [ { name: "settleStart", type: "uint256", internalType: "uint256" }, { name: "title", type: "string", internalType: "string" }, { name: "description", type: "string", internalType: "string" }, - { - name: "arbiters", - type: "address[]", - internalType: "address[]", - }, - { - name: "joinDeadline", - type: "uint256", - internalType: "uint256", - }, + { name: "arbiters", type: "address[]", internalType: "address[]" }, + { name: "joinDeadline", type: "uint256", internalType: "uint256" }, { name: "staking", type: "bool", internalType: "bool" }, ], }, @@ -117,16 +103,8 @@ export const beefAbi = [ { name: "resultNo", type: "uint128", internalType: "uint128" }, { name: "attendCount", type: "uint256", internalType: "uint256" }, { name: "beefGone", type: "bool", internalType: "bool" }, - { - name: "protocolRewardBasisPoints", - type: "uint256", - internalType: "uint256", - }, - { - name: "arbitersRewardBasisPoints", - type: "uint256", - internalType: "uint256", - }, + { name: "protocolRewardBasisPoints", type: "uint256", internalType: "uint256" }, + { name: "arbitersRewardBasisPoints", type: "uint256", internalType: "uint256" }, ], }, ], @@ -169,22 +147,10 @@ export const beefAbi = [ { name: "amountOutMin", type: "uint256", internalType: "uint256" }, { name: "_weth", type: "address", internalType: "address" }, { name: "_wsteth", type: "address", internalType: "address" }, - { name: "_uniswapV2Router", type: "address", internalType: "address" }, - { - name: "_slaughterhouse", - type: "address", - internalType: "address payable", - }, - { - name: "_protocolRewardBasisPoints", - type: "uint256", - internalType: "uint256", - }, - { - name: "_arbitersRewardBasisPoints", - type: "uint256", - internalType: "uint256", - }, + { name: "_swapRouter", type: "address", internalType: "address" }, + { name: "_slaughterhouse", type: "address", internalType: "address payable" }, + { name: "_protocolRewardBasisPoints", type: "uint256", internalType: "uint256" }, + { name: "_arbitersRewardBasisPoints", type: "uint256", internalType: "uint256" }, ], outputs: [], stateMutability: "payable", @@ -217,13 +183,7 @@ export const beefAbi = [ outputs: [{ name: "", type: "uint256", internalType: "uint256" }], stateMutability: "view", }, - { - type: "function", - name: "renounceOwnership", - inputs: [], - outputs: [], - stateMutability: "nonpayable", - }, + { type: "function", name: "renounceOwnership", inputs: [], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "resultNo", @@ -280,6 +240,13 @@ export const beefAbi = [ outputs: [{ name: "", type: "bool", internalType: "bool" }], stateMutability: "view", }, + { + type: "function", + name: "swapRouter", + inputs: [], + outputs: [{ name: "", type: "address", internalType: "contract IV3SwapRouter" }], + stateMutability: "view", + }, { type: "function", name: "title", @@ -301,19 +268,6 @@ export const beefAbi = [ outputs: [], stateMutability: "nonpayable", }, - { - type: "function", - name: "uniswapV2Router", - inputs: [], - outputs: [ - { - name: "", - type: "address", - internalType: "contract IUniswapV2Router02", - }, - ], - stateMutability: "view", - }, { type: "function", name: "wager", @@ -338,14 +292,7 @@ export const beefAbi = [ { type: "event", name: "ArbiterAttended", - inputs: [ - { - name: "arbiter", - type: "address", - indexed: true, - internalType: "address", - }, - ], + inputs: [{ name: "arbiter", type: "address", indexed: true, internalType: "address" }], anonymous: false, }, { type: "event", name: "BeefCooking", inputs: [], anonymous: false }, @@ -353,81 +300,29 @@ export const beefAbi = [ type: "event", name: "BeefCreated", inputs: [ - { - name: "owner", - type: "address", - indexed: true, - internalType: "address", - }, - { - name: "challenger", - type: "address", - indexed: true, - internalType: "address", - }, - { - name: "wager", - type: "uint256", - indexed: false, - internalType: "uint256", - }, - { - name: "settleStart", - type: "uint256", - indexed: false, - internalType: "uint256", - }, + { name: "owner", type: "address", indexed: true, internalType: "address" }, + { name: "challenger", type: "address", indexed: true, internalType: "address" }, + { name: "wager", type: "uint256", indexed: false, internalType: "uint256" }, + { name: "settleStart", type: "uint256", indexed: false, internalType: "uint256" }, { name: "title", type: "string", indexed: false, internalType: "string" }, - { - name: "description", - type: "string", - indexed: false, - internalType: "string", - }, - { - name: "arbiters", - type: "address[]", - indexed: false, - internalType: "address[]", - }, - { - name: "protocolRewardBasisPoints", - type: "uint256", - indexed: false, - internalType: "uint256", - }, - { - name: "arbitersRewardBasisPoints", - type: "uint256", - indexed: false, - internalType: "uint256", - }, + { name: "description", type: "string", indexed: false, internalType: "string" }, + { name: "arbiters", type: "address[]", indexed: false, internalType: "address[]" }, + { name: "protocolRewardBasisPoints", type: "uint256", indexed: false, internalType: "uint256" }, + { name: "arbitersRewardBasisPoints", type: "uint256", indexed: false, internalType: "uint256" }, ], anonymous: false, }, { type: "event", name: "BeefServed", - inputs: [ - { - name: "winner", - type: "address", - indexed: true, - internalType: "address", - }, - ], + inputs: [{ name: "winner", type: "address", indexed: true, internalType: "address" }], anonymous: false, }, { type: "event", name: "BeefSettled", inputs: [ - { - name: "arbiter", - type: "address", - indexed: true, - internalType: "address", - }, + { name: "arbiter", type: "address", indexed: true, internalType: "address" }, { name: "verdict", type: "bool", indexed: false, internalType: "bool" }, ], anonymous: false, @@ -435,45 +330,21 @@ export const beefAbi = [ { type: "event", name: "BeefWithdrawn", - inputs: [ - { - name: "hadBeenCooking", - type: "bool", - indexed: false, - internalType: "bool", - }, - ], + inputs: [{ name: "hadBeenCooking", type: "bool", indexed: false, internalType: "bool" }], anonymous: false, }, { type: "event", name: "Initialized", - inputs: [ - { - name: "version", - type: "uint64", - indexed: false, - internalType: "uint64", - }, - ], + inputs: [{ name: "version", type: "uint64", indexed: false, internalType: "uint64" }], anonymous: false, }, { type: "event", name: "OwnershipTransferred", inputs: [ - { - name: "previousOwner", - type: "address", - indexed: true, - internalType: "address", - }, - { - name: "newOwner", - type: "address", - indexed: true, - internalType: "address", - }, + { name: "previousOwner", type: "address", indexed: true, internalType: "address" }, + { name: "newOwner", type: "address", indexed: true, internalType: "address" }, ], anonymous: false, }, @@ -521,11 +392,7 @@ export const beefAbi = [ { name: "timestamp", type: "uint256", internalType: "uint256" }, ], }, - { - type: "error", - name: "BeefNotArbiter", - inputs: [{ name: "sender", type: "address", internalType: "address" }], - }, + { type: "error", name: "BeefNotArbiter", inputs: [{ name: "sender", type: "address", internalType: "address" }] }, { type: "error", name: "BeefNotChallenger", @@ -572,11 +439,7 @@ export const beefAbi = [ { type: "error", name: "EthTransferFailed", inputs: [] }, { type: "error", name: "InvalidInitialization", inputs: [] }, { type: "error", name: "NotInitializing", inputs: [] }, - { - type: "error", - name: "OwnableInvalidOwner", - inputs: [{ name: "owner", type: "address", internalType: "address" }], - }, + { type: "error", name: "OwnableInvalidOwner", inputs: [{ name: "owner", type: "address", internalType: "address" }] }, { type: "error", name: "OwnableUnauthorizedAccount", diff --git a/src/abi/quoterAbi.ts b/src/abi/quoterAbi.ts new file mode 100644 index 0000000..1b5947a --- /dev/null +++ b/src/abi/quoterAbi.ts @@ -0,0 +1,147 @@ +export const quoterAbi = [ + { + inputs: [ + { internalType: "address", name: "_factory", type: "address" }, + { internalType: "address", name: "_WETH9", type: "address" }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [], + name: "WETH9", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "factory", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "bytes", name: "path", type: "bytes" }, + { internalType: "uint256", name: "amountIn", type: "uint256" }, + ], + name: "quoteExactInput", + outputs: [ + { internalType: "uint256", name: "amountOut", type: "uint256" }, + { + internalType: "uint160[]", + name: "sqrtPriceX96AfterList", + type: "uint160[]", + }, + { + internalType: "uint32[]", + name: "initializedTicksCrossedList", + type: "uint32[]", + }, + { internalType: "uint256", name: "gasEstimate", type: "uint256" }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + components: [ + { internalType: "address", name: "tokenIn", type: "address" }, + { internalType: "address", name: "tokenOut", type: "address" }, + { internalType: "uint256", name: "amountIn", type: "uint256" }, + { internalType: "uint24", name: "fee", type: "uint24" }, + { + internalType: "uint160", + name: "sqrtPriceLimitX96", + type: "uint160", + }, + ], + internalType: "struct IQuoterV2.QuoteExactInputSingleParams", + name: "params", + type: "tuple", + }, + ], + name: "quoteExactInputSingle", + outputs: [ + { internalType: "uint256", name: "amountOut", type: "uint256" }, + { internalType: "uint160", name: "sqrtPriceX96After", type: "uint160" }, + { + internalType: "uint32", + name: "initializedTicksCrossed", + type: "uint32", + }, + { internalType: "uint256", name: "gasEstimate", type: "uint256" }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes", name: "path", type: "bytes" }, + { internalType: "uint256", name: "amountOut", type: "uint256" }, + ], + name: "quoteExactOutput", + outputs: [ + { internalType: "uint256", name: "amountIn", type: "uint256" }, + { + internalType: "uint160[]", + name: "sqrtPriceX96AfterList", + type: "uint160[]", + }, + { + internalType: "uint32[]", + name: "initializedTicksCrossedList", + type: "uint32[]", + }, + { internalType: "uint256", name: "gasEstimate", type: "uint256" }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + components: [ + { internalType: "address", name: "tokenIn", type: "address" }, + { internalType: "address", name: "tokenOut", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "uint24", name: "fee", type: "uint24" }, + { + internalType: "uint160", + name: "sqrtPriceLimitX96", + type: "uint160", + }, + ], + internalType: "struct IQuoterV2.QuoteExactOutputSingleParams", + name: "params", + type: "tuple", + }, + ], + name: "quoteExactOutputSingle", + outputs: [ + { internalType: "uint256", name: "amountIn", type: "uint256" }, + { internalType: "uint160", name: "sqrtPriceX96After", type: "uint160" }, + { + internalType: "uint32", + name: "initializedTicksCrossed", + type: "uint32", + }, + { internalType: "uint256", name: "gasEstimate", type: "uint256" }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "int256", name: "amount0Delta", type: "int256" }, + { internalType: "int256", name: "amount1Delta", type: "int256" }, + { internalType: "bytes", name: "path", type: "bytes" }, + ], + name: "uniswapV3SwapCallback", + outputs: [], + stateMutability: "view", + type: "function", + }, +] as const; diff --git a/src/abi/slaughterhouse.ts b/src/abi/slaughterhouse.ts index 7d384bc..27acfb7 100644 --- a/src/abi/slaughterhouse.ts +++ b/src/abi/slaughterhouse.ts @@ -4,25 +4,17 @@ export const slaughterhouseAbi = [ inputs: [ { name: "_weth", type: "address", internalType: "address" }, { name: "_wsteth", type: "address", internalType: "address" }, - { name: "_uniswapV2Router", type: "address", internalType: "address" }, + { name: "_uniswapV3Router", type: "address", internalType: "address" }, { name: "initialOwner", type: "address", internalType: "address" }, - { - name: "_protocolRewardBasisPoints", - type: "uint256", - internalType: "uint256", - }, - { - name: "_arbitersRewardBasisPoints", - type: "uint256", - internalType: "uint256", - }, + { name: "_protocolRewardBasisPoints", type: "uint256", internalType: "uint256" }, + { name: "_arbitersRewardBasisPoints", type: "uint256", internalType: "uint256" }, ], stateMutability: "nonpayable", }, { type: "receive", stateMutability: "payable" }, { type: "function", - name: "WETH", + name: "WETH9", inputs: [], outputs: [{ name: "", type: "address", internalType: "address" }], stateMutability: "view", @@ -34,13 +26,7 @@ export const slaughterhouseAbi = [ outputs: [{ name: "", type: "address", internalType: "address" }], stateMutability: "view", }, - { - type: "function", - name: "acceptOwnership", - inputs: [], - outputs: [], - stateMutability: "nonpayable", - }, + { type: "function", name: "acceptOwnership", inputs: [], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "arbitersRewardBasisPoints", @@ -132,27 +118,13 @@ export const slaughterhouseAbi = [ outputs: [{ name: "", type: "uint256", internalType: "uint256" }], stateMutability: "view", }, - { - type: "function", - name: "renounceOwnership", - inputs: [], - outputs: [], - stateMutability: "nonpayable", - }, + { type: "function", name: "renounceOwnership", inputs: [], outputs: [], stateMutability: "nonpayable" }, { type: "function", name: "setRewardBasisPoints", inputs: [ - { - name: "_protocolRewardBasisPoints", - type: "uint256", - internalType: "uint256", - }, - { - name: "_arbitersRewardBasisPoints", - type: "uint256", - internalType: "uint256", - }, + { name: "_protocolRewardBasisPoints", type: "uint256", internalType: "uint256" }, + { name: "_arbitersRewardBasisPoints", type: "uint256", internalType: "uint256" }, ], outputs: [], stateMutability: "nonpayable", @@ -173,35 +145,19 @@ export const slaughterhouseAbi = [ }, { type: "function", - name: "uniswapV2Router", + name: "uniswapV3Router", inputs: [], outputs: [{ name: "", type: "address", internalType: "address" }], stateMutability: "view", }, - { - type: "function", - name: "withdrawRewards", - inputs: [], - outputs: [], - stateMutability: "nonpayable", - }, + { type: "function", name: "withdrawRewards", inputs: [], outputs: [], stateMutability: "nonpayable" }, { type: "event", name: "BeefPackaged", inputs: [ { name: "beef", type: "address", indexed: true, internalType: "address" }, - { - name: "owner", - type: "address", - indexed: true, - internalType: "address", - }, - { - name: "challenger", - type: "address", - indexed: true, - internalType: "address", - }, + { name: "owner", type: "address", indexed: true, internalType: "address" }, + { name: "challenger", type: "address", indexed: true, internalType: "address" }, ], anonymous: false, }, @@ -209,18 +165,8 @@ export const slaughterhouseAbi = [ type: "event", name: "OwnershipTransferStarted", inputs: [ - { - name: "previousOwner", - type: "address", - indexed: true, - internalType: "address", - }, - { - name: "newOwner", - type: "address", - indexed: true, - internalType: "address", - }, + { name: "previousOwner", type: "address", indexed: true, internalType: "address" }, + { name: "newOwner", type: "address", indexed: true, internalType: "address" }, ], anonymous: false, }, @@ -228,18 +174,8 @@ export const slaughterhouseAbi = [ type: "event", name: "OwnershipTransferred", inputs: [ - { - name: "previousOwner", - type: "address", - indexed: true, - internalType: "address", - }, - { - name: "newOwner", - type: "address", - indexed: true, - internalType: "address", - }, + { name: "previousOwner", type: "address", indexed: true, internalType: "address" }, + { name: "newOwner", type: "address", indexed: true, internalType: "address" }, ], anonymous: false, }, @@ -247,32 +183,15 @@ export const slaughterhouseAbi = [ type: "event", name: "RewardBasisPointsChanged", inputs: [ - { - name: "newProtocolRewardBasisPoints", - type: "uint256", - indexed: false, - internalType: "uint256", - }, - { - name: "newArbitersRewardBasisPoints", - type: "uint256", - indexed: false, - internalType: "uint256", - }, + { name: "newProtocolRewardBasisPoints", type: "uint256", indexed: false, internalType: "uint256" }, + { name: "newArbitersRewardBasisPoints", type: "uint256", indexed: false, internalType: "uint256" }, ], anonymous: false, }, { type: "event", name: "RewardsWithdrawn", - inputs: [ - { - name: "amount", - type: "uint256", - indexed: false, - internalType: "uint256", - }, - ], + inputs: [{ name: "amount", type: "uint256", indexed: false, internalType: "uint256" }], anonymous: false, }, { type: "error", name: "ERC1167FailedCreateClone", inputs: [] }, @@ -286,11 +205,7 @@ export const slaughterhouseAbi = [ { name: "providedBasisPoints", type: "uint256", internalType: "uint256" }, ], }, - { - type: "error", - name: "OwnableInvalidOwner", - inputs: [{ name: "owner", type: "address", internalType: "address" }], - }, + { type: "error", name: "OwnableInvalidOwner", inputs: [{ name: "owner", type: "address", internalType: "address" }] }, { type: "error", name: "OwnableUnauthorizedAccount", diff --git a/src/abi/uniswapV2Pair.ts b/src/abi/uniswapV2Pair.ts deleted file mode 100644 index 1b084b2..0000000 --- a/src/abi/uniswapV2Pair.ts +++ /dev/null @@ -1,376 +0,0 @@ -export const uniswapV2PairAbi = [ - { inputs: [], stateMutability: "nonpayable", type: "constructor" }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "owner", - type: "address", - }, - { - indexed: true, - internalType: "address", - name: "spender", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "value", - type: "uint256", - }, - ], - name: "Approval", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "sender", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "amount0", - type: "uint256", - }, - { - indexed: false, - internalType: "uint256", - name: "amount1", - type: "uint256", - }, - { indexed: true, internalType: "address", name: "to", type: "address" }, - ], - name: "Burn", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "sender", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "amount0", - type: "uint256", - }, - { - indexed: false, - internalType: "uint256", - name: "amount1", - type: "uint256", - }, - ], - name: "Mint", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "sender", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "amount0In", - type: "uint256", - }, - { - indexed: false, - internalType: "uint256", - name: "amount1In", - type: "uint256", - }, - { - indexed: false, - internalType: "uint256", - name: "amount0Out", - type: "uint256", - }, - { - indexed: false, - internalType: "uint256", - name: "amount1Out", - type: "uint256", - }, - { indexed: true, internalType: "address", name: "to", type: "address" }, - ], - name: "Swap", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "uint112", - name: "reserve0", - type: "uint112", - }, - { - indexed: false, - internalType: "uint112", - name: "reserve1", - type: "uint112", - }, - ], - name: "Sync", - type: "event", - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: "address", name: "from", type: "address" }, - { indexed: true, internalType: "address", name: "to", type: "address" }, - { - indexed: false, - internalType: "uint256", - name: "value", - type: "uint256", - }, - ], - name: "Transfer", - type: "event", - }, - { - inputs: [], - name: "DOMAIN_SEPARATOR", - outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "MINIMUM_LIQUIDITY", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "PERMIT_TYPEHASH", - outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "", type: "address" }, - { internalType: "address", name: "", type: "address" }, - ], - name: "allowance", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "spender", type: "address" }, - { internalType: "uint256", name: "value", type: "uint256" }, - ], - name: "approve", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "", type: "address" }], - name: "balanceOf", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "to", type: "address" }], - name: "burn", - outputs: [ - { internalType: "uint256", name: "amount0", type: "uint256" }, - { internalType: "uint256", name: "amount1", type: "uint256" }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "decimals", - outputs: [{ internalType: "uint8", name: "", type: "uint8" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "factory", - outputs: [{ internalType: "address", name: "", type: "address" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "getReserves", - outputs: [ - { internalType: "uint112", name: "_reserve0", type: "uint112" }, - { internalType: "uint112", name: "_reserve1", type: "uint112" }, - { internalType: "uint32", name: "_blockTimestampLast", type: "uint32" }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "_token0", type: "address" }, - { internalType: "address", name: "_token1", type: "address" }, - ], - name: "initialize", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "kLast", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "to", type: "address" }], - name: "mint", - outputs: [{ internalType: "uint256", name: "liquidity", type: "uint256" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "name", - outputs: [{ internalType: "string", name: "", type: "string" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "", type: "address" }], - name: "nonces", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "owner", type: "address" }, - { internalType: "address", name: "spender", type: "address" }, - { internalType: "uint256", name: "value", type: "uint256" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - { internalType: "uint8", name: "v", type: "uint8" }, - { internalType: "bytes32", name: "r", type: "bytes32" }, - { internalType: "bytes32", name: "s", type: "bytes32" }, - ], - name: "permit", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "price0CumulativeLast", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "price1CumulativeLast", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "to", type: "address" }], - name: "skim", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "amount0Out", type: "uint256" }, - { internalType: "uint256", name: "amount1Out", type: "uint256" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "bytes", name: "data", type: "bytes" }, - ], - name: "swap", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "symbol", - outputs: [{ internalType: "string", name: "", type: "string" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "sync", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "token0", - outputs: [{ internalType: "address", name: "", type: "address" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "token1", - outputs: [{ internalType: "address", name: "", type: "address" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "totalSupply", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "value", type: "uint256" }, - ], - name: "transfer", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "from", type: "address" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "value", type: "uint256" }, - ], - name: "transferFrom", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "nonpayable", - type: "function", - }, -] as const diff --git a/src/abi/uniswapV2Router.ts b/src/abi/uniswapV2Router.ts deleted file mode 100644 index d28a171..0000000 --- a/src/abi/uniswapV2Router.ts +++ /dev/null @@ -1,340 +0,0 @@ -export const uniswapV2RouterAbi = [ - { - inputs: [ - { internalType: "address", name: "_factory", type: "address" }, - { internalType: "address", name: "_WETH", type: "address" }, - ], - stateMutability: "nonpayable", - type: "constructor", - }, - { - inputs: [], - name: "WETH", - outputs: [{ internalType: "address", name: "", type: "address" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "tokenA", type: "address" }, - { internalType: "address", name: "tokenB", type: "address" }, - { internalType: "uint256", name: "amountADesired", type: "uint256" }, - { internalType: "uint256", name: "amountBDesired", type: "uint256" }, - { internalType: "uint256", name: "amountAMin", type: "uint256" }, - { internalType: "uint256", name: "amountBMin", type: "uint256" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - ], - name: "addLiquidity", - outputs: [ - { internalType: "uint256", name: "amountA", type: "uint256" }, - { internalType: "uint256", name: "amountB", type: "uint256" }, - { internalType: "uint256", name: "liquidity", type: "uint256" }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "token", type: "address" }, - { internalType: "uint256", name: "amountTokenDesired", type: "uint256" }, - { internalType: "uint256", name: "amountTokenMin", type: "uint256" }, - { internalType: "uint256", name: "amountETHMin", type: "uint256" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - ], - name: "addLiquidityETH", - outputs: [ - { internalType: "uint256", name: "amountToken", type: "uint256" }, - { internalType: "uint256", name: "amountETH", type: "uint256" }, - { internalType: "uint256", name: "liquidity", type: "uint256" }, - ], - stateMutability: "payable", - type: "function", - }, - { - inputs: [], - name: "factory", - outputs: [{ internalType: "address", name: "", type: "address" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "amountOut", type: "uint256" }, - { internalType: "uint256", name: "reserveIn", type: "uint256" }, - { internalType: "uint256", name: "reserveOut", type: "uint256" }, - ], - name: "getAmountIn", - outputs: [{ internalType: "uint256", name: "amountIn", type: "uint256" }], - stateMutability: "pure", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "amountIn", type: "uint256" }, - { internalType: "uint256", name: "reserveIn", type: "uint256" }, - { internalType: "uint256", name: "reserveOut", type: "uint256" }, - ], - name: "getAmountOut", - outputs: [{ internalType: "uint256", name: "amountOut", type: "uint256" }], - stateMutability: "pure", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "amountOut", type: "uint256" }, - { internalType: "address[]", name: "path", type: "address[]" }, - ], - name: "getAmountsIn", - outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "amountIn", type: "uint256" }, - { internalType: "address[]", name: "path", type: "address[]" }, - ], - name: "getAmountsOut", - outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "amountA", type: "uint256" }, - { internalType: "uint256", name: "reserveA", type: "uint256" }, - { internalType: "uint256", name: "reserveB", type: "uint256" }, - ], - name: "quote", - outputs: [{ internalType: "uint256", name: "amountB", type: "uint256" }], - stateMutability: "pure", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "tokenA", type: "address" }, - { internalType: "address", name: "tokenB", type: "address" }, - { internalType: "uint256", name: "liquidity", type: "uint256" }, - { internalType: "uint256", name: "amountAMin", type: "uint256" }, - { internalType: "uint256", name: "amountBMin", type: "uint256" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - ], - name: "removeLiquidity", - outputs: [ - { internalType: "uint256", name: "amountA", type: "uint256" }, - { internalType: "uint256", name: "amountB", type: "uint256" }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "token", type: "address" }, - { internalType: "uint256", name: "liquidity", type: "uint256" }, - { internalType: "uint256", name: "amountTokenMin", type: "uint256" }, - { internalType: "uint256", name: "amountETHMin", type: "uint256" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - ], - name: "removeLiquidityETH", - outputs: [ - { internalType: "uint256", name: "amountToken", type: "uint256" }, - { internalType: "uint256", name: "amountETH", type: "uint256" }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "token", type: "address" }, - { internalType: "uint256", name: "liquidity", type: "uint256" }, - { internalType: "uint256", name: "amountTokenMin", type: "uint256" }, - { internalType: "uint256", name: "amountETHMin", type: "uint256" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - ], - name: "removeLiquidityETHSupportingFeeOnTransferTokens", - outputs: [{ internalType: "uint256", name: "amountETH", type: "uint256" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "token", type: "address" }, - { internalType: "uint256", name: "liquidity", type: "uint256" }, - { internalType: "uint256", name: "amountTokenMin", type: "uint256" }, - { internalType: "uint256", name: "amountETHMin", type: "uint256" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - { internalType: "bool", name: "approveMax", type: "bool" }, - { internalType: "uint8", name: "v", type: "uint8" }, - { internalType: "bytes32", name: "r", type: "bytes32" }, - { internalType: "bytes32", name: "s", type: "bytes32" }, - ], - name: "removeLiquidityETHWithPermit", - outputs: [ - { internalType: "uint256", name: "amountToken", type: "uint256" }, - { internalType: "uint256", name: "amountETH", type: "uint256" }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "token", type: "address" }, - { internalType: "uint256", name: "liquidity", type: "uint256" }, - { internalType: "uint256", name: "amountTokenMin", type: "uint256" }, - { internalType: "uint256", name: "amountETHMin", type: "uint256" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - { internalType: "bool", name: "approveMax", type: "bool" }, - { internalType: "uint8", name: "v", type: "uint8" }, - { internalType: "bytes32", name: "r", type: "bytes32" }, - { internalType: "bytes32", name: "s", type: "bytes32" }, - ], - name: "removeLiquidityETHWithPermitSupportingFeeOnTransferTokens", - outputs: [{ internalType: "uint256", name: "amountETH", type: "uint256" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "tokenA", type: "address" }, - { internalType: "address", name: "tokenB", type: "address" }, - { internalType: "uint256", name: "liquidity", type: "uint256" }, - { internalType: "uint256", name: "amountAMin", type: "uint256" }, - { internalType: "uint256", name: "amountBMin", type: "uint256" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - { internalType: "bool", name: "approveMax", type: "bool" }, - { internalType: "uint8", name: "v", type: "uint8" }, - { internalType: "bytes32", name: "r", type: "bytes32" }, - { internalType: "bytes32", name: "s", type: "bytes32" }, - ], - name: "removeLiquidityWithPermit", - outputs: [ - { internalType: "uint256", name: "amountA", type: "uint256" }, - { internalType: "uint256", name: "amountB", type: "uint256" }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "amountOut", type: "uint256" }, - { internalType: "address[]", name: "path", type: "address[]" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - ], - name: "swapETHForExactTokens", - outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "amountOutMin", type: "uint256" }, - { internalType: "address[]", name: "path", type: "address[]" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - ], - name: "swapExactETHForTokens", - outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "amountOutMin", type: "uint256" }, - { internalType: "address[]", name: "path", type: "address[]" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - ], - name: "swapExactETHForTokensSupportingFeeOnTransferTokens", - outputs: [], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "amountIn", type: "uint256" }, - { internalType: "uint256", name: "amountOutMin", type: "uint256" }, - { internalType: "address[]", name: "path", type: "address[]" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - ], - name: "swapExactTokensForETH", - outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "amountIn", type: "uint256" }, - { internalType: "uint256", name: "amountOutMin", type: "uint256" }, - { internalType: "address[]", name: "path", type: "address[]" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - ], - name: "swapExactTokensForETHSupportingFeeOnTransferTokens", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "amountIn", type: "uint256" }, - { internalType: "uint256", name: "amountOutMin", type: "uint256" }, - { internalType: "address[]", name: "path", type: "address[]" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - ], - name: "swapExactTokensForTokens", - outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "amountIn", type: "uint256" }, - { internalType: "uint256", name: "amountOutMin", type: "uint256" }, - { internalType: "address[]", name: "path", type: "address[]" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - ], - name: "swapExactTokensForTokensSupportingFeeOnTransferTokens", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "amountOut", type: "uint256" }, - { internalType: "uint256", name: "amountInMax", type: "uint256" }, - { internalType: "address[]", name: "path", type: "address[]" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - ], - name: "swapTokensForExactETH", - outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "uint256", name: "amountOut", type: "uint256" }, - { internalType: "uint256", name: "amountInMax", type: "uint256" }, - { internalType: "address[]", name: "path", type: "address[]" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "deadline", type: "uint256" }, - ], - name: "swapTokensForExactTokens", - outputs: [{ internalType: "uint256[]", name: "amounts", type: "uint256[]" }], - stateMutability: "nonpayable", - type: "function", - }, - { stateMutability: "payable", type: "receive" }, -] as const diff --git a/src/app/beef/new/page.tsx b/src/app/beef/new/page.tsx index a085ec3..3633af9 100644 --- a/src/app/beef/new/page.tsx +++ b/src/app/beef/new/page.tsx @@ -31,6 +31,7 @@ import { useAddBeef } from "@/hooks/mutations" import { useBalance } from "@/hooks/queries" import { generateAddressForHandle } from "@/server/actions/generateAddressForHandle" import { ArbiterAccount, ChallengerAccount } from "@/types" +import { useTestChain } from "@/utils/chain" import { isValidEmail } from "@/utils/validations" const NUMBER_OF_ARBITERS = 3 @@ -84,7 +85,8 @@ const NewBeefPage = () => { type: ChallengerAccount.TWITTER, value: "", }, - staking: true, + // Disable staking on testnet, since it doesn't support uniswap V3 + staking: !useTestChain, }, }) @@ -438,7 +440,7 @@ const NewBeefPage = () => { render={({ field }) => ( } + control={} label={ Let the beef drip! @@ -449,7 +451,7 @@ const NewBeefPage = () => { - Your and your challenger's ETH will be swapped to Liquid Staking Derivative token + Your and your challenger's ETH will be swapped to the Liquid Staking Derivative token wstETH for the duration of the beef, earning ETH staking yield paid out to the winner when the beef is served ðŸ“ˆ diff --git a/src/components/providers/Providers.tsx b/src/components/providers/Providers.tsx index 1098cb8..2e90456 100644 --- a/src/components/providers/Providers.tsx +++ b/src/components/providers/Providers.tsx @@ -31,6 +31,7 @@ export const wagmiConfig = createConfig({ [base.id]: http(alchemyApiUrl), [baseSepolia.id]: http(alchemyApiUrl), }, + ssr: true, }) export const ensConfig = createConfig({ diff --git a/src/constants.ts b/src/constants.ts index 42cf822..bc714cc 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -6,7 +6,7 @@ type ChainAddressMap = Record const slaughterhouseAddresses: ChainAddressMap = { [baseSepolia.id]: "0x680C811Af29ab31d79e5eDb1b81A862fCF7d28DD", - [base.id]: "0xCBe8eC1e650f1B0eECC264B5B6E4127c18bC1D6C", + [base.id]: "0x18ec7cEEA296E94c601eCb44b222a854C4FfC0b2", } const wethAddresses: ChainAddressMap = { @@ -24,10 +24,18 @@ const uniswapRouterAddresses: ChainAddressMap = { [base.id]: "0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24", } +const uniswapQuoterV2Addresses: ChainAddressMap = { + [baseSepolia.id]: "0x0", + [base.id]: "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a", +} + export const SLAUGHTERHOUSE_ADDRESS = slaughterhouseAddresses[activeChain.id] export const WETH_ADDRESS = wethAddresses[activeChain.id] export const WSTETH_ADDRESS = wsethAddresses[activeChain.id] export const UNISWAP_ROUTER_ADDRESS = uniswapRouterAddresses[activeChain.id] +export const QUOTER_ADDRESS = uniswapQuoterV2Addresses[activeChain.id] + +export const STAKING_POOL_FEE = 100 export const LIGHT_ACCOUNT_FACTORY_ADDRESS = "0x00004EC70002a32400f8ae005A26081065620D20" diff --git a/src/hooks/mutations.ts b/src/hooks/mutations.ts index b583c65..351f1b8 100644 --- a/src/hooks/mutations.ts +++ b/src/hooks/mutations.ts @@ -1,14 +1,14 @@ import { useContext } from "react" import { useMutation, useQueryClient } from "@tanstack/react-query" import { Address, encodeFunctionData, erc20Abi, formatEther, isAddress } from "viem" -import { readContract, readContracts } from "wagmi/actions" +import { readContracts } from "wagmi/actions" import { beefAbi } from "@/abi/beef" +import { quoterAbi } from "@/abi/quoterAbi" import { slaughterhouseAbi } from "@/abi/slaughterhouse" -import { uniswapV2RouterAbi } from "@/abi/uniswapV2Router" import { NewBeefFormValues } from "@/app/beef/new/page" import { wagmiConfig } from "@/components/providers/Providers" import { SmartAccountClientContext } from "@/components/providers/SmartAccountClientContext" -import { SLAUGHTERHOUSE_ADDRESS, UNISWAP_ROUTER_ADDRESS, WETH_ADDRESS, WSTETH_ADDRESS } from "@/constants" +import { QUOTER_ADDRESS, SLAUGHTERHOUSE_ADDRESS, STAKING_POOL_FEE, WETH_ADDRESS, WSTETH_ADDRESS } from "@/constants" import { useBalance } from "@/hooks/queries" import { BeefApi } from "@/server/actions/beef/beefApi" import { generateAddressForEmail } from "@/server/actions/generateAddressForEmail" @@ -96,16 +96,7 @@ export const useJoinBeef = (beefId: Address) => { throw new Error(`Not enough funds to join beef! ${formatEther(wager)} ETH needed!`) } - const amountOut = staking - ? ( - await readContract(wagmiConfig, { - address: UNISWAP_ROUTER_ADDRESS, - abi: uniswapV2RouterAbi, - functionName: "getAmountsOut", - args: [wager, [WETH_ADDRESS, WSTETH_ADDRESS]], - }) - )[1]! - : BigInt(0) + const amountOut = staking ? await getAmountOut(wager, WETH_ADDRESS, WSTETH_ADDRESS) : 0n const { transactionHash } = await sendTransaction({ to: beefId, @@ -113,7 +104,7 @@ export const useJoinBeef = (beefId: Address) => { data: encodeFunctionData({ abi: beefAbi, functionName: "joinBeef", - args: [subtractSlippage(amountOut)], + args: [amountOut], }), }) @@ -172,16 +163,7 @@ export const useAddBeef = () => { const arbitersAddresses = await Promise.all(addressPromises) - const amountOut = staking - ? ( - await readContract(wagmiConfig, { - address: UNISWAP_ROUTER_ADDRESS, - abi: uniswapV2RouterAbi, - functionName: "getAmountsOut", - args: [wager, [WETH_ADDRESS, WSTETH_ADDRESS]], - }) - )[1]! - : BigInt(0) + const amountOut = staking ? await getAmountOut(wager, WETH_ADDRESS, WSTETH_ADDRESS) : 0n const { blockHash, transactionHash } = await sendTransaction({ to: SLAUGHTERHOUSE_ADDRESS, @@ -201,7 +183,7 @@ export const useAddBeef = () => { arbiters: arbitersAddresses, staking, }, - subtractSlippage(amountOut), + amountOut, ], }), }) @@ -250,18 +232,9 @@ const getWithdrawAmountOut = async (beefAddress: Address) => { ], }) - const amountOut = staking - ? ( - await readContract(wagmiConfig, { - address: UNISWAP_ROUTER_ADDRESS, - abi: uniswapV2RouterAbi, - functionName: "getAmountsOut", - args: [wstEthBalance, [WSTETH_ADDRESS, WETH_ADDRESS]], - }) - )[1]! - : BigInt(0) - - return subtractSlippage(amountOut) + const amountOut = staking ? await getAmountOut(wstEthBalance, WSTETH_ADDRESS, WETH_ADDRESS) : 0n + + return amountOut } export const useWithdrawBeef = (beefId: Address, withdrawType: "withdrawRaw" | "withdrawRotten" | "serveBeef") => { @@ -293,3 +266,22 @@ export const useWithdrawBeef = (beefId: Address, withdrawType: "withdrawRaw" | " }, }) } + +const getAmountOut = async (amountIn: bigint, tokenIn: Address, tokenOut: Address) => { + const { result } = await publicClient.simulateContract({ + address: QUOTER_ADDRESS, + abi: quoterAbi, + functionName: "quoteExactInputSingle", + args: [ + { + tokenIn, + tokenOut, + fee: STAKING_POOL_FEE, + amountIn, + sqrtPriceLimitX96: 0n, + }, + ], + }) + + return subtractSlippage(result[0]) +} diff --git a/src/utils/chain.ts b/src/utils/chain.ts index 60dde73..113b24c 100644 --- a/src/utils/chain.ts +++ b/src/utils/chain.ts @@ -2,7 +2,7 @@ import { base as baseAlchemy, baseSepolia as baseSepoliaAlchemy } from "@alchemy import { createPublicClient, http } from "viem" import { base, baseSepolia } from "viem/chains" -const useTestChain = process.env.NEXT_PUBLIC_USE_TEST_CHAIN === "true" +export const useTestChain = process.env.NEXT_PUBLIC_USE_TEST_CHAIN === "true" const alchemyKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY ?? "" const baseApiKey = process.env.NEXT_PUBLIC_BASE_API_KEY ?? "" @@ -19,5 +19,6 @@ export const baseApiUrl = useTestChain : `https://api.developer.coinbase.com/rpc/v1/base/${baseApiKey}` export const publicClient = createPublicClient({ + chain: activeChain, transport: http(alchemyApiUrl), })