-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathUSDS.sol
61 lines (43 loc) · 1.92 KB
/
USDS.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// SPDX-License-Identifier: BUSL 1.1
pragma solidity =0.8.22;
import "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-contracts/contracts/access/Ownable.sol";
import "../stable/interfaces/ICollateralAndLiquidity.sol";
import "./interfaces/IUSDS.sol";
// USDS can be borrowed by users who have deposited WBTC/WETH liquidity as collateral via CollateralAndLiquidity.sol.
// The default initial collateralization ratio of collateral / borrowed USDS is 200%.
// The minimum default collateral ratio is 110% - below which positions can be liquidated by any user.
contract USDS is ERC20, IUSDS, Ownable
{
event USDSMinted(address indexed to, uint256 amount);
event USDSTokensBurned(uint256 amount);
ICollateralAndLiquidity public collateralAndLiquidity;
constructor()
ERC20( "USDS", "USDS" )
{
}
// This will be called only once - at deployment time
function setCollateralAndLiquidity( ICollateralAndLiquidity _collateralAndLiquidity ) external onlyOwner
{
collateralAndLiquidity = _collateralAndLiquidity;
// setCollateralAndLiquidity can only be called once
renounceOwnership();
}
// Mint USDS for users to borrow after they deposit adequate WBTC/WETH liquidity as collateral.
// Only callable by the CollateralAndLiquidity contract.
function mintTo( address wallet, uint256 amount ) external
{
require( msg.sender == address(collateralAndLiquidity), "USDS.mintTo is only callable from the Collateral contract" );
require( amount > 0, "Cannot mint zero USDS" );
_mint( wallet, amount );
emit USDSMinted(wallet, amount);
}
// USDS tokens will need to be sent here before they are burned (on a repayment or liquidation).
// There should otherwise be no USDS balance in this contract.
function burnTokensInContract() external
{
uint256 balance = balanceOf( address(this) );
_burn( address(this), balance );
emit USDSTokensBurned(balance);
}
}