Skip to content

Commit

Permalink
Merge pull request #582 from mysofinance/statemind-resubmission
Browse files Browse the repository at this point in the history
Statemind resubmission
  • Loading branch information
jpick713 authored Aug 9, 2023
2 parents 92e89ae + 93bf122 commit 141d514
Show file tree
Hide file tree
Showing 16 changed files with 1,909 additions and 118 deletions.
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ contracts/
┃ ┃ ┃ ┣ IDSETH.sol
┃ ┃ ┃ ┣ IOlympus.sol
┃ ┃ ┃ ┗ IUniV2.sol
┃ ┃ ┣ policyManagers/
┃ ┃ ┃ ┣ IBasicQuotePolicyManager.sol
┃ ┃ ┃ ┗ IQuotePolicyManager.sol
┃ ┃ ┣ wrappers/
┃ ┃ ┃ ┣ ERC20/
┃ ┃ ┃ ┃ ┣ IERC20Wrapper.sol
Expand Down Expand Up @@ -81,6 +84,9 @@ contracts/
┃ ┃ ┣ OracleLibrary.sol
┃ ┃ ┣ TickMath.sol
┃ ┃ ┗ TwapGetter.sol
┃ ┣ policyManagers/
┃ ┃ ┣ BasicQuotePolicyManager.sol
┃ ┃ ┗ DataTypesBasicPolicies.sol
┃ ┣ wrappers/
┃ ┃ ┣ ERC20/
┃ ┃ ┃ ┣ ERC20Wrapper.sol
Expand Down Expand Up @@ -164,13 +170,13 @@ File | % Stmts | % Branch |
Helpers.sol | 100 | 50 | 100 | 100 | |
contracts\interfaces\ | 100 | 100 | 100 | 100 | |
IMysoTokenManager.sol | 100 | 100 | 100 | 100 | |
contracts\peer-to-peer\ | 99.72 | 94.74 | 98.72 | 98.75 | |
AddressRegistry.sol | 100 | 96.74 | 100 | 99.17 | 116 |
contracts\peer-to-peer\ | 99.74 | 94.61 | 98.84 | 98.66 | |
AddressRegistry.sol | 100 | 96.74 | 100 | 99.17 | 117 |
BorrowerGateway.sol | 98.57 | 90.91 | 90.91 | 96.97 | 241,317,358 |
DataTypesPeerToPeer.sol | 100 | 100 | 100 | 100 | |
LenderVaultFactory.sol | 100 | 87.5 | 100 | 100 | |
LenderVaultImpl.sol | 100 | 92.86 | 100 | 98.88 | 63,206 |
QuoteHandler.sol | 100 | 98.04 | 100 | 99.34 | 365 |
LenderVaultImpl.sol | 100 | 93.1 | 100 | 98.92 | 64,207 |
QuoteHandler.sol | 100 | 96.83 | 100 | 98.91 | 266,478 |
contracts\peer-to-peer\callbacks\ | 100 | 75 | 88.89 | 96.88 | |
BalancerV2Looping.sol | 100 | 100 | 100 | 100 | |
UniV3Looping.sol | 100 | 100 | 100 | 100 | |
Expand Down Expand Up @@ -209,6 +215,9 @@ File | % Stmts | % Branch |
AggregatorV3Interface.sol | 100 | 100 | 100 | 100 | |
contracts\peer-to-peer\interfaces\oracles\uniswap\ | 100 | 100 | 100 | 100 | |
ITwapGetter.sol | 100 | 100 | 100 | 100 | |
contracts\peer-to-peer\interfaces\policyManagers\ | 100 | 100 | 100 | 100 | |
IBasicQuotePolicyManager.sol | 100 | 100 | 100 | 100 | |
IQuotePolicyManager.sol | 100 | 100 | 100 | 100 | |
contracts\peer-to-peer\interfaces\wrappers\ERC20\ | 100 | 100 | 100 | 100 | |
IERC20Wrapper.sol | 100 | 100 | 100 | 100 | |
IWrappedERC20Impl.sol | 100 | 100 | 100 | 100 | |
Expand All @@ -229,6 +238,9 @@ File | % Stmts | % Branch |
OracleLibrary.sol | 100 | 66.67 | 100 | 100 | |
TickMath.sol | 100 | 80.43 | 100 | 84.09 |... 63,65,67,73 |
TwapGetter.sol | 100 | 62.5 | 100 | 93.33 | 57 |
contracts\peer-to-peer\policyManagers\ | 100 | 100 | 100 | 100 | |
BasicQuotePolicyManager.sol | 100 | 100 | 100 | 100 | |
DataTypesBasicPolicies.sol | 100 | 100 | 100 | 100 | |
contracts\peer-to-peer\wrappers\ERC20\ | 100 | 83.33 | 100 | 98.88 | |
ERC20Wrapper.sol | 100 | 75 | 100 | 96.88 | 45 |
WrappedERC20Impl.sol | 100 | 89.29 | 100 | 100 | |
Expand All @@ -245,6 +257,6 @@ File | % Stmts | % Branch |
IFundingPoolImpl.sol | 100 | 100 | 100 | 100 | |
ILoanProposalImpl.sol | 100 | 100 | 100 | 100 | |
---------------------------------------------------------|----------|----------|----------|----------|----------------|
All files | 98.99 | 88.83 | 98.63 | 96.8 | |
All files | 99.07 | 89.56 | 98.74 | 96.97 | |
---------------------------------------------------------|----------|----------|----------|----------|----------------|
```
8 changes: 8 additions & 0 deletions contracts/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,12 @@ library Errors {
error TokenNotOwnedByWrapper();
error TokenDoesNotBelongInWrapper(address tokenAddr, uint256 tokenId);
error InvalidMintAmount();
error QuoteViolatesPolicy();
error AlreadyPublished();
error PolicyAlreadySet();
error NoPolicyToDelete();
error InvalidTenors();
error InvalidLoanPerCollOrLtv();
error InvalidMinApr();
error NoPolicy();
}
1 change: 1 addition & 0 deletions contracts/peer-to-peer/AddressRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ contract AddressRegistry is Initializable, Ownable2Step, IAddressRegistry {
address public borrowerGateway;
address public quoteHandler;
address public mysoTokenManager;
address public quotePolicyManager;
address public erc721Wrapper;
address public erc20Wrapper;
mapping(address => bool) public isRegisteredVault;
Expand Down
11 changes: 10 additions & 1 deletion contracts/peer-to-peer/DataTypesPeerToPeer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ library DataTypesPeerToPeer {
uint256 tokenAmount;
}

struct OnChainQuoteInfo {
// hash of on chain quote
bytes32 quoteHash;
// valid until timestamp
uint256 validUntil;
}

enum WhitelistState {
// not whitelisted
NOT_WHITELISTED,
Expand All @@ -175,6 +182,8 @@ library DataTypesPeerToPeer {
// can be used as ERC20 wrapper contract
ERC20WRAPPER,
// can be used as MYSO token manager contract
MYSO_TOKEN_MANAGER
MYSO_TOKEN_MANAGER,
// can be used as quote policy manager contract
QUOTE_POLICY_MANAGER
}
}
24 changes: 24 additions & 0 deletions contracts/peer-to-peer/LenderVaultImpl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ contract LenderVaultImpl is
address[] public signers;
address public circuitBreaker;
address public reverseCircuitBreaker;
address public onChainQuotingDelegate;
uint256 public minNumOfSigners;
mapping(address => bool) public isSigner;
bool public withdrawEntered;
Expand Down Expand Up @@ -366,6 +367,25 @@ contract LenderVaultImpl is
);
}

function setOnChainQuotingDelegate(
address newOnChainQuotingDelegate
) external {
_checkOwner();
address oldOnChainQuotingDelegate = onChainQuotingDelegate;
// delegate is allowed to be a signer, unlike owner, circuit breaker or reverse circuit breaker
if (
newOnChainQuotingDelegate == oldOnChainQuotingDelegate ||
newOnChainQuotingDelegate == owner()
) {
revert Errors.InvalidAddress();
}
onChainQuotingDelegate = newOnChainQuotingDelegate;
emit OnChainQuotingDelegateUpdated(
newOnChainQuotingDelegate,
oldOnChainQuotingDelegate
);
}

function pauseQuotes() external {
if (msg.sender != circuitBreaker && msg.sender != owner()) {
revert Errors.InvalidSender();
Expand Down Expand Up @@ -394,6 +414,10 @@ contract LenderVaultImpl is
return _loans.length;
}

function totalNumSigners() external view returns (uint256) {
return signers.length;
}

function getTokenBalancesAndLockedAmounts(
address[] calldata tokens
)
Expand Down
Loading

0 comments on commit 141d514

Please sign in to comment.