// SPDX-License-Identifier: MIT
/*
_________ ______ ______ ___ __ ______ ___ ___
/________/\/_____/\ /_____/\ /__/\ /__/\ /_____/\ /__/\ /__/\
\__.::.__\/\:::_ \ \ \::::_\/_\::\_\\ \ \\:::__\/ \::\ \\ \ \
\::\ \ \:(_) ) )_\:\/___/\\:. `-\ \ \\:\ \ __\::\/_\ .\ \
\::\ \ \: __ `\ \\::___\/_\:. _ \ \\:\ \/_/\\:: ___::\ \
\::\ \ \ \ `\ \ \\:\____/\\. \`-\ \ \\:\_\ \ \\: \ \\::\ \
\__\/ \_\/ \_\/ \_____\/ \__\/ \__\/ \_____\/ \__\/ \::\/
______ ________ _______ _______ ______ ______
/_____/\ /_______/\/______/\ /______/\ /_____/\ /_____/\
\:::_ \ \ \__.::._\/\::::__\/__\::::__\/__\::::_\/_\:::_ \ \
\:\ \ \ \ \::\ \ \:\ /____/\\:\ /____/\\:\/___/\\:(_) ) )_
\:\ \ \ \ _\::\ \__\:\\_ _\/ \:\\_ _\/ \::___\/_\: __ `\ \
\:\/.:| |/__\::\__/\\:\_\ \ \ \:\_\ \ \ \:\____/\\ \ `\ \ \
\____/_/\________\/ \_____\/ \_____\/ \_____\/ \_\/ \_\/
TG: https://t.me/trenchdiggereth
X: https://x.com/i/communities/1939432261595636176
Yo Degens,
Welcome to TrenchDigger, a permissionless arena for behavioral liquidity
where bullPosts roar and FUDs lurk in the trenches.
In TrenchDigger, the entrenched sentiment of any $TOKEN can be determined by analysing its bullPosts and FUDs.
Your position is called a Dwelling which is also tradable.
A dwelling - Bull or Bear - is locked for a set duration and liquidated at the end of that duration.
Express bullish conviction by BullPosting (trading $TRENCH for $TOKEN) or
bearish stance by Creating FUD (trading $TOKEN for $TRENCH).
BullShit to fud a BullPost or BuryFUD to counter FUD.
How to dig $TRENCH:
- Use Etherscan, DIY scripts, or the dApp, whatever suits your degen style
- Ensure $TOKEN is NOT a honeypot, Uniswap doesn't care, neither do I
- Make sure the $TRENCH <-> $TOKEN prices make sense
- Approve $TRENCH CA to spend $TRENCH/$TOKEN
- Entrench as a bull or bear in a Dwelling using BullPost, BullShit, CreateFUD, BuryFUD
- BullPost on $TOKEN by sending x $TRENCH for y $TOKEN for duration of 1hr/6hrs/12hrs/24hrs/7days/15days/30days
BullShit on the BullPost by sending y $TOKEN for x $TRENCH within the duration
- CreateFUD on $TOKEN by sending p $TOKEN for q $TRENCH for duration of 1hr/6hrs/12hrs/24hrs/7days/15days/30days
BuryFUD on $TOKEN by sending q $TRENCH for p $TOKEN within the duration
- Set selling price for your Dwelling and trade Dwellings using $TRENCH
- Withdraw your $TRENCH or $TOKEN after the duration ends
- There is no fee, just pay gas
Example:
- Sensai is bullish on $PEPE
- current $TRENCH <-> $PEPE happens to be 1:1
- Sensai bullPosts "to the moon" with 10 $TRENCH for 9 $PEPE for a duration lock of 24hrs,
entrenches a new dwelling with id 1 as the bull
- Becker calls bullShit "to the dump" on Sensai's bullPost and transfers 9 $PEPE,
enters dwelling 1 as the bear
- $PEPE price shoots and current $TRENCH <-> $PEPE happens to be 3:1
- Sensai needs a quick exit and sets the price of his dwelling as 15 $TRENCH
- Shark is also bullish on $PEPE and buys dwelling 1 as the bull replacing Sensai,
transferring 15 $TRENCH to Sensai
- 24 hrs are over and $PEPE is still holding 3:1
- position is liquidated with Shark receiving 9 $PEPE and Becker receiving 10 $TRENCH
- Shark swaps 9 $PEPE for 25 $TRENCH on dex, profits of 10 $TRENCH
$TRENCH-nomics:
Supply: 1000000 $TRENCH
Launch Market Cap ~ 5000 USD, Ratio of 1 $ETH to 1000000 $TRENCH with 100% supply in uni-v3 lp
Wallet Limits - 1% of supply, increased gradually.
Liquidity pool position mint NFT is PERMA-LOCKED into this contract.
$TRENCH is DEFLATIONARY in nature, 1% LP fees in $TRENCH is burnt on-chain.
$TRENCH-map:
Trench web app will be deployed on IPFS, hash will be updated and announced on-chain
Leaderboard for most profitable dwellings and top diggers
TrenchDigger TG bot & X agent: share on-chain bullPosts and Leaderboards
devs are welcome to build more dApps, bots, tools, scripts, subgraphs on $TRENCH
AI Agents can learn to dig $TRENCH and trade dwellings as a test for intelligent belligerence
Contract will NOT be renounced.
Read emitted contract events for announcements and navigation through the trenches.
Yours truly,
dev
Telegram : https://t.me/trenchdiggereth
Twitter : https://x.com/i/communities/1939432261595636176
P.S. I will never DM you.
*/
pragma solidity ^0.8.25;
interface IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address _owner) external view returns (uint256 balance);
function transferFrom(
address _from,
address _to,
uint256 _value
) external returns (bool success);
function transfer(address _to, uint256 _value) external returns (bool success);
function approve(address _spender, uint256 _value) external returns (bool success);
function allowance(address _owner, address _spender) external view returns (uint256 remaining);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed ownerAddress, address indexed spender, uint256 value);
}
interface INonfungiblePositionManager {
struct CollectParams {
uint256 tokenId;
address recipient;
uint128 amount0Max;
uint128 amount1Max;
}
function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);
function positions(uint256 tokenId)
external
view
returns (
uint96 nonce,
address operator,
address token0,
address token1,
uint24 fee,
int24 tickLower,
int24 tickUpper,
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
struct MintParams {
address token0;
address token1;
uint24 fee;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
address recipient;
uint256 deadline;
}
function createAndInitializePoolIfNecessary(
address token0,
address token1,
uint24 fee,
uint160 sqrtPriceX96
) external payable returns (address pool);
function mint(MintParams calldata params)
external
payable
returns (
uint256 tokenId,
uint128 liquidity,
uint256 amount0,
uint256 amount1
);
function factory() external pure returns (address);
function WETH9() external pure returns (address);
}
interface IUniswapV3Factory {
/// @return pool The address of the newly created pool
function createPool(
address tokenA,
address tokenB,
uint24 fee
) external returns (address pool);
}
interface IUniswapV3Pool {
function initialize(uint160 sqrtPriceX96) external;
}
/// @title TrenchDigger
/// @dev contains ERC20 methods along with TrenchDigger extension
contract TrenchDigger is IERC20 {
mapping (address => uint256) balances_;
mapping (address => mapping (address => uint256)) allowances_;
mapping(address => bool) isExempted_;
mapping (uint256 => Entrench) dwellings_;
uint256 nextDwelling_;
address owner_;
address spawner_;
bool tradingEnabled_;
uint256 tradingEnabledTs_;
uint8 decimals_;
uint256 supply_;
string name_;
string symbol_;
uint256 maxWallet_;
uint256 maxTx_;
bool walletLtd_;
INonfungiblePositionManager positionManager_;
address uniswapV3Pool_;
uint256 lpNFTId_;
bool isEntered_;
event StartedDigging(address pair, uint256 liq, address router);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event IncreasedLimits(uint256 maxWallet_, uint256 maxTx);
event BullPost(uint256 id, address token, Entrench entrench, string message, uint256 price);
event CreateFud(uint256 id, address token, Entrench entrench, string message, uint256 price);
event BullShit(uint256 id, address token, string message, uint256 price);
event BuryFud(uint256 id, address token, string message, uint256 price);
event Announcement(string message);
event SocialsRequest(string twitter, string telegram, string message);
event BullChanged(uint256 id, address oldBull, address newBull, uint256 price);
event BearChanged(uint256 id, address oldBear, address newBear, uint256 price);
event Withdrawn(uint256 id);
event BullPriceChanged(uint256 id, uint256 price);
event BearPriceChanged(uint256 id, uint256 price);
struct Initializer {
address owner;
uint256 maxWallet;
uint256 maxTx;
}
struct Entrench {
address token;
address bull;
address bear;
uint256 amount;
uint256 cost;
uint256 duration;
uint256 createTs;
uint256 status;
uint256 bullPrice;
uint256 bearPrice;
bool isBull;
}
//reentrancy lock
modifier lockTheEntry {
isEntered_ = true;
_;
isEntered_ = false;
}
/// @notice Constructor
constructor(Initializer memory params) {
spawner_ = msg.sender;
owner_ = payable(params.owner);
decimals_ = 18;
name_ = "TrenchDigger";
symbol_ = "TRENCH";
supply_ = 1000000 * 10**decimals_;
walletLtd_ = true;
maxWallet_ = supply_ * params.maxWallet / 10000;
maxTx_ = supply_ * params.maxTx / 10000;
if (params.maxWallet == 10000 && params.maxTx == 10000) {
walletLtd_ = false;
}
isExempted_[address(this)] = true;
isExempted_[address(owner_)] = true;
isExempted_[address(spawner_)] = true;
isExempted_[address(0x000000000000000000000000000000000000dEaD)] = true;
balances_[address(this)] = supply_;
emit OwnershipTransferred(address(0), owner_);
emit IncreasedLimits(params.maxWallet, params.maxTx);
emit Transfer(address(0), address(this), supply_);
}
/// @notice Create liquidity pool
/// @dev
function startDigging(address pmgr, uint160 sqrtPriceX96, INonfungiblePositionManager.MintParams memory params) external {
require(msg.sender == owner_ || msg.sender == spawner_);
require(!tradingEnabled_);
tradingEnabled_ = true;
tradingEnabledTs_ = block.timestamp;
uint256 maxTxTemp = maxTx_;
uint256 maxWalletTemp = maxWallet_;
bool walletLtdTemp = walletLtd_;
if(walletLtd_ == true) {
maxTx_ = supply_;
maxWallet_ = supply_;
walletLtd_ = false;
}
positionManager_ = INonfungiblePositionManager(pmgr);
isExempted_[address(positionManager_)] = true;
allowances_[address(this)][address(positionManager_)] = supply_;
require(sqrtPriceX96 >= 0, "sq");
require(params.token0 != params.token1);
require(params.token1 == address(this) || params.token0 == address(this),"s2");
if(params.token1 == address(this)) {
require(params.amount1Desired == supply_,"s6");
} else {
require(params.amount0Desired == supply_,"s6");
}
uniswapV3Pool_ = positionManager_.createAndInitializePoolIfNecessary(params.token0, params.token1, params.fee, sqrtPriceX96);
isExempted_[address(uniswapV3Pool_)] = true;
(lpNFTId_,,,) = positionManager_.mint(params);
emit StartedDigging(uniswapV3Pool_, address(this).balance, address(positionManager_));
if(walletLtdTemp == true) {
maxTx_ = maxTxTemp;
maxWallet_ = maxWalletTemp;
walletLtd_ = true;
}
}
///@dev Increases wallet and tx limits
function increaseLimits(uint256 _maxwallet, uint256 _maxtx) external {
require(msg.sender == owner_ && walletLtd_);
require(supply_ * _maxwallet / 10000 >= maxWallet_ && _maxwallet <= 10000, "a");
require(supply_ * _maxtx / 10000 >= maxTx_ && _maxtx <= 10000, "b");
maxWallet_ = supply_ * _maxwallet / 10000;
maxTx_ = supply_ * _maxtx / 10000;
if (_maxwallet == 10000 && _maxtx == 10000) {
walletLtd_ = false;
}
emit IncreasedLimits(_maxwallet, _maxtx);
}
///@dev Returns the name of the token.
function name() external view override returns (string memory) {
return name_;
}
///@dev Returns the symbol of the token, usually a shorter version of name.
function symbol() external view override returns (string memory) {
return symbol_;
}
///@dev Returns the number of decimals used to get its user representation.
function decimals() external view override returns (uint8) {
return decimals_;
}
///@dev Returns the value of tokens in existence.
function totalSupply() public view override returns (uint256) {
return supply_;
}
///@dev Returns the value of tokens owned by account.
function balanceOf(address _account) public view override returns (uint256) {
return balances_[_account];
}
///@dev Moves a amount of tokens from the caller's account to receipient.
function transfer(address _recipient, uint256 _amount) external override returns (bool) {
_transfer(msg.sender, _recipient, _amount);
return true;
}
///@dev Returns the remaining number of tokens that `spender` will be
// allowed to spend on behalf of `owner` through {transferFrom}. This is
// zero by default
function allowance(address _owner, address _spender) external view override returns (uint256) {
return allowances_[_owner][_spender];
}
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's token
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address _spender, uint256 _amount) external override returns (bool) {
_approve(msg.sender, _spender, _amount);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address _sender, address _recipient, uint256 _amount) public override returns (bool) {
require(_amount <= allowances_[_sender][msg.sender], "25");
_approve(_sender, msg.sender,allowances_[_sender][msg.sender] - _amount);
_transfer(_sender, _recipient, _amount);
return true;
}
function _approve(address _owner, address _spender, uint256 _amount) private {
require(_owner != address(0));
require(_spender != address(0));
allowances_[_owner][_spender] = _amount;
emit Approval(_owner, _spender, _amount);
}
/// @notice ERC20 transfer
/// @dev
function _transfer(address _from, address _to, uint256 _amount) private {
require(_from != address(0) && _to != address(0));
require(balances_[_from] >= _amount, "ba");
if (tradingEnabled_ && walletLtd_ && !isExempted_[_from] && !isExempted_[_to]) {
require(maxTx_ >= _amount, "mt");
}
if (tradingEnabled_ && walletLtd_ && !isExempted_[_to]) {
require((balances_[_to] + _amount) <= maxWallet_, "mw");
}
balances_[_from] = balances_[_from] - _amount;
balances_[_to] = balances_[_to] + _amount;
emit Transfer(_from, _to, _amount);
}
/// @notice recovers eth
/// @dev
function recoverEth() external lockTheEntry {
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
(bool ret, ) = owner_.call{value: address(this).balance}("");
}
}
/// @notice Set the address of the new owner of the contract
/// @param _newOwner The address of the new owner of the contract
function transferOwnership(address _newOwner) external {
require(msg.sender == owner_);
emit OwnershipTransferred(owner_, _newOwner);
owner_ = _newOwner;
}
/// @notice Get the address of the owner
/// @return The address of the owner.
function owner() public view returns (address) {
return owner_;
}
/// @notice Claim LP Rewards and Burn $TRENCH
/// @dev
function claimLPRewards() external lockTheEntry {
require(tradingEnabledTs_ > 0, "tc");
(uint256 amount0, uint256 amount1) = positionManager_.collect(
INonfungiblePositionManager.CollectParams({
tokenId: lpNFTId_,
recipient: address(this),
amount0Max: type(uint128).max,
amount1Max: type(uint128).max
})
);
(,, address token0, address token1,,,,,,,,) = positionManager_.positions(lpNFTId_);
if(token0 == address(this)) {
if(amount0 > 0)
require(IERC20(address(this)).transfer(address(0x000000000000000000000000000000000000dEaD), amount0),"cr1");
if(amount1 > 0)
require(IERC20(token1).transfer(owner_, amount1),"cr2");
} else {
if(amount1 > 0)
require(IERC20(address(this)).transfer(address(0x000000000000000000000000000000000000dEaD), amount1),"cr3");
if(amount0 > 0)
require(IERC20(token0).transfer(owner_, amount0),"cr4");
}
}
/// @notice Dev Announcements
/// @dev check emitted events
function announce(string calldata _announcement) external {
require(msg.sender == owner_);
emit Announcement(_announcement);
}
/// @notice bullPost create a locked position with $trench for any $token
/// @dev requires approval for $trench ca to spend $trench on your behalf
/// @param _token address of any $token
/// @param _amount $trench to be transferred to this contract in wei
/// @param _cost $token required to be transferred by bear to this contract in wei
/// @param _duration in seconds
/// @param _price price of bull dwelling in $trench, 0 if you dont wish to sell
/// @param _message bull post
function bullPost(address _token, uint256 _amount, uint256 _cost, uint256 _duration, uint256 _price, string calldata _message) external lockTheEntry {
//am ready to buy _amount $token using _cost $trench for _duration seconds
require(tradingEnabledTs_ > 0, "bp1");
require(_duration == 1 hours || _duration == 6 hours || _duration == 12 hours || _duration == 24 hours || _duration == 7 days || _duration == 15 days || _duration == 30 days, "bp2");
require(IERC20(address(this)).transferFrom(msg.sender, address(this), _amount), "bp3");
nextDwelling_ += 1;
dwellings_[nextDwelling_] = Entrench(_token, msg.sender, address(0), _amount, _cost, _duration, block.timestamp, 1, _price, 0, true);
emit BullPost(nextDwelling_, _token, dwellings_[nextDwelling_], _message, _price);
}
/// @notice bullShit on any bullpost by entering locked position with $token
/// @dev requires approval for $trench ca to spend $token on your behalf
/// @param _id id of the dwelling
/// @param _price price of bear dwelling in $trench, 0 if you dont wish to sell
/// @param _message bullshit
function bullShit(uint256 _id, uint256 _price, string calldata _message) external lockTheEntry {
//status=0-none,1-active,2-sold,3-claimed
require(tradingEnabledTs_ > 0, "bs1");
require(dwellings_[_id].bull != msg.sender && dwellings_[_id].bear != msg.sender, "bs2");
require(dwellings_[_id].status == 1 && dwellings_[_id].isBull == true, "bs3");
require(block.timestamp - dwellings_[_id].createTs < dwellings_[_id].duration, "bs4");
require(IERC20(dwellings_[_id].token).transferFrom(msg.sender, address(this), dwellings_[_id].cost), "bs5");
dwellings_[_id].status = 2;
dwellings_[_id].bear = msg.sender;
dwellings_[_id].bearPrice = _price;
emit BullShit(_id, dwellings_[_id].token, _message, _price);
}
/// @notice createFud create a locked position(dwelling) with any $token for $trench
/// @dev requires approval for $trench ca to spend $token on your behalf
/// @param _token address of any $token
/// @param _amount $token in wei transferred into this contract
/// @param _cost $trench in wei to be transferred by bull
/// @param _duration in seconds
/// @param _price price of the created bear dwelling in $trench, 0 if you dont wish to sell
/// @param _message FUD
function createFUD(address _token, uint256 _amount, uint256 _cost, uint256 _duration, uint256 _price, string calldata _message) external lockTheEntry {
require(tradingEnabledTs_ > 0, "cf1");
require(_duration == 1 hours || _duration == 6 hours || _duration == 12 hours || _duration == 24 hours || _duration == 7 days || _duration == 15 days || _duration == 30 days, "cf2");
require(IERC20(_token).transferFrom(msg.sender, address(this), _amount), "cf3");
nextDwelling_ += 1;
dwellings_[nextDwelling_] = Entrench(_token, address(0), msg.sender, _amount, _cost, _duration, block.timestamp, 1, 0, _price, false);
emit CreateFud(nextDwelling_, _token, dwellings_[nextDwelling_], _message, _price);
}
/// @notice bury a FUD by entering a locked position with $trench for $token
/// @dev requires approval for $trench ca to spend $trench on your behalf
/// @param _id id of the dwelling
/// @param _price price of bull dwelling in $trench, 0 if you dont wish to sell
/// @param _message bullish message
function buryFUD(uint256 _id, uint256 _price, string calldata _message) external lockTheEntry {
require(tradingEnabledTs_ > 0, "bf1");
require(dwellings_[_id].bear != msg.sender && dwellings_[_id].bull != msg.sender, "bf2");
require(dwellings_[_id].status == 1, "bzf3");
require(!dwellings_[_id].isBull, "bf4z");
require(block.timestamp - dwellings_[_id].createTs < dwellings_[_id].duration, "bf4");
require(IERC20(address(this)).transferFrom(msg.sender, address(this), dwellings_[_id].cost), "bf5");
dwellings_[_id].status = 2;
dwellings_[_id].bull = msg.sender;
dwellings_[_id].bullPrice = _price;
emit BuryFud(_id, dwellings_[_id].token, _message, _price);
}
/// @notice withdraw $trench or $token after end of lock duration
/// @dev pass appropriate id
/// @param _id id of the dwelling
function withdraw(uint256 _id) external lockTheEntry {
require(tradingEnabledTs_ > 0, "w1");
require(block.timestamp - dwellings_[_id].createTs >= dwellings_[_id].duration, "w2");
require(dwellings_[_id].status > 0 && dwellings_[_id].status < 3, "w3");
if(dwellings_[_id].status == 1) {
if(dwellings_[_id].isBull == true) {
require(IERC20(address(this)).transfer(dwellings_[_id].bull, dwellings_[_id].amount), "w4");
} else {
require(IERC20(dwellings_[_id].token).transfer(dwellings_[_id].bear, dwellings_[_id].amount), "w5");
}
} else {
if(dwellings_[_id].isBull == true) {
require(IERC20(address(this)).transfer(dwellings_[_id].bear, dwellings_[_id].amount), "w6");
require(IERC20(dwellings_[_id].token).transfer(dwellings_[_id].bull, dwellings_[_id].cost), "w7");
} else {
require(IERC20(address(this)).transfer(dwellings_[_id].bear, dwellings_[_id].cost), "w8");
require(IERC20(dwellings_[_id].token).transfer(dwellings_[_id].bull, dwellings_[_id].amount), "w9");
}
}
dwellings_[_id].status = 3;
emit Withdrawn(_id);
}
/// @notice get the details of a bullPost or createdFud
/// @dev pass appropriate id
/// @param _id id of the dwelling
function getDwelling(uint256 _id) external view returns (Entrench memory) {
return dwellings_[_id];
}
/// @notice set the selling price for your dwelling
/// @dev pass appropriate id and new price
/// @param _id id of the dwelling
/// @param _price new price, 0 if you dont wish to sell
function setDwellingPrice(uint256 _id, uint256 _price) external lockTheEntry {
require(dwellings_[_id].status > 0 && dwellings_[_id].status < 3, "sd1");
require(block.timestamp - dwellings_[_id].createTs < dwellings_[_id].duration, "sd2");
if(msg.sender == dwellings_[_id].bull) {
dwellings_[_id].bullPrice = _price;
emit BullPriceChanged(_id, _price);
} else if (msg.sender == dwellings_[_id].bear) {
dwellings_[_id].bearPrice = _price;
emit BearPriceChanged(_id, _price);
}
}
/// @notice buy dwelling, requires allowance for $trench ca to spend on your behalf
/// @dev pass appropriate id, isBull or not and new price
/// @param _id id of the dwelling
/// @param _isBull true to be the bull, false to be the bear
/// @param _newPrice price after the buy, 0 if you dont wish to sell
function buyDwelling(uint256 _id, bool _isBull, uint256 _newPrice) external lockTheEntry {
require(dwellings_[_id].status > 0 && dwellings_[_id].status < 3, "bd1");
require(block.timestamp - dwellings_[_id].createTs < dwellings_[_id].duration, "bd2");
if(_isBull == true) {
require(dwellings_[_id].bullPrice > 0, "bd3");
require(dwellings_[_id].bull != msg.sender && dwellings_[_id].bear != msg.sender , "bd4");
require(IERC20(address(this)).transferFrom(msg.sender, dwellings_[_id].bull, dwellings_[_id].bullPrice), "bd5");
emit BullChanged(_id, dwellings_[_id].bull, msg.sender, _newPrice);
dwellings_[_id].bull = msg.sender;
dwellings_[_id].bullPrice = _newPrice;
} else {
require(dwellings_[_id].bearPrice > 0, "bd6");
require(dwellings_[_id].bull != msg.sender && dwellings_[_id].bear != msg.sender, "bd7");
require(IERC20(address(this)).transferFrom(msg.sender, dwellings_[_id].bear, dwellings_[_id].bearPrice), "bd8");
emit BearChanged(_id, dwellings_[_id].bear, msg.sender, _newPrice);
dwellings_[_id].bear = msg.sender;
dwellings_[_id].bearPrice = _newPrice;
}
}
/// @notice receive eth
receive() external payable {}
}
{
"compilationTarget": {
"contracts/utils/TrenchDigger.sol": "TrenchDigger"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 800
},
"remappings": []
}
[{"inputs":[{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"maxWallet","type":"uint256"},{"internalType":"uint256","name":"maxTx","type":"uint256"}],"internalType":"struct TrenchDigger.Initializer","name":"params","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"message","type":"string"}],"name":"Announcement","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"ownerAddress","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":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"address","name":"oldBear","type":"address"},{"indexed":false,"internalType":"address","name":"newBear","type":"address"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"BearChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"BearPriceChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"address","name":"oldBull","type":"address"},{"indexed":false,"internalType":"address","name":"newBull","type":"address"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"BullChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"bull","type":"address"},{"internalType":"address","name":"bear","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"cost","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"createTs","type":"uint256"},{"internalType":"uint256","name":"status","type":"uint256"},{"internalType":"uint256","name":"bullPrice","type":"uint256"},{"internalType":"uint256","name":"bearPrice","type":"uint256"},{"internalType":"bool","name":"isBull","type":"bool"}],"indexed":false,"internalType":"struct TrenchDigger.Entrench","name":"entrench","type":"tuple"},{"indexed":false,"internalType":"string","name":"message","type":"string"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"BullPost","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"BullPriceChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"string","name":"message","type":"string"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"BullShit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"string","name":"message","type":"string"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"BuryFud","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"bull","type":"address"},{"internalType":"address","name":"bear","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"cost","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"createTs","type":"uint256"},{"internalType":"uint256","name":"status","type":"uint256"},{"internalType":"uint256","name":"bullPrice","type":"uint256"},{"internalType":"uint256","name":"bearPrice","type":"uint256"},{"internalType":"bool","name":"isBull","type":"bool"}],"indexed":false,"internalType":"struct TrenchDigger.Entrench","name":"entrench","type":"tuple"},{"indexed":false,"internalType":"string","name":"message","type":"string"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"CreateFud","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxWallet_","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxTx","type":"uint256"}],"name":"IncreasedLimits","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"twitter","type":"string"},{"indexed":false,"internalType":"string","name":"telegram","type":"string"},{"indexed":false,"internalType":"string","name":"message","type":"string"}],"name":"SocialsRequest","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pair","type":"address"},{"indexed":false,"internalType":"uint256","name":"liq","type":"uint256"},{"indexed":false,"internalType":"address","name":"router","type":"address"}],"name":"StartedDigging","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_announcement","type":"string"}],"name":"announce","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_cost","type":"uint256"},{"internalType":"uint256","name":"_duration","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"string","name":"_message","type":"string"}],"name":"bullPost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"string","name":"_message","type":"string"}],"name":"bullShit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"string","name":"_message","type":"string"}],"name":"buryFUD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"bool","name":"_isBull","type":"bool"},{"internalType":"uint256","name":"_newPrice","type":"uint256"}],"name":"buyDwelling","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimLPRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_cost","type":"uint256"},{"internalType":"uint256","name":"_duration","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"string","name":"_message","type":"string"}],"name":"createFUD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"getDwelling","outputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"bull","type":"address"},{"internalType":"address","name":"bear","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"cost","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"createTs","type":"uint256"},{"internalType":"uint256","name":"status","type":"uint256"},{"internalType":"uint256","name":"bullPrice","type":"uint256"},{"internalType":"uint256","name":"bearPrice","type":"uint256"},{"internalType":"bool","name":"isBull","type":"bool"}],"internalType":"struct TrenchDigger.Entrench","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxwallet","type":"uint256"},{"internalType":"uint256","name":"_maxtx","type":"uint256"}],"name":"increaseLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"recoverEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"setDwellingPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pmgr","type":"address"},{"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"},{"components":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"uint256","name":"amount0Desired","type":"uint256"},{"internalType":"uint256","name":"amount1Desired","type":"uint256"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct INonfungiblePositionManager.MintParams","name":"params","type":"tuple"}],"name":"startDigging","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_sender","type":"address"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]