Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
534 changes: 534 additions & 0 deletions contracts/identity/IdentityV3.sol

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions contracts/token/ERC20PresetMinterPauserUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ contract ERC20PresetMinterPauserUpgradeable is
ERC20BurnableUpgradeable,
ERC20PausableUpgradeable
{
function initialize(string memory name, string memory symbol)
public
virtual
initializer
{
function initialize(
string memory name,
string memory symbol
) public virtual initializer {
__ERC20PresetMinterPauser_init(name, symbol);
}

Expand All @@ -53,7 +52,7 @@ contract ERC20PresetMinterPauserUpgradeable is
function __ERC20PresetMinterPauser_init(
string memory name,
string memory symbol
) internal initializer {
) internal onlyInitializing {
__Context_init_unchained();
__ERC165_init_unchained();
__AccessControl_init_unchained();
Expand All @@ -67,9 +66,9 @@ contract ERC20PresetMinterPauserUpgradeable is
}

function __ERC20PresetMinterPauser_init_unchained(
string memory name,
string memory symbol
) internal initializer {
string memory,
string memory
) internal onlyInitializing {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());

_setupRole(MINTER_ROLE, _msgSender());
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/GoodDollar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ contract GoodDollar is
) internal override onlyOwner {}

function decimals() public view virtual override returns (uint8) {
return 2;
return 18;
}

function setFormula(IFeesFormula _formula) external onlyOwner {
Expand Down
13 changes: 13 additions & 0 deletions contracts/token/GoodDollar2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT

import "./GoodDollar.sol";

/**
* @title The GoodDollar V2 ERC677 token contract
*/

contract GoodDollar2 is GoodDollar {
function decimals() public view virtual override returns (uint8) {
return 2;
}
}
19 changes: 0 additions & 19 deletions contracts/token/superfluid/ISuperToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -429,28 +429,9 @@ interface ISuperToken is ISuperfluidToken, TokenInfo, IERC20, IERC777 {
* ERC20x-specific Functions
*************************************************************************/

function CONSTANT_OUTFLOW_NFT() external view returns (IConstantOutflowNFT);

function CONSTANT_INFLOW_NFT() external view returns (IConstantInflowNFT);

function poolAdminNFT() external view returns (IPoolAdminNFT);

function poolMemberNFT() external view returns (IPoolMemberNFT);

/**
* @dev Constant Outflow NFT proxy created event
* @param constantOutflowNFT constant outflow nft address
*/
event ConstantOutflowNFTCreated(
IConstantOutflowNFT indexed constantOutflowNFT
);

/**
* @dev Constant Inflow NFT proxy created event
* @param constantInflowNFT constant inflow nft address
*/
event ConstantInflowNFTCreated(IConstantInflowNFT indexed constantInflowNFT);

/**************************************************************************
* Function modifiers for access control and parameter validations
*
Expand Down
23 changes: 2 additions & 21 deletions contracts/token/superfluid/SuperGoodDollar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ contract SuperGoodDollar is
IFeesFormula _formula,
IIdentity _identity,
address _feeRecipient,
address _owner,
IConstantOutflowNFT _outflowNFT,
IConstantInflowNFT _inflowNFT
address _owner
) public initializer {
initialize(IERC20(address(0)), 18, n, s);
__AccessControl_init_unchained();
Expand All @@ -82,8 +80,6 @@ contract SuperGoodDollar is
formula = _formula;
cap = _cap;
_setNFTProxyContracts(
_outflowNFT,
_inflowNFT,
IPoolAdminNFT(address(0)),
IPoolMemberNFT(address(0))
);
Expand Down Expand Up @@ -374,34 +370,19 @@ contract SuperGoodDollar is
*************************************************************************/

function setNFTProxyContracts(
IConstantOutflowNFT _constantOutflowNFT,
IConstantInflowNFT _constantInflowNFT,
IPoolAdminNFT _poolAdminNFT,
IPoolMemberNFT _poolMemberNFT
) public {
_onlyOwner();
_setNFTProxyContracts(
_constantOutflowNFT,
_constantInflowNFT,
_poolAdminNFT,
_poolMemberNFT
);
_setNFTProxyContracts(_poolAdminNFT, _poolMemberNFT);
}

function _setNFTProxyContracts(
IConstantOutflowNFT _constantOutflowNFT,
IConstantInflowNFT _constantInflowNFT,
IPoolAdminNFT _poolAdminNFT,
IPoolMemberNFT _poolMemberNFT
) internal {
CONSTANT_OUTFLOW_NFT = _constantOutflowNFT;
CONSTANT_INFLOW_NFT = _constantInflowNFT;
poolAdminNFT = _poolAdminNFT;
poolMemberNFT = _poolMemberNFT;

// emit NFT proxy creation events
emit ConstantOutflowNFTCreated(CONSTANT_OUTFLOW_NFT);
emit ConstantInflowNFTCreated(CONSTANT_INFLOW_NFT);
}

function recover(IERC20 token) public {
Expand Down
4 changes: 2 additions & 2 deletions contracts/token/superfluid/SuperToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ contract SuperToken is UUPSProxiable, SuperfluidToken, ISuperToken {
ERC777Helper.Operators internal _operators;

/// @notice Constant Outflow NFT proxy address
IConstantOutflowNFT public CONSTANT_OUTFLOW_NFT;
IConstantOutflowNFT private _unused_CONSTANT_OUTFLOW_NFT;

/// @notice Constant Inflow NFT proxy address
IConstantInflowNFT public CONSTANT_INFLOW_NFT;
IConstantInflowNFT private _unused_CONSTANT_INFLOW_NFT;

/// @notice Pool Admin NFT proxy address
IPoolAdminNFT public poolAdminNFT;
Expand Down
133 changes: 66 additions & 67 deletions contracts/token/superfluid/SuperfluidToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,14 @@ abstract contract SuperfluidToken is ISuperfluidToken {
*************************************************************************/

/// @dev ISuperfluidToken.realtimeBalanceOf implementation
function realtimeBalanceOf(address account, uint256 timestamp)
function realtimeBalanceOf(
address account,
uint256 timestamp
)
public
view
override
returns (
int256 availableBalance,
uint256 deposit,
uint256 owedDeposit
)
returns (int256 availableBalance, uint256 deposit, uint256 owedDeposit)
{
availableBalance = _sharedSettledBalances[account];
ISuperAgreement[] memory activeAgreements = getAccountActiveAgreements(
Expand Down Expand Up @@ -105,7 +104,9 @@ abstract contract SuperfluidToken is ISuperfluidToken {
}

/// @dev ISuperfluidToken.realtimeBalanceOfNow implementation
function realtimeBalanceOfNow(address account)
function realtimeBalanceOfNow(
address account
)
public
view
override
Expand All @@ -116,38 +117,35 @@ abstract contract SuperfluidToken is ISuperfluidToken {
uint256 timestamp
)
{
timestamp = _host.getNow();
timestamp = address(_host) != address(0) ? _host.getNow() : block.timestamp;
(availableBalance, deposit, owedDeposit) = realtimeBalanceOf(
account,
timestamp
address(_host) != address(0) ? _host.getNow() : block.timestamp
);
}

function isAccountCritical(address account, uint256 timestamp)
public
view
override
returns (bool isCritical)
{
function isAccountCritical(
address account,
uint256 timestamp
) public view override returns (bool isCritical) {
(int256 availableBalance, , ) = realtimeBalanceOf(account, timestamp);
return availableBalance < 0;
}

function isAccountCriticalNow(address account)
external
view
override
returns (bool isCritical)
{
return isAccountCritical(account, _host.getNow());
function isAccountCriticalNow(
address account
) external view override returns (bool isCritical) {
return
isAccountCritical(
account,
address(_host) != address(0) ? _host.getNow() : block.timestamp
);
}

function isAccountSolvent(address account, uint256 timestamp)
public
view
override
returns (bool isSolvent)
{
function isAccountSolvent(
address account,
uint256 timestamp
) public view override returns (bool isSolvent) {
(
int256 availableBalance,
uint256 deposit,
Expand All @@ -159,23 +157,24 @@ abstract contract SuperfluidToken is ISuperfluidToken {
return realtimeBalance >= 0;
}

function isAccountSolventNow(address account)
external
view
override
returns (bool isSolvent)
{
return isAccountSolvent(account, _host.getNow());
function isAccountSolventNow(
address account
) external view override returns (bool isSolvent) {
return
isAccountSolvent(
account,
address(_host) != address(0) ? _host.getNow() : block.timestamp
);
}

/// @dev ISuperfluidToken.getAccountActiveAgreements implementation
function getAccountActiveAgreements(address account)
public
view
override
returns (ISuperAgreement[] memory)
{
return _host.mapAgreementClasses(~_inactiveAgreementBitmap[account]);
function getAccountActiveAgreements(
address account
) public view override returns (ISuperAgreement[] memory) {
return
address(_host) != address(0)
? _host.mapAgreementClasses(~_inactiveAgreementBitmap[account])
: new ISuperAgreement[](0);
}

/**************************************************************************
Expand All @@ -190,7 +189,10 @@ abstract contract SuperfluidToken is ISuperfluidToken {
}

function _burn(address account, uint256 amount) internal {
(int256 availableBalance, , ) = realtimeBalanceOf(account, _host.getNow());
(int256 availableBalance, , ) = realtimeBalanceOf(
account,
address(_host) != address(0) ? _host.getNow() : block.timestamp
);
if (availableBalance < amount.toInt256()) {
revert SF_TOKEN_BURN_INSUFFICIENT_BALANCE();
}
Expand All @@ -200,12 +202,11 @@ abstract contract SuperfluidToken is ISuperfluidToken {
_totalSupply = _totalSupply - amount;
}

function _move(
address from,
address to,
int256 amount
) internal {
(int256 availableBalance, , ) = realtimeBalanceOf(from, _host.getNow());
function _move(address from, address to, int256 amount) internal {
(int256 availableBalance, , ) = realtimeBalanceOf(
from,
address(_host) != address(0) ? _host.getNow() : block.timestamp
);
if (availableBalance < amount) {
revert SF_TOKEN_MOVE_INSUFFICIENT_BALANCE();
}
Expand All @@ -227,11 +228,10 @@ abstract contract SuperfluidToken is ISuperfluidToken {
*************************************************************************/

/// @dev ISuperfluidToken.createAgreement implementation
function createAgreement(bytes32 id, bytes32[] calldata data)
public
virtual
override
{
function createAgreement(
bytes32 id,
bytes32[] calldata data
) public virtual override {
address agreementClass = msg.sender;
bytes32 slot = keccak256(abi.encode("AgreementData", agreementClass, id));
if (FixedSizeData.hasData(slot, data.length)) {
Expand All @@ -252,21 +252,21 @@ abstract contract SuperfluidToken is ISuperfluidToken {
}

/// @dev ISuperfluidToken.updateAgreementData implementation
function updateAgreementData(bytes32 id, bytes32[] calldata data)
external
override
{
function updateAgreementData(
bytes32 id,
bytes32[] calldata data
) external override {
address agreementClass = msg.sender;
bytes32 slot = keccak256(abi.encode("AgreementData", agreementClass, id));
FixedSizeData.storeData(slot, data);
emit AgreementUpdated(msg.sender, id, data);
}

/// @dev ISuperfluidToken.terminateAgreement implementation
function terminateAgreement(bytes32 id, uint256 dataLength)
external
override
{
function terminateAgreement(
bytes32 id,
uint256 dataLength
) external override {
address agreementClass = msg.sender;
bytes32 slot = keccak256(abi.encode("AgreementData", agreementClass, id));
if (!FixedSizeData.hasData(slot, dataLength)) {
Expand Down Expand Up @@ -303,11 +303,10 @@ abstract contract SuperfluidToken is ISuperfluidToken {
}

/// @dev ISuperfluidToken.settleBalance implementation
function settleBalance(address account, int256 delta)
external
override
onlyAgreement
{
function settleBalance(
address account,
int256 delta
) external override onlyAgreement {
_sharedSettledBalances[account] = _sharedSettledBalances[account] + delta;
}

Expand Down
Loading
Loading