Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
# pragma version 0.4.3
dao: public(address)
emergency: public(address)
interface IController:
def set_callback(_cb: address): nonpayable
def set_amm_fee(_fee: uint256): nonpayable
def set_amm_admin_fee(_fee: uint256): nonpayable
def set_monetary_policy(_monetary_policy: address): nonpayable
def set_borrowing_discounts(_loan_discount: uint256, _liquidation_discount: uint256): nonpayable
interface IFactory:
def set_admin(admin: address): nonpayable
def set_debt_ceiling(_to: address, debt_ceiling: uint256): nonpayable
def debt_ceiling(_to: address) -> uint256: view
MAX_CALLDATA_SIZE: constant(uint256) = 1024
MAX_OUTSIZE: constant(uint256) = 1024
@deploy
def __init__(_dao: address, _emergency: address):
self.dao = _dao
self.emergency = _emergency
@internal
def _check_authorized():
assert msg.sender in [self.dao, self.emergency], "Unauthorized"
@internal
def _check_dao():
assert msg.sender == self.dao, "Only DAO"
@external
def set_callback(_controller: IController, _cb: address):
self._check_authorized()
extcall _controller.set_callback(_cb)
@external
def set_amm_fee(_controller: IController, _fee: uint256):
self._check_authorized()
extcall _controller.set_amm_fee(_fee)
@external
def set_monetary_policy(_controller: IController, _monetary_policy: address):
self._check_authorized()
extcall _controller.set_monetary_policy(_monetary_policy)
@external
def set_borrowing_discounts(_controller: IController, _loan_discount: uint256, _liquidation_discount: uint256):
self._check_authorized()
extcall _controller.set_borrowing_discounts(_loan_discount, _liquidation_discount)
@external
def set_admin_fee(_controller: IController, _fee: uint256):
self._check_authorized()
extcall _controller.set_amm_admin_fee(_fee)
@external
def reduce_debt_ceiling(_factory: IFactory, _to: address, _amount: uint256):
# In practice there's only one factory where this matters
# Did this for convenience on the caller side
self._check_authorized()
current_debt_ceiling: uint256 = staticcall _factory.debt_ceiling(_to)
assert _amount <= current_debt_ceiling, "Can only reduce debt ceiling"
extcall _factory.set_debt_ceiling(_to, _amount)
@external
@payable
def execute(_target: address, _calldata: Bytes[MAX_CALLDATA_SIZE]) -> Bytes[MAX_OUTSIZE]:
self._check_dao()
return raw_call(
_target,
_calldata,
value=msg.value,
max_outsize=MAX_OUTSIZE
)
@external
def transfer_ownership(_factory: IFactory, _owner: address):
self._check_dao()
extcall _factory.set_admin(_owner)
@external
def set_emergency(_emergency: address):
self._check_dao()
self.emergency = _emergency
@external
def remove_emergency():
"""
Useful in case of compromise of the emergency address
"""
self._check_authorized()
self.emergency = empty(address)
Submitted on: 2025-11-04 09:43:48
Comments
Log in to comment.
No comments yet.