This function is only callable by the admin of the contract.
Function to set the debt ceiling of a market and mint the token amount given for it.
Returns: debt ceiling (uint256).
Emits: MintForMarket or RemoveFromMarket or SetDebtCeiling
Input
Type
Description
_to
address
Address to set debt ceiling for
debt_ceiling
uint256
Maximum to be allowed to mint
Source code
eventSetDebtCeiling:addr:indexed(address)debt_ceiling:uint256eventMintForMarket:addr:indexed(address)amount:uint256eventRemoveFromMarket:addr:indexed(address)amount:uint256@internaldef_set_debt_ceiling(addr:address,debt_ceiling:uint256,update:bool):""" @notice Set debt ceiling for a market @param addr Controller address @param debt_ceiling Value for stablecoin debt ceiling @param update Whether to actually update the debt ceiling (False is used for burning the residuals) """old_debt_residual:uint256=self.debt_ceiling_residual[addr]ifdebt_ceiling>old_debt_residual:to_mint:uint256=debt_ceiling-old_debt_residualSTABLECOIN.mint(addr,to_mint)self.debt_ceiling_residual[addr]=debt_ceilinglogMintForMarket(addr,to_mint)ifdebt_ceiling<old_debt_residual:diff:uint256=min(old_debt_residual-debt_ceiling,STABLECOIN.balanceOf(addr))STABLECOIN.burnFrom(addr,diff)self.debt_ceiling_residual[addr]=old_debt_residual-difflogRemoveFromMarket(addr,diff)ifupdate:self.debt_ceiling[addr]=debt_ceilinglogSetDebtCeiling(addr,debt_ceiling)@external@nonreentrant('lock')defset_debt_ceiling(_to:address,debt_ceiling:uint256):""" @notice Set debt ceiling of the address - mint the token amount given for it @param _to Address to allow borrowing for @param debt_ceiling Maximum allowed to be allowed to mint for it """assertmsg.sender==self.adminself._set_debt_ceiling(_to,debt_ceiling,True)
@externaldefmint(_to:address,_value:uint256)->bool:""" @notice Mint `_value` amount of tokens to `_to`. @dev Only callable by an account with minter privileges. @param _to The account newly minted tokens are credited to. @param _value The amount of tokens to mint. """assertmsg.sender==self.minterassert_tonotin[self,empty(address)]self.balanceOf[_to]+=_valueself.totalSupply+=_valuelogTransfer(empty(address),_to,_value)returnTrue@externaldefburn(_value:uint256)->bool:""" @notice Burn `_value` amount of tokens. @param _value The amount of tokens to burn. """self._burn(msg.sender,_value)returnTrue
This function is only callable by the admin of the contract.
Function to set the fee receiver address.
Emits: SetFeeReceiver
Input
Type
Description
fee_receiver
address
Address of the receiver
Source code
eventSetFeeReceiver:fee_receiver:addressfee_receiver:public(address)@external@nonreentrant('lock')defset_fee_receiver(fee_receiver:address):""" @notice Set fee receiver who earns interest (DAO) @param fee_receiver Address of the receiver """assertmsg.sender==self.adminassertfee_receiver!=empty(address)self.fee_receiver=fee_receiverlogSetFeeReceiver(fee_receiver)
This function is only callable by the admin of the contract.
Function to claim fees above the debt ceiling. This function will automatically increase the debt ceiling if there is not enough to claim admin fees.
Input
Type
Description
_to
address
Address of the controller
Source code
@external@nonreentrant('lock')defcollect_fees_above_ceiling(_to:address):""" @notice If the receiver is the controller - increase the debt ceiling if it's not enough to claim admin fees and claim them @param _to Address of the controller """assertmsg.sender==self.adminold_debt_residual:uint256=self.debt_ceiling_residual[_to]assertself.debt_ceiling[_to]>0orold_debt_residual>0admin_fees:uint256=Controller(_to).total_debt()+Controller(_to).redeemed()-Controller(_to).minted()b:uint256=STABLECOIN.balanceOf(_to)ifadmin_fees>b:to_mint:uint256=admin_fees-bSTABLECOIN.mint(_to,to_mint)self.debt_ceiling_residual[_to]=old_debt_residual+to_mintController(_to).collect_fees()
This function is only callable by the admin of the contract.
Function to set new implementations (blueprints) for Controller and AMM. Setting new implementations for Controller and AMM does not affect the existing ones.
Emits: SetImplementations
Input
Type
Description
controller
Address
Address of the controller blueprint
amm
Address
Address of the amm blueprint
Source code
eventSetImplementations:amm:addresscontroller:addresscontroller_implementation:public(address)amm_implementation:public(address)@external@nonreentrant('lock')defset_implementations(controller:address,amm:address):""" @notice Set new implementations (blueprints) for controller and amm. Doesn't change existing ones @param controller Address of the controller blueprint @param amm Address of the AMM blueprint """assertmsg.sender==self.adminassertcontroller!=empty(address)assertamm!=empty(address)self.controller_implementation=controllerself.amm_implementation=ammlogSetImplementations(amm,controller)
>>>ControllerFactory.set_implementation("new controller implementation, new amm implementation")
admin:public(address)@externaldef__init__(stablecoin:ERC20,admin:address,fee_receiver:address,weth:address):""" @notice Factory which creates both controllers and AMMs from blueprints @param stablecoin Stablecoin address @param admin Admin of the factory (ideally DAO) @param fee_receiver Receiver of interest and admin fees @param weth Address of WETH contract address """STABLECOIN=stablecoinself.admin=adminself.fee_receiver=fee_receiverWETH=weth
This function is only callable by the admin of the contract.
Function to set the admin of the contract.
Emits: SetAdmin
Input
Type
Description
admin
address
New admin
Source code
eventSetAdmin:admin:addressadmin:public(address)@external@nonreentrant('lock')defset_admin(admin:address):""" @notice Set admin of the factory (should end up with DAO) @param admin Address of the admin """assertmsg.sender==self.adminself.admin=adminlogSetAdmin(admin)