Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- DSProxyRegistry
- Optimization enabled
- true
- Compiler version
- v0.5.17+commit.d19bba13
- Optimization runs
- 0
- EVM Version
- default
- Verified at
- 2026-01-23T12:08:33.582797Z
Constructor Arguments
00000000000000000000000090996fb2c2b60f6832d3b57e636a5766891d66a0
Arg [0] (address) : 0x90996fb2c2b60f6832d3b57e636a5766891d66a0
contracts/libs/DS/DSProxyRegistry.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity >=0.5.0;
import {DSProxy, DSProxyFactory} from './DSProxy.sol';
// This Registry deploys new proxy instances through DSProxyFactory.build(address) and keeps a registry of owner => proxy
contract DSProxyRegistry {
mapping(address => DSProxy) public proxies;
DSProxyFactory factory;
constructor(address factory_) public {
factory = DSProxyFactory(factory_);
}
// deploys a new proxy instance
// sets owner of proxy to caller
function build() public returns (address payable proxy) {
proxy = build(msg.sender);
}
// deploys a new proxy instance
// sets custom owner of proxy
function build(address owner) public returns (address payable proxy) {
require(proxies[owner] == DSProxy(0) || proxies[owner].owner() != owner); // Not allow new proxy if the user already has one and remains being the owner
proxy = factory.build(owner);
proxies[owner] = DSProxy(proxy);
}
}
contracts/libs/DS/DSAuth.sol
// SPDX-License-Identifier: GNU-3
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity >=0.4.23;
interface DSAuthority {
function canCall(address src, address dst, bytes4 sig) external view returns (bool);
}
contract DSAuthEvents {
event LogSetAuthority(address indexed authority);
event LogSetOwner(address indexed owner);
}
contract DSAuth is DSAuthEvents {
DSAuthority public authority;
address public owner;
constructor() public {
owner = msg.sender;
emit LogSetOwner(msg.sender);
}
function setOwner(address owner_) public auth {
owner = owner_;
emit LogSetOwner(owner);
}
function setAuthority(DSAuthority authority_) public auth {
authority = authority_;
emit LogSetAuthority(address(authority));
}
modifier auth() {
require(isAuthorized(msg.sender, msg.sig), "ds-auth-unauthorized");
_;
}
function isAuthorized(address src, bytes4 sig) internal view returns (bool) {
if (src == address(this)) {
return true;
} else if (src == owner) {
return true;
} else if (authority == DSAuthority(address(0))) {
return false;
} else {
return authority.canCall(src, address(this), sig);
}
}
}
contracts/libs/DS/DSNote.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.24;
contract DSNote {
event LogNote(
bytes4 indexed sig,
address indexed guy,
bytes32 indexed foo,
bytes32 indexed bar,
uint256 wad,
bytes fax
) anonymous;
modifier note() {
bytes32 foo;
bytes32 bar;
assembly {
foo := calldataload(4)
bar := calldataload(36)
}
emit LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data);
_;
}
}
contracts/libs/DS/DSProxy.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.6.0;
import { DSAuth } from "./DSAuth.sol";
import { DSNote } from "./DSNote.sol";
contract DSProxy is DSAuth, DSNote {
DSProxyCache public cache; // global cache for dma-contracts
constructor(address _cacheAddr) public {
setCache(_cacheAddr);
}
function() external payable {}
// use the proxy to execute calldata _data on contract _code
function execute(
bytes memory _code,
bytes memory _data
) public payable returns (address target, bytes memory response) {
target = cache.read(_code);
if (target == address(0)) {
// deploy contract & store its address in cache
target = cache.write(_code);
}
response = execute(target, _data);
}
function execute(
address _target,
bytes memory _data
) public payable auth note returns (bytes memory response) {
require(_target != address(0), "ds-proxy-target-address-required");
// call contract in current context
assembly {
let succeeded := delegatecall(sub(gas, 5000), _target, add(_data, 0x20), mload(_data), 0, 0)
let size := returndatasize
response := mload(0x40)
mstore(0x40, add(response, and(add(add(size, 0x20), 0x1f), not(0x1f))))
mstore(response, size)
returndatacopy(add(response, 0x20), 0, size)
switch iszero(succeeded)
case 1 {
// throw if delegatecall failed
revert(add(response, 0x20), size)
}
}
}
//set new cache
function setCache(address _cacheAddr) public payable auth note returns (bool) {
require(_cacheAddr != address(0), "ds-proxy-cache-address-required");
cache = DSProxyCache(_cacheAddr); // overwrite cache
return true;
}
}
contract DSProxyFactory {
event Created(address indexed sender, address indexed owner, address proxy, address cache);
mapping(address => bool) public isProxy;
DSProxyCache public cache;
constructor() public {
cache = new DSProxyCache();
}
// deploys a new proxy instance
// sets owner of proxy to caller
function build() public returns (address payable proxy) {
proxy = build(msg.sender);
}
// deploys a new proxy instance
// sets custom owner of proxy
function build(address owner) public returns (address payable proxy) {
proxy = address(new DSProxy(address(cache)));
emit Created(msg.sender, owner, address(proxy), address(cache));
DSProxy(proxy).setOwner(owner);
isProxy[proxy] = true;
}
}
contract DSProxyCache {
mapping(bytes32 => address) cache;
function read(bytes memory _code) public view returns (address) {
bytes32 hash = keccak256(_code);
return cache[hash];
}
function write(bytes memory _code) public returns (address target) {
assembly {
target := create(0, add(_code, 0x20), mload(_code))
switch iszero(extcodesize(target))
case 1 {
// throw if contract failed to deploy
revert(0, 0)
}
}
bytes32 hash = keccak256(_code);
cache[hash] = target;
}
}
Compiler Settings
{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":0,"enabled":true},"libraries":{}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","payable":false,"inputs":[{"type":"address","name":"factory_","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"address","name":"proxy","internalType":"address payable"}],"name":"build","inputs":[],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[{"type":"address","name":"proxy","internalType":"address payable"}],"name":"build","inputs":[{"type":"address","name":"owner","internalType":"address"}],"constant":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"address","name":"","internalType":"contract DSProxy"}],"name":"proxies","inputs":[{"type":"address","name":"","internalType":"address"}],"constant":true}]
Contract Creation Code
0x608060405234801561001057600080fd5b506040516102dc3803806102dc8339818101604052602081101561003357600080fd5b5051600180546001600160a01b0319166001600160a01b03909216919091179055610279806100636000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80638e1a55fc14610046578063c45527911461006a578063f3701da214610090575b600080fd5b61004e6100b6565b604080516001600160a01b039092168252519081900360200190f35b61004e6004803603602081101561008057600080fd5b50356001600160a01b03166100c6565b61004e600480360360208110156100a657600080fd5b50356001600160a01b03166100e1565b60006100c1336100e1565b905090565b6000602081905290815260409020546001600160a01b031681565b6001600160a01b03818116600090815260208190526040812054909116158061018d57506001600160a01b0380831660008181526020818152604091829020548251638da5cb5b60e01b8152925193941692638da5cb5b926004808201939291829003018186803b15801561015557600080fd5b505afa158015610169573d6000803e3d6000fd5b505050506040513d602081101561017f57600080fd5b50516001600160a01b031614155b61019657600080fd5b600154604080516379b80ed160e11b81526001600160a01b0385811660048301529151919092169163f3701da29160248083019260209291908290030181600087803b1580156101e557600080fd5b505af11580156101f9573d6000803e3d6000fd5b505050506040513d602081101561020f57600080fd5b50516001600160a01b03928316600090815260208190526040902080546001600160a01b03191693821693909317909255509056fea265627a7a723158208a7b83da76b6d17f49002823454c14a00d68d941376bd5abfbe60aa63cca59b464736f6c6343000511003200000000000000000000000090996fb2c2b60f6832d3b57e636a5766891d66a0
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100415760003560e01c80638e1a55fc14610046578063c45527911461006a578063f3701da214610090575b600080fd5b61004e6100b6565b604080516001600160a01b039092168252519081900360200190f35b61004e6004803603602081101561008057600080fd5b50356001600160a01b03166100c6565b61004e600480360360208110156100a657600080fd5b50356001600160a01b03166100e1565b60006100c1336100e1565b905090565b6000602081905290815260409020546001600160a01b031681565b6001600160a01b03818116600090815260208190526040812054909116158061018d57506001600160a01b0380831660008181526020818152604091829020548251638da5cb5b60e01b8152925193941692638da5cb5b926004808201939291829003018186803b15801561015557600080fd5b505afa158015610169573d6000803e3d6000fd5b505050506040513d602081101561017f57600080fd5b50516001600160a01b031614155b61019657600080fd5b600154604080516379b80ed160e11b81526001600160a01b0385811660048301529151919092169163f3701da29160248083019260209291908290030181600087803b1580156101e557600080fd5b505af11580156101f9573d6000803e3d6000fd5b505050506040513d602081101561020f57600080fd5b50516001600160a01b03928316600090815260208190526040902080546001600160a01b03191693821693909317909255509056fea265627a7a723158208a7b83da76b6d17f49002823454c14a00d68d941376bd5abfbe60aa63cca59b464736f6c63430005110032