Address Contract Verified
Address
0x8E2FF92834C75D3132ad5CED6482E660822f5EF6
Balance
0 ETH
Nonce
1
Code Size
1168 bytes
Creator
0xdadf0000...689c at tx 0x50592ab6...5b8f78
Indexed Transactions
0
Contract Bytecode
1168 bytes
0x60806040526004361015610015575b3661043257005b5f3560e01c80630900f0101461007457806341c20c8e1461006f5780635c60da1b1461006a57806367fc913814610065578063c6d8954c146100605763df2e50660361000e576102e6565b6102a2565b6101d5565b6101ae565b61018c565b34610188576020366003190112610188576004356001600160a01b038116810361018857635f35b0b360e01b6080908152336084526020906024816001600160a01b037f000000000000000000000000441d5687245ee9e7388c51159770736fb142ea9c165afa8015610183575f9061014d575b600160fc1b16156100f8565b1590565b8015610138575b610124575f80546001600160a01b0319166001600160a01b039092169190911790555b005b63d1b5191160e01b5f52600160045260245ffd5b506101486100f460025460ff1690565b6100ff565b5060203d60201161017c575b6100f46101748261016c6100f8946103ad565b608001610406565b9150506100e8565b503d610159565b610427565b5f80fd5b34610188575f36600319011261018857602060ff600254166040519015158152f35b34610188575f366003190112610188575f546040516001600160a01b039091168152602090f35b34610188575f36600319011261018857604051635f35b0b360e01b81523360048201526020816024817f000000000000000000000000441d5687245ee9e7388c51159770736fb142ea9c6001600160a01b03165afa9081156101835761024c916100f4915f91610273575b50600160ff1b16151590565b61025f5761012260ff1960025416600255565b63d1b5191160e01b5f52603e60045260245ffd5b610295915060203d60201161029b575b61028d81836103e4565b810190610418565b5f610240565b503d610283565b34610188575f366003190112610188576040517f000000000000000000000000441d5687245ee9e7388c51159770736fb142ea9c6001600160a01b03168152602090f35b34610188575f36600319011261018857604051635f35b0b360e01b81523360048201526020816024816001600160a01b037f000000000000000000000000441d5687245ee9e7388c51159770736fb142ea9c165afa9081156101835761035d916100f4915f9161038e575b50600160fb1b16151590565b8015610379575b610124575f80546001600160a01b0319169055005b506103896100f460025460ff1690565b610364565b6103a7915060203d60201161029b5761028d81836103e4565b5f610351565b601f80199101166080016080811067ffffffffffffffff8211176103d057604052565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff8211176103d057604052565b602090607f1901126101885760805190565b90816020910312610188575190565b6040513d5f823e3d90fd5b5f805481906001600160a01b0316368280378136915af43d5f803e15610456573d5ff35b3d5ffdfea26469706673582212209f3e14cd60e5a3becebc187d8c9f6f2aa14cc4c152fb580b60130b76dcaf518164736f6c634300081d0033
Verified Source Code Full Match
Compiler: v0.8.29+commit.ab55807c
EVM: cancun
Optimization: Yes (100 runs)
TTSwap_Market_Proxy.sol 81 lines
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.29;
import {TTSwapError} from "./libraries/L_Error.sol";
import {L_UserConfigLibrary} from "./libraries/L_UserConfig.sol";
import {toTTSwapUINT256} from "./libraries/L_TTSwapUINT256.sol";
import {I_TTSwap_Token} from "./interfaces/I_TTSwap_Token.sol";
/**
* @title TTSwap Market Proxy
* @dev Proxy contract for TTSwap Market using delegatecall.
* @notice This contract holds the storage and delegates logic execution to the implementation contract.
* It supports upgradability controlled by admins.
*/
contract TTSwap_Market_Proxy {
using L_UserConfigLibrary for uint256;
address public implementation;
I_TTSwap_Token public immutable TTS_CONTRACT;
mapping(address _trader => uint256 nonce) private nonces;
bool public upgradeable;
/// @notice Initializes the proxy with the token contract and initial implementation.
/// @param _TTS_Contract The address of the TTSwap Token contract (for permission checks).
/// @param _implementation The address of the initial Market implementation logic.
constructor(
I_TTSwap_Token _TTS_Contract,
address _implementation
) {
TTS_CONTRACT = _TTS_Contract;
implementation = _implementation;
upgradeable = true;
}
/// @notice Fallback function that delegates calls to the implementation contract.
fallback() external payable {
address impl = implementation;
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), impl, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if iszero(result) {
revert(0, returndatasize())
}
return(0, returndatasize())
}
}
/// @dev Restricts access to Market Admins.
modifier onlyMarketAdminProxy() {
if (!TTS_CONTRACT.userConfig(msg.sender).isMarketAdmin() || !upgradeable)
revert TTSwapError(1);
_;
}
/// @dev Restricts access to Market Managers.
modifier onlyMarketManagerProxy() {
if (!TTS_CONTRACT.userConfig(msg.sender).isMarketManager() || !upgradeable)
revert TTSwapError(1);
_;
}
/// @notice Upgrades the market implementation contract.
/// @param _implementation The new implementation address.
function upgrade(address _implementation) external onlyMarketAdminProxy {
implementation = _implementation;
}
/// @notice Permanently disables upgradability.
/// @dev Can only be called by DAO Admin. Once disabled, the implementation cannot be changed.
function disableUpgrade() external {
if (!TTS_CONTRACT.userConfig(msg.sender).isDAOAdmin()) revert TTSwapError(62);
upgradeable = false;
}
/// @notice Freezes the market by setting implementation to address(0).
/// @dev Can be called by Market Manager for emergency stops.
function freezeMarket() external onlyMarketManagerProxy {
implementation = address(0);
}
receive() external payable {}
}
I_TTSwap_Token.sol 303 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;
/// @title Investment Proof Interface
/// @notice Contains a series of interfaces for goods
interface I_TTSwap_Token {
/// @notice Emitted when environment variables are set
/// @param marketcontract The address of the market contract
event e_setenv(address marketcontract);
/// @notice Emitted when user config is updated
/// @param user The address of the user
/// @param config The new config value
event e_updateUserConfig(address user, uint256 config);
/// @notice Emitted when a referral relationship is added
/// @param user The address of the user being referred
event e_addreferral(address user, address referal);
/// @notice Emitted when minting is added
/// @param recipient The address receiving the minted tokens
/// @param leftamount The remaining amount to be minted
/// @param metric The metric used for minting
/// @param chips The number of chips
event e_addShare(
address recipient,
uint128 leftamount,
uint120 metric,
uint8 chips
);
/// @notice Emitted when minting is burned
/// @param owner The index of the minting operation being burned
event e_burnShare(address owner);
/// @notice Emitted when DAO minting occurs
/// @param mintamount The amount being minted
/// @param owner The index of the minting operation
event e_shareMint(uint128 mintamount, address owner);
/// @notice Emitted during a public sale
/// @param usdtamount The amount of USDT involved
/// @param ttsamount The amount of TTS involved
event e_publicsell(uint256 usdtamount, uint256 ttsamount);
/// @notice Emitted when chain stake is synchronized
/// @param chain The chain ID
/// @param poolasset The pool asset value
/// @param proofstate The value of the pool
//first 128 bit proofvalue,last 128 bit proofconstruct
event e_syncChainStake(uint32 chain, uint128 poolasset, uint256 proofstate);
/// @notice Emitted when unstaking occurs
/// @param recipient The address receiving the unstaked tokens
/// @param proofvalue first 128 bit proofvalue,last 128 bit poolcontruct
/// @param unstakestate The state after unstaking
/// @param stakestate The state of the stake
/// @param poolstate The state of the pool
event e_stakeinfo(
address recipient,
uint256 proofvalue,
uint256 unstakestate,
uint256 stakestate,
uint256 poolstate
);
/// @notice Emitted when the pool state is updated
/// @param poolstate The new state of the pool
event e_updatepool(uint256 poolstate);
/// @notice Emitted when the pool state is updated
/// @param ttsconfig The new state of the pool
event e_updatettsconfig(uint256 ttsconfig);
/**
* @dev Returns the share information for a given user address.
* @param user The address to query for share information.
* @return The s_share struct containing the user's share details.
*/
function usershares(address user) external view returns (s_share memory);
/**
* @dev Returns the current staking state.
* @return The staking state as a uint256 value.
*/
function stakestate() external view returns (uint256);
/**
* @dev Returns the current pool state.
* @return The pool state as a uint256 value.
*/
function poolstate() external view returns (uint256);
/**
* @dev Returns the TTS token configuration value.
* @return The configuration as a uint256 value.
*/
function ttstokenconfig() external view returns (uint256);
/**
* @dev Returns the amount of left share available for minting.
* @return The left share as a uint128 value.
*/
function left_share() external view returns (uint128);
/**
* @dev Returns the stake proof information for a given index.
* @param index The index to query for stake proof information.
* @return The s_proof struct containing the stake proof details.
*/
function stakeproofinfo(uint256 index) external view returns (s_proof memory);
/**
* @dev Sets the trading volume ratio for the protocol.
* @param _ratio The new ratio value (max 10000).
*/
function setRatio(uint256 _ratio) external;
/**
* @dev Grants or revokes DAO admin privileges to a recipient address.
* @param _recipient The address to grant or revoke DAO admin rights.
* @param result Boolean indicating whether to grant (true) or revoke (false) the privilege.
*/
function setDAOAdmin(address _recipient, bool result) external;
/**
* @dev Grants or revokes Token admin privileges to a recipient address.
* @param _recipient The address to grant or revoke Token admin rights.
* @param result Boolean indicating whether to grant (true) or revoke (false) the privilege.
*/
function setTokenAdmin(address _recipient, bool result) external;
/**
* @dev Grants or revokes Token manager privileges to a recipient address.
* @param _recipient The address to grant or revoke Token manager rights.
* @param result Boolean indicating whether to grant (true) or revoke (false) the privilege.
*/
function setTokenManager(address _recipient, bool result) external;
/**
* @dev Grants or revokes permission to call mintTTS to a recipient address.
* @param _recipient The address to grant or revoke permission.
* @param result Boolean indicating whether to grant (true) or revoke (false) the privilege.
*/
function setCallMintTTS(address _recipient, bool result) external;
/**
* @dev Grants or revokes Market admin privileges to a recipient address.
* @param _recipient The address to grant or revoke Market admin rights.
* @param result Boolean indicating whether to grant (true) or revoke (false) the privilege.
*/
function setMarketAdmin(address _recipient, bool result) external;
/**
* @dev Grants or revokes Market manager privileges to a recipient address.
* @param _recipient The address to grant or revoke Market manager rights.
* @param result Boolean indicating whether to grant (true) or revoke (false) the privilege.
*/
function setMarketManager(address _recipient, bool result) external;
/**
* @dev Grants or revokes Stake admin privileges to a recipient address.
* @param _recipient The address to grant or revoke Stake admin rights.
* @param result Boolean indicating whether to grant (true) or revoke (false) the privilege.
*/
function setStakeAdmin(address _recipient, bool result) external;
/**
* @dev Grants or revokes Stake manager privileges to a recipient address.
* @param _recipient The address to grant or revoke Stake manager rights.
* @param result Boolean indicating whether to grant (true) or revoke (false) the privilege.
*/
function setStakeManager(address _recipient, bool result) external;
/**
* @dev Sets or unsets a ban on a recipient address, restricting their access.
* @param _recipient The address to ban or unban.
* @param result Boolean indicating whether to ban (true) or unban (false) the address.
*/
function setBan(address _recipient, bool result) external;
/**
* @dev Returns the amount of TTS available for public sale
* @return _publicsell Returns the amount of TTS available for public sale
*/
function publicsell() external view returns (uint128 _publicsell);
/**
* @dev Returns the authorization level for a given address
* @param recipent user's address
* @return _auth Returns the authorization level
*/
function userConfig(address recipent) external view returns (uint256 _auth);
/**
* @dev Sets the environment variables for normal good ID, value good ID, and market contract address
* @param _marketcontract The address of the market contract
*/
function setEnv(address _marketcontract) external;
/**
* @dev Adds a new mint share to the contract
* @param _share The share structure containing recipient, amount, metric, and chips
* @notice Only callable on the main chain by the DAO admin
* @notice Reduces the left_share by the amount in _share
* @notice Increments the shares_index and adds the new share to the shares mapping
* @notice Emits an e_addShare event with the share details
*/
function addShare(s_share calldata _share, address owner) external;
/**
* @dev Burns the share at the specified index
* @param owner owner of share
*/
function burnShare(address owner) external;
/**
* @dev Mints a share at the specified
*/
function shareMint() external;
/**
* @dev how much cost to buy tts
* @param usdtamount usdt amount
*/
function publicSell(uint256 usdtamount, bytes calldata data) external;
/**
* @dev Withdraws the specified amount from the public sale to the recipient
* @param amount admin tranfer public sell to another address
* @param recipent user's address
*/
function withdrawPublicSell(uint256 amount, address recipent) external;
/**
* @dev Burns the specified value of tokens from the given account
* @param value the amount will be burned
*/
function burn(uint256 value) external;
/// @notice Add a referral relationship
/// @param user The address of the user being referred
/// @param referral The address of the referrer
function setReferral(address user, address referral) external;
/// @notice Stake tokens
/// @param staker The address of the staker
/// @param proofvalue The proof value for the stake
/// @return construct The construct value after staking
function stake(
address staker,
uint128 proofvalue
) external returns (uint128 construct);
/// @notice Unstake tokens
/// @param staker The address of the staker
/// @param proofvalue The proof value for unstaking
function unstake(address staker, uint128 proofvalue) external;
/// @notice Get the DAO admin and referral for a customer
/// @param _customer The address of the customer
/// @return referral The address of the referrer
function getreferral(
address _customer
) external view returns (address referral);
/**
* @dev Permits a share to be transferred
* @param _share The share structure containing recipient, amount, metric, and chips
* @param dealline The deadline for the share transfer
* @param signature The signature of the share transfer
* @param signer The address of the signer
*/
function permitShare(
s_share memory _share,
uint128 dealline,
bytes calldata signature,
address signer
) external;
/**
* @dev Calculates the hash of a share transfer
* @param _share The share structure containing recipient, amount, metric, and chips
* @param owner The address of the owner
* @param leftamount The amount of left share
* @param deadline The deadline for the share transfer
*/
function shareHash(
s_share memory _share,
address owner,
uint128 leftamount,
uint128 deadline,
uint256 nonce
) external pure returns (bytes32);
}
/// @notice Struct for share information
/// @dev Contains information about a share, including the amount of left to unlock, the metric, and the chips
struct s_share {
uint128 leftamount; // unlock amount
uint120 metric; //last unlock's metric
uint8 chips; // define the share's chips, and every time unlock one chips
}
/// @notice Struct for proof information
/// @dev Contains information about a proof, including the contract address and the state
struct s_proof {
address fromcontract; // from which contract
uint256 proofstate; // stake's state amount0 value 128 construct asset
}
L_TTSwapUINT256.sol 204 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;
using L_TTSwapUINT256Library for uint256;
/// @notice Converts two uint128 values into a T_BalanceUINT256
/// @param _amount0 The first 128-bit amount
/// @param _amount1 The second 128-bit amount
/// @return balanceDelta The resulting T_BalanceUINT256
function toTTSwapUINT256(uint128 _amount0, uint128 _amount1) pure returns (uint256 balanceDelta) {
assembly ("memory-safe") {
balanceDelta :=
or(shl(128, _amount0), and(0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff, _amount1))
}
}
/// @notice Adds two T_BalanceUINT256 values
/// @param a The first T_BalanceUINT256
/// @param b The second T_BalanceUINT256
/// @return The sum of a and b as a T_BalanceUINT256
function add(uint256 a, uint256 b) pure returns (uint256) {
uint256 res0;
uint256 res1;
uint256 a0;
uint256 a1;
uint256 b0;
uint256 b1;
assembly ("memory-safe") {
a0 := shr(128, a)
a1 := and(0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff, a)
b0 := shr(128, b)
b1 := and(0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff, b)
res0 := add(a0, b0)
res1 := add(a1, b1)
}
require(res0 >= a0 && res0 >= b0 && res1 >= a1 && res1 >= b1 && res1 <type(uint128).max && res0 <type(uint128).max, "TTSwapUINT256: add overflow");
return (res0<<128)+res1;
}
/// @notice Subtracts two T_BalanceUINT256 values
/// @param a The first T_BalanceUINT256
/// @param b The second T_BalanceUINT256
/// @return The difference of a and b as a T_BalanceUINT256
function sub(uint256 a, uint256 b) pure returns (uint256) {
uint256 res0;
uint256 res1;
uint256 a0;
uint256 a1;
uint256 b0;
uint256 b1;
unchecked{
assembly ("memory-safe") {
a0 := shr(128, a)
a1 := and(0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff, a)
b0 := shr(128, b)
b1 := and(0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff, b)
res0 := sub(a0, b0)
res1 := sub(a1, b1)
}}
require(res0 <=a0 && res1<=a1 &&a1>=b1 && a0>=b0, "TTSwapUINT256: sub overflow");
return (res0<<128)+res1;
}
/// @notice Adds the first components and subtracts the second components of two T_BalanceUINT256 values
/// @param a The first T_BalanceUINT256
/// @param b The second T_BalanceUINT256
/// @return The result of (a0 + b0, a1 - b1) as a T_BalanceUINT256
function addsub(uint256 a, uint256 b) pure returns (uint256) {
uint256 res0;
uint256 res1;
uint256 a0;
uint256 a1;
uint256 b0;
uint256 b1;
unchecked{
assembly ("memory-safe") {
a0 := shr(128, a)
a1 := and(0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff, a)
b0 := shr(128, b)
b1 := and(0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff, b)
res0 := add(a0, b0)
res1 := sub(a1, b1)
}}
require(res0 >=a0 && res0>=b0 && res1<=a1 && a1>=b1 && res0<type(uint128).max , "TTSwapUINT256: addsub overflow");
return (res0<<128)+res1;
}
/// @notice Subtracts the first components and adds the second components of two T_BalanceUINT256 values
/// @param a The first T_BalanceUINT256
/// @param b The second T_BalanceUINT256
/// @return The result of (a0 - b0, a1 + b1) as a T_BalanceUINT256
function subadd(uint256 a, uint256 b) pure returns (uint256) {
uint256 res0;
uint256 res1;
uint256 a0;
uint256 a1;
uint256 b0;
uint256 b1;
unchecked{
assembly ("memory-safe") {
a0 := sar(128, a)
a1 := and(0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff, a)
b0 := sar(128, b)
b1 := and(0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff, b)
res0 := sub(a0, b0)
res1 := add(a1, b1)
}}
require(res1 >=a1 && res1>=b1 && res0<=a0 && a0>=b0 && res1<type(uint128).max , "TTSwapUINT256: subadd overflow");
return (res0<<128)+res1;
}
/// @notice Safely converts a uint256 to a uint128
/// @param a The uint256 value to convert
/// @return b converted uint128 value, or 0 if overflow
function toUint128(uint256 a) pure returns (uint128 b) {
b=uint128(a);
require(a==uint256(b) , "TTSwapUINT256: toUint128 overflow");
}
/// @notice Compares the prices of three T_BalanceUINT256 values
/// @param a The first T_BalanceUINT256
/// @param b The second T_BalanceUINT256
/// @param c The third T_BalanceUINT256
/// @return True if the price of a is lower than the prices of b and c, false otherwise
function lowerprice(uint256 a, uint256 b, uint256 c) pure returns (bool) {
return uint256(a.amount0()) * uint256(b.amount1()) * uint256(c.amount1())
> uint256(a.amount1()) * uint256(b.amount0()) * uint256(c.amount0()) ? true : false;
}
/// @notice Performs a multiplication followed by a division (full precision)
/// @dev Optimized to prevent intermediate overflow during multiplication
/// @param config The multiplicand
/// @param amount The multiplier
/// @param domitor The divisor
/// @return a The result as a uint128
function mulDiv(uint256 config, uint256 amount, uint256 domitor) pure returns (uint128 a) {
uint256 result;
unchecked {
assembly {
config := mul(config, amount)
result := div(config, domitor)
}
}
return toUint128(result);
}
/// @title L_TTSwapUINT256Library
/// @notice A library for operations on T_BalanceUINT256
library L_TTSwapUINT256Library {
/// @notice Extracts the first 128-bit amount from a T_BalanceUINT256
/// @param balanceDelta The T_BalanceUINT256 to extract from
/// @return _amount0 The extracted first 128-bit amount
function amount0(uint256 balanceDelta) internal pure returns (uint128 _amount0) {
assembly {
_amount0 := shr(128, balanceDelta)
}
}
/// @notice Extracts the second 128-bit amount from a T_BalanceUINT256
/// @param balanceDelta The T_BalanceUINT256 to extract from
/// @return _amount1 The extracted second 128-bit amount
function amount1(uint256 balanceDelta) internal pure returns (uint128 _amount1) {
assembly {
_amount1 := balanceDelta
}
}
/// @notice Extracts the first and second 128-bit amounts from a T_BalanceUINT256
/// @param balanceDelta The T_BalanceUINT256 to extract from
/// @return _amount0 The extracted first 128-bit amount
/// @return _amount1 The extracted second 128-bit amount
function amount01(uint256 balanceDelta) internal pure returns (uint128 _amount0,uint128 _amount1) {
assembly {
_amount0 := shr(128, balanceDelta)
_amount1 := balanceDelta
}
}
/// @notice Calculates amount0 based on a given amount1 and the ratio in balanceDelta
/// @param balanceDelta The T_BalanceUINT256 containing the ratio
/// @param amount1delta The amount1 to base the calculation on
/// @return _amount0 The calculated amount0
function getamount0fromamount1(uint256 balanceDelta, uint128 amount1delta)
internal
pure
returns (uint128 _amount0)
{
return mulDiv(balanceDelta.amount0(), amount1delta, balanceDelta.amount1());
}
/// @notice Calculates amount1 based on a given amount0 and the ratio in balanceDelta
/// @param balanceDelta The T_BalanceUINT256 containing the ratio
/// @param amount0delta The amount0 to base the calculation on
/// @return _amount1 The calculated amount1
function getamount1fromamount0(uint256 balanceDelta, uint128 amount0delta)
internal
pure
returns (uint128 _amount1)
{
return mulDiv(balanceDelta.amount1(), amount0delta, balanceDelta.amount0());
}
}
L_UserConfig.sol 127 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.29;
/// @title User Configuration Library
/// @notice Library for managing user permissions and roles within the TTSwap system.
/// @dev Uses bitwise operations on a `uint256` to store boolean flags and addresses efficiently.
///
/// Permission Layout (Bit Index):
/// - 255: DAO Admin
/// - 254: Token Admin
/// - 253: Token Manager
/// - 252: Market Admin
/// - 251: Market Manager
/// - 250: Can Call Mint TTS (Contract Role)
/// - 249: Stake Admin
/// - 248: Stake Manager
/// - 160: Ban Status
/// - [0-159]: Referral Address (160 bits)
library L_UserConfigLibrary {
/// @notice Checks if the user has DAO Admin privileges.
/// @param config The user's configuration value.
/// @return a True if DAO Admin, false otherwise.
function isDAOAdmin(uint256 config) internal pure returns(bool a){
return (config&uint256(2**255))>0;
}
/// @notice Sets or unsets DAO Admin privileges.
/// @param config The current configuration value.
/// @param a The new boolean status.
/// @return e The updated configuration value.
function setDAOAdmin(uint256 config,bool a)internal pure returns(uint256 e){
return (config&(~(uint256(2**255))))|(a?uint256(2**255):0);
}
/// @notice Checks if the user has Token Admin privileges.
function isTokenAdmin(uint256 config) internal pure returns(bool a){
return (config&uint256(2**254))>0;
}
/// @notice Sets or unsets Token Admin privileges.
function setTokenAdmin(uint256 config,bool a)internal pure returns(uint256 e){
return config&~(uint256(2**254))|(a?uint256(2**254):0);
}
/// @notice Checks if the user has Token Manager privileges.
function isTokenManager(uint256 config) internal pure returns(bool a){
return (config&uint256(2**253))>0;
}
/// @notice Sets or unsets Token Manager privileges.
function setTokenManager(uint256 config,bool a)internal pure returns(uint256 e){
return config&~(uint256(2**253))|(a?uint256(2**253):0);
}
/// @notice Checks if the user has Market Admin privileges.
function isMarketAdmin(uint256 config)internal pure returns(bool a){
return (config&uint256(2**252))>0;
}
/// @notice Sets or unsets Market Admin privileges.
function setMarketAdmin(uint256 config,bool a)internal pure returns(uint256 e){
return config&~(uint256(2**252))|(a?uint256(2**252):0);
}
/// @notice Checks if the user has Market Manager privileges.
function isMarketManager(uint256 config)internal pure returns(bool a){
return (config&uint256(2**251))>0;
}
/// @notice Sets or unsets Market Manager privileges.
function setMarketManager(uint256 config,bool a)internal pure returns(uint256 e){
return config&~(uint256(2**251))|(a?uint256(2**251):0);
}
/// @notice Checks if the user (contract) is authorized to call mint functions.
function isCallMintTTS(uint256 config)internal pure returns(bool a){
return (config&uint256(2**250))>0;
}
/// @notice Sets or unsets mint calling authorization.
function setCallMintTTS(uint256 config,bool a)internal pure returns(uint256 e){
return config&~(uint256(2**250))|(a?uint256(2**250):0);
}
/// @notice Checks if the user has Stake Admin privileges.
function isStakeAdmin(uint256 config)internal pure returns(bool a){
return (config&uint256(2**249))>0;
}
/// @notice Sets or unsets Stake Admin privileges.
function setStakeAdmin(uint256 config,bool a)internal pure returns(uint256 e){
return config&~(uint256(2**249))|(a?uint256(2**249):0);
}
/// @notice Checks if the user has Stake Manager privileges.
function isStakeManager(uint256 config)internal pure returns(bool a){
return (config&uint256(2**248))>0;
}
/// @notice Sets or unsets Stake Manager privileges.
function setStakeManager(uint256 config,bool a)internal pure returns(uint256 e){
return config&~(uint256(2**248))|(a?uint256(2**248):0);
}
/// @notice Checks if the user is banned.
function isBan(uint256 config)internal pure returns(bool a){
return (config&uint256(2**160))>0;
}
/// @notice Sets or unsets the ban status.
function setBan(uint256 config,bool a)internal pure returns(uint256 e){
return config&~(uint256(2**160))|(a?uint256(2**160):0);
}
/// @notice Retrieves the referral address associated with the user.
/// @dev Returns the lower 160 bits cast as an address.
function referral(uint256 config)internal pure returns(address a){
return address(uint160(config));
}
/// @notice Sets the referral address for the user.
/// @dev Clears the lower 160 bits and ORs them with the new address.
function setReferral(uint256 config,address a)internal pure returns(uint256 e){
return (config&~(uint256(2**160)-1))|uint256(uint160(a));
}
}
L_Error.sol 7 lines
// SPDX-License-Identifier: MIT pragma solidity 0.8.29; /// @notice Defines the standard error type used throughout the TTSwap protocol. /// @dev Errors are identified by a unique sequence code `seq` to save bytecode size compared to string revert messages. error TTSwapError(uint256 seq);
Read Contract
TTS_CONTRACT 0xc6d8954c → address
implementation 0x5c60da1b → address
upgradeable 0x41c20c8e → bool
Write Contract 3 functions
These functions modify contract state and require a wallet transaction to execute.
disableUpgrade 0x67fc9138
No parameters
freezeMarket 0xdf2e5066
No parameters
upgrade 0x0900f010
address _implementation
Recent Transactions
No transactions found for this address