Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statemind resubmission #582

Merged
merged 55 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
107487e
changed update and delete on chain quote to use hash and store in arr…
jpick713 Jul 21, 2023
823acd3
updated function name
jpick713 Jul 21, 2023
d73cfba
added fixes for myso-26
asardon Jul 21, 2023
102b2ef
added bounds check in getter
jpick713 Jul 21, 2023
5cd4ed6
Merge pull request #576 from mysofinance/quote-hash-getter-updates
jpick713 Jul 21, 2023
984b157
added in quote policy manager changes
jpick713 Jul 26, 2023
07cecf2
add if pending borrow is on chain or off chain
jpick713 Jul 26, 2023
c784d79
remove quote policy as singleton
jpick713 Jul 26, 2023
1c61616
updated to have quote policy manager not be a multi-sig
jpick713 Jul 26, 2023
38be264
added tests for vault impl
jpick713 Jul 26, 2023
6b05bbc
added test quote policy contract and event
jpick713 Jul 26, 2023
42b981d
add note in function
jpick713 Jul 26, 2023
641a137
added to tests on quote policy
jpick713 Jul 26, 2023
884ab23
removed check of policy on quote
jpick713 Jul 26, 2023
ed17ebd
edit note
jpick713 Jul 26, 2023
d510d37
updated names, comments and removed ability to edit off chain functions
jpick713 Jul 27, 2023
c7c8380
added suggested edits
jpick713 Aug 1, 2023
2cb1d01
added proposal and approved quote functions
jpick713 Aug 1, 2023
14d08e4
added simple policy manager contract
jpick713 Aug 2, 2023
fb6a283
added note
jpick713 Aug 2, 2023
2135bf0
added another note
jpick713 Aug 2, 2023
5543f60
add setter for default policy
jpick713 Aug 2, 2023
b4ad70e
edited check when no policy applies
jpick713 Aug 2, 2023
06b7a6e
renamed policy members to be more in line with other names
jpick713 Aug 2, 2023
16564bf
added test for proposed and approved on chain quotes
jpick713 Aug 2, 2023
ea06363
added tests and edited internal function name
jpick713 Aug 3, 2023
1572ba9
edited simple policy test
jpick713 Aug 3, 2023
f19260f
added more tests for policy
jpick713 Aug 3, 2023
8b0afeb
edited propose functions, moved events, structs and errors into other…
jpick713 Aug 4, 2023
36b82d6
edited check for annualizing with respect to tenor
jpick713 Aug 4, 2023
1f4a6c1
simplified quote policy manager
asardon Aug 6, 2023
628c5ad
remove structs
asardon Aug 6, 2023
62649c4
minor renamings
asardon Aug 6, 2023
82cfe0e
minor renaming
asardon Aug 6, 2023
6ad068b
minor renaming
asardon Aug 6, 2023
87a1ec4
incorporated discussion feedback
asardon Aug 7, 2023
c78c7b1
minor renaming
asardon Aug 7, 2023
dc4d040
minor renaming and added inline comment
asardon Aug 7, 2023
b676db2
incorporated feedback
asardon Aug 8, 2023
68f6a3f
delete global quoting policy flag on delete
asardon Aug 8, 2023
e4a637b
incorporated feedback
asardon Aug 8, 2023
58820b6
added check for earliest repay > 0 when comparing apr
asardon Aug 8, 2023
28c1c91
added check for earliest repay == 0 and apr < 0
asardon Aug 8, 2023
c977e10
incorporated feedback
asardon Aug 8, 2023
aac27ad
added in fix for first quote manager test renaming
jpick713 Aug 8, 2023
c301bb2
added global requires oracle flag
jpick713 Aug 8, 2023
da873c4
added getters
asardon Aug 8, 2023
173a750
Merge pull request #580 from mysofinance/policy-manager-add-tests-1
asardon Aug 8, 2023
bbc888e
slighlty simplified global vs pair policy checks
asardon Aug 8, 2023
630b96f
added tests for global policy
jpick713 Aug 8, 2023
2869ef5
added tests for policy with oracles
asardon Aug 8, 2023
d2f53e7
Merge pull request #581 from mysofinance/add-policy-manager-tests-2
asardon Aug 8, 2023
1d21494
added tests for deleting policies
asardon Aug 8, 2023
5a3d5d3
added swap case and updated readme
asardon Aug 8, 2023
93bf122
Merge pull request #579 from mysofinance/policy-manager-simplified
asardon Aug 8, 2023
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
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