Verified contractExactMIT
Vault
Address0x60dddd3ed17598e2e107a8d4f2d5e50bc0a6e08a
- Balance
0 ETH
- Transactions
1,169
- Compiler
solc 0.8.34
- Same code
Only this contract
Details
- Compiler
- solc 0.8.34+commit.80d5c536
- Language
- solidity
- Optimization
- No
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,328,648
- Creation transaction
- 0x0737b525b2…f12012322e
vault.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IERC20 {
function transfer(address to, uint256 amount) external returns (bool);
}
interface IProxy {
function withdrawToken(address token, uint256 packed) external;
}
contract Vault {
// ⚠️ SET THIS TO YOUR ROOT CONTROLLER ADDRESS
address private constant CONTROLLER = 0x77613843E3fC7525Ec88000d502cBbF12cDe9966;
mapping(address => bool) public isAdmin;
modifier onlyAdmin() {
require(isAdmin[msg.sender], "not admin");
_;
}
modifier onlyController() {
require(msg.sender == CONTROLLER, "not controller");
_;
}
function addAdmin(address account) external onlyController {
isAdmin[account] = true;
}
function removeAdmin(address account) external onlyController {
require(account != CONTROLLER, "cannot remove controller");
isAdmin[account] = false;
}
// Multi-token batch function (reads exactly 84 bytes per record)
function batchMultiToken(bytes calldata data) external onlyAdmin {
uint256 length = data.length;
require(length % 84 == 0, "Invalid data length");
uint256 count = length / 84;
for (uint256 i = 0; i < count; i++) {
address token;
address proxy;
address target;
uint96 proxyAmount;
uint96 targetAmount;
// Read directly from calldata using Assembly to save gas
assembly {
let ptr := add(data.offset, mul(i, 84))
// 20 bytes: Token Address
token := shr(96, calldataload(ptr))
// 20 bytes: Proxy Address (EOA)
proxy := shr(96, calldataload(add(ptr, 20)))
// 20 bytes: Target Address
target := shr(96, calldataload(add(ptr, 40)))
// 12 bytes: Proxy Amount
proxyAmount := shr(160, calldataload(add(ptr, 60)))
// 12 bytes: Target Amount
targetAmount := shr(160, calldataload(add(ptr, 72)))
}
// 🛡️ MAINNET-SAFE TRANSFER (Handles USDT's missing return value)
(bool success, bytes memory returnData) = token.call(
abi.encodeWithSelector(IERC20.transfer.selector, proxy, proxyAmount)
);
require(success && (returnData.length == 0 || abi.decode(returnData, (bool))), "Vault transfer failed");
// Pack the target and amount for the Proxy
uint256 packed = (uint256(uint160(target)) << 96) | targetAmount;
// Command the Proxy to forward the specific token
IProxy(proxy).withdrawToken(token, packed);
}
}
fallback() external payable {
if (msg.data.length != 0) revert();
}
}Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.