Address Contract Partially Verified
Address
0xAD038Eb671c44b853887A7E32528FaB35dC5D710
Balance
0 ETH
Nonce
1
Code Size
6937 bytes
Creator
0x3FcB35a1...cB28 at tx 0x11880b3f...2ffcae
Indexed Transactions
0
Contract Bytecode
6937 bytes
0x608060405234801561001057600080fd5b50600436106102325760003560e01c806370a0823111610130578063ac7e534e116100b8578063dcdf770f1161007c578063dcdf770f146104ed578063dd62ed3e146104f6578063f46eccc414610521578063f7f11fb714610544578063fffdfb381461055757600080fd5b8063ac7e534e14610499578063b2c08775146104ac578063d505accf146104bf578063d54e65fb146104d2578063d8d2c648146104da57600080fd5b806393e30633116100ff57806393e306331461044f57806395d89b4114610462578063983b2d561461046a578063a10f84cb1461047d578063a9059cbb1461048657600080fd5b806370a08231146103e65780637ecebe00146103f95780638200b331146104195780638e8f294b1461042c57600080fd5b80633092afd5116101be57806340c10f191161018257806340c10f191461037a57806342966c681461038d578063570ca735146103a05780635a57b46f146103cb5780636866c625146103d357600080fd5b80633092afd514610329578063313ce5671461033c5780633644e5151461035657806336459f041461035e5780633eaaf86b1461037157600080fd5b806318160ddd1161020557806318160ddd146102bb57806323b30572146102c357806323b872dd146102d657806327e235e3146102e95780632ecd4e7d1461030957600080fd5b806306fdde0314610237578063095ea7b3146102555780630a6f93e614610278578063143d4e49146102a6575b600080fd5b61023f610577565b60405161024c91906116c1565b60405180910390f35b610268610263366004611732565b610605565b604051901515815260200161024c565b61029861028636600461175c565b600e6020526000908152604090205481565b60405190815260200161024c565b6102b96102b436600461175c565b610671565b005b6102986106c6565b6102b96102d136600461177e565b6106ef565b6102686102e4366004611797565b6107e7565b6102986102f736600461175c565b60076020526000908152604090205481565b61029861031736600461175c565b600c6020526000908152604090205481565b6102b961033736600461175c565b6108ef565b610344601281565b60405160ff909116815260200161024c565b610298610962565b61029861036c36600461175c565b6109b8565b61029860025481565b6102b9610388366004611732565b610a8a565b6102b961039b36600461177e565b610b11565b6003546103b3906001600160a01b031681565b6040516001600160a01b03909116815260200161024c565b6102b9610b1e565b6102b96103e136600461175c565b610b40565b6102986103f436600461175c565b610c65565b61029861040736600461175c565b60096020526000908152604090205481565b61029861042736600461175c565b610d25565b61026861043a36600461175c565b600b6020526000908152604090205460ff1681565b6102b961045d36600461175c565b610daf565b61023f610e25565b6102b961047836600461175c565b610e32565b61029860065481565b610268610494366004611732565b610ea8565b6004546103b3906001600160a01b031681565b6102b96104ba3660046117d3565b610f36565b6102b96104cd366004611815565b6110ec565b6102b9611330565b6102b96104e8366004611732565b6113d6565b61029860055481565b610298610504366004611888565b600860209081526000928352604080842090915290825290205481565b61026861052f36600461175c565b600a6020526000908152604090205460ff1681565b6102b9610552366004611732565b61146f565b61029861056536600461175c565b600d6020526000908152604090205481565b60008054610584906118bb565b80601f01602080910402602001604051908101604052809291908181526020018280546105b0906118bb565b80156105fd5780601f106105d2576101008083540402835291602001916105fd565b820191906000526020600020905b8154815290600101906020018083116105e057829003601f168201915b505050505081565b3360008181526008602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906106609086815260200190565b60405180910390a350600192915050565b6003546001600160a01b031633146106a45760405162461bcd60e51b815260040161069b906118f5565b60405180910390fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b600060025460055411156106da5750600090565b6005546002546106ea9190611932565b905090565b6003546001600160a01b031633146107195760405162461bcd60e51b815260040161069b906118f5565b600081116107745760405162461bcd60e51b815260206004820152602260248201527f7265706c656e6973686d656e74207072696365206d757374206265206f766572604482015261020360f41b606482015260840161069b565b620f42408111156107e25760405162461bcd60e51b815260206004820152603260248201527f5265706c656e6973686d656e742070726963652063616e6e6f742065786365656044820152713210189818102227a620903832b91022212960711b606482015260840161069b565b600655565b6001600160a01b038316600090815260086020908152604080832033845290915281205460001981146108435761081e8382611932565b6001600160a01b03861660009081526008602090815260408083203384529091529020555b8261084d86610c65565b101561086b5760405162461bcd60e51b815260040161069b90611949565b6001600160a01b03851660009081526007602052604081208054859290610893908490611932565b90915550506001600160a01b0380851660008181526007602052604090819020805487019055519091871690600080516020611ac4833981519152906108dc9087815260200190565b60405180910390a3506001949350505050565b6003546001600160a01b031633146109195760405162461bcd60e51b815260040161069b906118f5565b6001600160a01b0381166000818152600a6020526040808220805460ff19169055517f2f91b591fc56ac0917953ad01ec225524ee5ef0555213e4c8a9d8c9728ee7ffb9190a250565b60007f00000000000000000000000000000000000000000000000000000000000000014614610993576106ea611543565b507fd70c5a91c034ae556adea4a4208575466a13f1986ad8d938d1032fd48eb07e7690565b6001600160a01b0381166000908152600c6020908152604080832054600e90925282205482906301e133809083906109f09042611932565b6109fa9190611977565b610a049190611996565b6001600160a01b038516600090815260076020908152604080832054600d9092529091205491925090610a389083906119b8565b1015610a48575060009392505050565b6001600160a01b038416600090815260076020908152604080832054600d90925290912054610a789083906119b8565b610a829190611932565b949350505050565b336000908152600a602052604090205460ff16151560011480610ab757506003546001600160a01b031633145b610b035760405162461bcd60e51b815260206004820152601860248201527f4f4e4c59204d494e54455253204f52204f50455241544f520000000000000000604482015260640161069b565b610b0d82826115dd565b5050565b610b1b3382611637565b50565b336000908152600960205260408120805491610b39836119d0565b9190505550565b6001600160a01b0381166000908152600c6020908152604080832054600e90925290912054429003610b70575050565b6001600160a01b0382166000908152600e60205260408120546301e13380908390610b9b9042611932565b610ba59190611977565b610baf9190611996565b90506000811180610bd657506001600160a01b0383166000908152600e6020526040902054155b15610c60576001600160a01b0383166000908152600d602052604081208054839290610c039084906119b8565b925050819055508060056000828254610c1c91906119b8565b90915550506001600160a01b0383166000818152600e6020908152604080832042905551848152919291600080516020611ac4833981519152910160405180910390a35b505050565b6001600160a01b0381166000908152600c6020908152604080832054600e90925282205482906301e13380908390610c9d9042611932565b610ca79190611977565b610cb19190611996565b6001600160a01b038516600090815260076020908152604080832054600d9092529091205491925090610ce59083906119b8565b1115610cf5575060009392505050565b6001600160a01b0384166000908152600d60209081526040808320546007909252909120548291610a7891611932565b6001600160a01b0381166000908152600c6020908152604080832054600e90925282205482906301e13380908390610d5d9042611932565b610d679190611977565b610d719190611996565b6001600160a01b0385166000908152600d60209081526040808320546007909252909120549192508291610da591906119e9565b610a8291906119e9565b6003546001600160a01b03163314610dd95760405162461bcd60e51b815260040161069b906118f5565b6001600160a01b0381166000818152600b6020526040808220805460ff19166001179055517fc3dfb88ee5301cecf05761fb2728064e5b641524346ae69b9ba80394631bf11f9190a250565b60018054610584906118bb565b6003546001600160a01b03163314610e5c5760405162461bcd60e51b815260040161069b906118f5565b6001600160a01b0381166000818152600a6020526040808220805460ff19166001179055517f16baa937b08d58713325f93ac58b8a9369a4359bbefb4957d6d9b402735722ab9190a250565b600081610eb433610c65565b1015610ed25760405162461bcd60e51b815260040161069b90611949565b3360009081526007602052604081208054849290610ef1908490611932565b90915550506001600160a01b03831660008181526007602052604090819020805485019055513390600080516020611ac4833981519152906106609086815260200190565b336000908152600b602052604090205460ff16610fa45760405162461bcd60e51b815260206004820152602660248201527f4f6e6c79206d61726b6574732063616e2063616c6c206f6e466f7263655265706044820152650d8cadcd2e6d60d31b606482015260840161069b565b6000610faf856109b8565b905060008111610fee5760405162461bcd60e51b815260206004820152600a602482015269139bc81919599a58da5d60b21b604482015260640161069b565b828110156110315760405162461bcd60e51b815260206004820152601060248201526f105b5bdd5b9d080f881919599a58da5d60821b604482015260640161069b565b6000612710600654856110449190611977565b61104e9190611996565b905061105986610b40565b6001600160a01b0386166000908152600c6020526040812080548392906110819084906119b8565b90915550611091905086856115dd565b604080518581526020810183905290810184905233906001600160a01b0387811691908916907f6a03700072ec60131e7e4ff249dad34d458e1e5785dbfa8146b2265997fbf6869060600160405180910390a4505050505050565b4284101561113c5760405162461bcd60e51b815260206004820152601760248201527f5045524d49545f444541444c494e455f45585049524544000000000000000000604482015260640161069b565b60006001611148610962565b6001600160a01b038a811660008181526009602090815260409182902080546001810190915582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98184015280840194909452938d166060840152608083018c905260a083019390935260c08083018b90528151808403909101815260e08301909152805192019190912061190160f01b6101008301526101028201929092526101228101919091526101420160408051601f198184030181528282528051602091820120600084529083018083525260ff871690820152606081018590526080810184905260a0016020604051602081039080840390855afa158015611254573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381161580159061128a5750876001600160a01b0316816001600160a01b0316145b6112c75760405162461bcd60e51b815260206004820152600e60248201526d24a72b20a624a22fa9a4a3a722a960911b604482015260640161069b565b6001600160a01b0390811660009081526008602090815260408083208a8516808552908352928190208990555188815291928a16917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350505050505050565b6004546001600160a01b031633146113825760405162461bcd60e51b815260206004820152601560248201527427a7262c902822a72224a7239027a822a920aa27a960591b604482015260640161069b565b60048054600380546001600160a01b0383166001600160a01b031991821681179092559091169091556040517f8eb831fe42156caaf4721a87ad40c6e662b893dbeee76d7a3ed2564a318b091c90600090a2565b336000908152600b602052604090205460ff166114355760405162461bcd60e51b815260206004820152601d60248201527f4f6e6c79206d61726b6574732063616e2063616c6c206f6e5265706179000000604482015260640161069b565b61143e82610b40565b6001600160a01b0382166000908152600c602052604081208054839290611466908490611932565b90915550505050565b336000908152600b602052604090205460ff166114ce5760405162461bcd60e51b815260206004820152601e60248201527f4f6e6c79206d61726b6574732063616e2063616c6c206f6e426f72726f770000604482015260640161069b565b6114d782610b40565b6114e0826109b8565b1561151b5760405162461bcd60e51b815260206004820152600b60248201526a111094881119599a58da5d60aa1b604482015260640161069b565b6001600160a01b0382166000908152600c6020526040812080548392906114669084906119b8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60006040516115759190611a28565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b80600260008282546115ef91906119b8565b90915550506001600160a01b038216600081815260076020908152604080832080548601905551848152600080516020611ac483398151915291015b60405180910390a35050565b8061164183610c65565b101561165f5760405162461bcd60e51b815260040161069b90611949565b6001600160a01b03821660009081526007602052604081208054839290611687908490611932565b90915550506002805482900390556040518181526000906001600160a01b03841690600080516020611ac48339815191529060200161162b565b600060208083528351808285015260005b818110156116ee578581018301518582016040015282016116d2565b81811115611700576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b038116811461172d57600080fd5b919050565b6000806040838503121561174557600080fd5b61174e83611716565b946020939093013593505050565b60006020828403121561176e57600080fd5b61177782611716565b9392505050565b60006020828403121561179057600080fd5b5035919050565b6000806000606084860312156117ac57600080fd5b6117b584611716565b92506117c360208501611716565b9150604084013590509250925092565b600080600080608085870312156117e957600080fd5b6117f285611716565b935061180060208601611716565b93969395505050506040820135916060013590565b600080600080600080600060e0888a03121561183057600080fd5b61183988611716565b965061184760208901611716565b95506040880135945060608801359350608088013560ff8116811461186b57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561189b57600080fd5b6118a483611716565b91506118b260208401611716565b90509250929050565b600181811c908216806118cf57607f821691505b6020821081036118ef57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252600d908201526c27a7262c9027a822a920aa27a960991b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000828210156119445761194461191c565b500390565b602080825260149082015273496e73756666696369656e742062616c616e636560601b604082015260600190565b60008160001904831182151516156119915761199161191c565b500290565b6000826119b357634e487b7160e01b600052601260045260246000fd5b500490565b600082198211156119cb576119cb61191c565b500190565b6000600182016119e2576119e261191c565b5060010190565b60008083128015600160ff1b850184121615611a0757611a0761191c565b6001600160ff1b0384018313811615611a2257611a2261191c565b50500390565b600080835481600182811c915080831680611a4457607f831692505b60208084108203611a6357634e487b7160e01b86526022600452602486fd5b818015611a775760018114611a8857611ab5565b60ff19861689528489019650611ab5565b60008a81526020902060005b86811015611aad5781548b820152908501908301611a94565b505084890196505b50949897505050505050505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212203b6dcf74dcba5952c94f9204ff21e7856d27346b72b6c0f7426e61aaa65331f464736f6c634300080d0033
Verified Source Code Partial Match
Compiler: v0.8.13+commit.abaa5c0e
EVM: london
Optimization: Yes (200 runs)
DolaBorrowingRights.sol 393 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
/**
@title Dola Borrow Rights
@notice The DolaBorrowRights contract is a non-standard ERC20 token, that gives the right of holders to borrow DOLA at 0% interest.
As a borrower takes on DOLA debt, their DBR balance will be exhausted at 1 DBR per 1 DOLA borrowed per year.
*/
contract DolaBorrowingRights {
string public name;
string public symbol;
uint8 public constant decimals = 18;
uint256 public _totalSupply;
address public operator;
address public pendingOperator;
uint public totalDueTokensAccrued;
uint public replenishmentPriceBps;
mapping(address => uint256) public balances;
mapping(address => mapping(address => uint256)) public allowance;
uint256 internal immutable INITIAL_CHAIN_ID;
bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;
mapping(address => uint256) public nonces;
mapping (address => bool) public minters;
mapping (address => bool) public markets;
mapping (address => uint) public debts; // user => debt across all tracked markets
mapping (address => uint) public dueTokensAccrued; // user => amount of due tokens accrued
mapping (address => uint) public lastUpdated; // user => last update timestamp
constructor(
uint _replenishmentPriceBps,
string memory _name,
string memory _symbol,
address _operator
) {
replenishmentPriceBps = _replenishmentPriceBps;
name = _name;
symbol = _symbol;
operator = _operator;
INITIAL_CHAIN_ID = block.chainid;
INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
}
modifier onlyOperator {
require(msg.sender == operator, "ONLY OPERATOR");
_;
}
/**
@notice Sets pending operator of the contract. Operator role must be claimed by the new oprator. Only callable by Operator.
@param newOperator_ The address of the newOperator
*/
function setPendingOperator(address newOperator_) public onlyOperator {
pendingOperator = newOperator_;
}
/**
@notice Sets the replenishment price in basis points. Replenishment price denotes the increase in DOLA debt upon forced replenishments.
At 10000, the cost of replenishing 1 DBR is 1 DOLA in debt. Only callable by Operator.
@param newReplenishmentPriceBps_ The new replen
*/
function setReplenishmentPriceBps(uint newReplenishmentPriceBps_) public onlyOperator {
require(newReplenishmentPriceBps_ > 0, "replenishment price must be over 0");
require(newReplenishmentPriceBps_ <= 1_000_000, "Replenishment price cannot exceed 100 DOLA per DBR");
replenishmentPriceBps = newReplenishmentPriceBps_;
}
/**
@notice claims the Operator role if set as pending operator.
*/
function claimOperator() public {
require(msg.sender == pendingOperator, "ONLY PENDING OPERATOR");
operator = pendingOperator;
pendingOperator = address(0);
emit ChangeOperator(operator);
}
/**
@notice Add a minter to the set of addresses allowed to mint DBR tokens. Only callable by Operator.
@param minter_ The address of the new minter.
*/
function addMinter(address minter_) public onlyOperator {
minters[minter_] = true;
emit AddMinter(minter_);
}
/**
@notice Removes a minter from the set of addresses allowe to mint DBR tokens. Only callable by Operator.
@param minter_ The address to be removed from the minter set.
*/
function removeMinter(address minter_) public onlyOperator {
minters[minter_] = false;
emit RemoveMinter(minter_);
}
/**
@notice Adds a market to the set of active markets. Only callable by Operator.
@dev markets can be added but cannot be removed. A removed market would result in unrepayable debt for some users.
@param market_ The address of the new market contract to be added.
*/
function addMarket(address market_) public onlyOperator {
markets[market_] = true;
emit AddMarket(market_);
}
/**
@notice Get the total supply of DBR tokens.
@dev The total supply is calculated as the difference between total DBR minted and total DBR accrued.
@return uint representing the total supply of DBR.
*/
function totalSupply() public view returns (uint) {
if(totalDueTokensAccrued > _totalSupply) return 0;
return _totalSupply - totalDueTokensAccrued;
}
/**
@notice Get the DBR balance of an address. Will return 0 if the user has zero DBR or a deficit.
@dev The balance of a user is calculated as the difference between the user's balance and the user's accrued DBR debt + due DBR debt.
@param user Address of the user.
@return uint representing the balance of the user.
*/
function balanceOf(address user) public view returns (uint) {
uint debt = debts[user];
uint accrued = (block.timestamp - lastUpdated[user]) * debt / 365 days;
if(dueTokensAccrued[user] + accrued > balances[user]) return 0;
return balances[user] - dueTokensAccrued[user] - accrued;
}
/**
@notice Get the DBR deficit of an address. Will return 0 if th user has zero DBR or more.
@dev The deficit of a user is calculated as the difference between the user's accrued DBR deb + due DBR debt and their balance.
@param user Address of the user.
@return uint representing the deficit of the user.
*/
function deficitOf(address user) public view returns (uint) {
uint debt = debts[user];
uint accrued = (block.timestamp - lastUpdated[user]) * debt / 365 days;
if(dueTokensAccrued[user] + accrued < balances[user]) return 0;
return dueTokensAccrued[user] + accrued - balances[user];
}
/**
@notice Get the signed DBR balance of an address.
@dev This function will revert if a user has a balance of more than 2^255-1 DBR
@param user Address of the user.
@return Returns a signed int of the user's balance
*/
function signedBalanceOf(address user) public view returns (int) {
uint debt = debts[user];
uint accrued = (block.timestamp - lastUpdated[user]) * debt / 365 days;
return int(balances[user]) - int(dueTokensAccrued[user]) - int(accrued);
}
/**
@notice Approves spender to spend amount of DBR on behalf of the message sender.
@param spender Address of the spender to be approved
@param amount Amount to be approved to spend
@return Always returns true, will revert if not successful.
*/
function approve(address spender, uint256 amount) public virtual returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
/**
@notice Transfers amount to address to from message sender.
@param to The address to transfer to
@param amount The amount of DBR to transfer
@return Always returns true, will revert if not successful.
*/
function transfer(address to, uint256 amount) public virtual returns (bool) {
require(balanceOf(msg.sender) >= amount, "Insufficient balance");
balances[msg.sender] -= amount;
unchecked {
balances[to] += amount;
}
emit Transfer(msg.sender, to, amount);
return true;
}
/**
@notice Transfer amount of DBR on behalf of address from to address to. Message sender must have a sufficient allowance from the from address.
@dev Allowance is reduced by the amount transferred.
@param from Address to transfer from.
@param to Address to transfer to.
@param amount Amount of DBR to transfer.
@return Always returns true, will revert if not successful.
*/
function transferFrom(
address from,
address to,
uint256 amount
) public virtual returns (bool) {
uint256 allowed = allowance[from][msg.sender];
if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;
require(balanceOf(from) >= amount, "Insufficient balance");
balances[from] -= amount;
unchecked {
balances[to] += amount;
}
emit Transfer(from, to, amount);
return true;
}
/**
@notice Permits an address to spend on behalf of another address via a signed message.
@dev Can be bundled with a transferFrom call, to reduce transaction load on users.
@param owner Address of the owner permitting the spending
@param spender Address allowed to spend on behalf of owner.
@param value Amount to be allowed to spend.
@param deadline Timestamp after which the signed message is no longer valid.
@param v The v param of the ECDSA signature
@param r The r param of the ECDSA signature
@param s The s param of the ECDSA signature
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");
unchecked {
address recoveredAddress = ecrecover(
keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR(),
keccak256(
abi.encode(
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
),
owner,
spender,
value,
nonces[owner]++,
deadline
)
)
)
),
v,
r,
s
);
require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");
allowance[recoveredAddress][spender] = value;
}
emit Approval(owner, spender, value);
}
/**
@notice Function for invalidating the nonce of a signed message.
*/
function invalidateNonce() public {
nonces[msg.sender]++;
}
function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
}
function computeDomainSeparator() internal view virtual returns (bytes32) {
return
keccak256(
abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256(bytes(name)),
keccak256("1"),
block.chainid,
address(this)
)
);
}
/**
@notice Accrue due DBR debt of user
@dev DBR debt is accrued at a rate of 1 DBR per 1 DOLA of debt per year.
@param user The address of the user to accrue DBR debt to.
*/
function accrueDueTokens(address user) public {
uint debt = debts[user];
if(lastUpdated[user] == block.timestamp) return;
uint accrued = (block.timestamp - lastUpdated[user]) * debt / 365 days;
if(accrued > 0 || lastUpdated[user] == 0){
dueTokensAccrued[user] += accrued;
totalDueTokensAccrued += accrued;
lastUpdated[user] = block.timestamp;
emit Transfer(user, address(0), accrued);
}
}
/**
@notice Function to be called by markets when a borrow occurs.
@dev Accrues due tokens on behalf of the user, before increasing their debt.
@param user The address of the borrower
@param additionalDebt The additional amount of DOLA the user is borrowing
*/
function onBorrow(address user, uint additionalDebt) public {
require(markets[msg.sender], "Only markets can call onBorrow");
accrueDueTokens(user);
require(deficitOf(user) == 0, "DBR Deficit");
debts[user] += additionalDebt;
}
/**
@notice Function to be called by markets when a repayment occurs.
@dev Accrues due tokens on behalf of the user, before reducing their debt.
@param user The address of the borrower having their debt repaid
@param repaidDebt The amount of DOLA repaid
*/
function onRepay(address user, uint repaidDebt) public {
require(markets[msg.sender], "Only markets can call onRepay");
accrueDueTokens(user);
debts[user] -= repaidDebt;
}
/**
@notice Function to be called by markets when a force replenish occurs. This function can only be called if the user has a DBR deficit.
@dev Accrues due tokens on behalf of the user, before increasing their debt by the replenishment price and minting them new DBR.
@param user The user to be force replenished.
@param amount The amount of DBR the user will be force replenished.
*/
function onForceReplenish(address user, address replenisher, uint amount, uint replenisherReward) public {
require(markets[msg.sender], "Only markets can call onForceReplenish");
uint deficit = deficitOf(user);
require(deficit > 0, "No deficit");
require(deficit >= amount, "Amount > deficit");
uint replenishmentCost = amount * replenishmentPriceBps / 10000;
accrueDueTokens(user);
debts[user] += replenishmentCost;
_mint(user, amount);
emit ForceReplenish(user, replenisher, msg.sender, amount, replenishmentCost, replenisherReward);
}
/**
@notice Function for burning DBR from message sender, reducing supply.
@param amount Amount to be burned
*/
function burn(uint amount) public {
_burn(msg.sender, amount);
}
/**
@notice Function for minting new DBR, increasing supply. Only callable by minters and the operator.
@param to Address to mint DBR to.
@param amount Amount of DBR to mint.
*/
function mint(address to, uint amount) public {
require(minters[msg.sender] == true || msg.sender == operator, "ONLY MINTERS OR OPERATOR");
_mint(to, amount);
}
/**
@notice Internal function for minting DBR.
@param to Address to mint DBR to.
@param amount Amount of DBR to mint.
*/
function _mint(address to, uint256 amount) internal virtual {
_totalSupply += amount;
unchecked {
balances[to] += amount;
}
emit Transfer(address(0), to, amount);
}
/**
@notice Internal function for burning DBR.
@param from Address to burn DBR from.
@param amount Amount of DBR to be burned.
*/
function _burn(address from, uint256 amount) internal virtual {
require(balanceOf(from) >= amount, "Insufficient balance");
balances[from] -= amount;
unchecked {
_totalSupply -= amount;
}
emit Transfer(from, address(0), amount);
}
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 amount);
event AddMinter(address indexed minter);
event RemoveMinter(address indexed minter);
event AddMarket(address indexed market);
event ChangeOperator(address indexed newOperator);
event ForceReplenish(address indexed account, address indexed replenisher, address indexed market, uint deficit, uint replenishmentCost, uint replenisherReward);
}
Read Contract
DOMAIN_SEPARATOR 0x3644e515 → bytes32
_totalSupply 0x3eaaf86b → uint256
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
balances 0x27e235e3 → uint256
debts 0x2ecd4e7d → uint256
decimals 0x313ce567 → uint8
deficitOf 0x36459f04 → uint256
dueTokensAccrued 0xfffdfb38 → uint256
lastUpdated 0x0a6f93e6 → uint256
markets 0x8e8f294b → bool
minters 0xf46eccc4 → bool
name 0x06fdde03 → string
nonces 0x7ecebe00 → uint256
operator 0x570ca735 → address
pendingOperator 0xac7e534e → address
replenishmentPriceBps 0xa10f84cb → uint256
signedBalanceOf 0x8200b331 → int256
symbol 0x95d89b41 → string
totalDueTokensAccrued 0xdcdf770f → uint256
totalSupply 0x18160ddd → uint256
Write Contract 17 functions
These functions modify contract state and require a wallet transaction to execute.
accrueDueTokens 0x6866c625
address user
addMarket 0x93e30633
address market_
addMinter 0x983b2d56
address minter_
approve 0x095ea7b3
address spender
uint256 amount
returns: bool
burn 0x42966c68
uint256 amount
claimOperator 0xd54e65fb
No parameters
invalidateNonce 0x5a57b46f
No parameters
mint 0x40c10f19
address to
uint256 amount
onBorrow 0xf7f11fb7
address user
uint256 additionalDebt
onForceReplenish 0xb2c08775
address user
address replenisher
uint256 amount
uint256 replenisherReward
onRepay 0xd8d2c648
address user
uint256 repaidDebt
permit 0xd505accf
address owner
address spender
uint256 value
uint256 deadline
uint8 v
bytes32 r
bytes32 s
removeMinter 0x3092afd5
address minter_
setPendingOperator 0x143d4e49
address newOperator_
setReplenishmentPriceBps 0x23b30572
uint256 newReplenishmentPriceBps_
transfer 0xa9059cbb
address to
uint256 amount
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 amount
returns: bool
Recent Transactions
No transactions found for this address