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

MYSO-27: Allow delegation of on-chain quotes #583

Open
asardon opened this issue Aug 8, 2023 · 2 comments · Fixed by #582
Open

MYSO-27: Allow delegation of on-chain quotes #583

asardon opened this issue Aug 8, 2023 · 2 comments · Fixed by #582
Assignees

Comments

@asardon
Copy link
Member

asardon commented Aug 8, 2023

Description

Currently, only the vault owners themselves are authorized to produce on-chain quotes. However, to improve convenience and onboard more users, vault owners may want to delegate on-chain quoting to designated 3rd parties (similarly to off-chain quoting). In addition, even in case without 3rd party delegation, vault owners may want to separate their vault owner wallet from a wallet they use to produce on-chain quotes. This way they can store their vault owner key in a cold wallet which they only use from time to time and in parallel have a hot wallet for on-chain quoting which they use more frequently and only for on-chain quoting.

Recommendation

Allow vault owners to delegate on-chain quoting to an on-chain quoting account.

@asardon asardon self-assigned this Aug 8, 2023
@asardon asardon linked a pull request Aug 8, 2023 that will close this issue
@asardon
Copy link
Member Author

asardon commented Aug 8, 2023

Implementation

This has been implemented through the following function:

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
);
}

Moreover, a clearer segregation of duties has been introduced, ie while adding, updating and deleting on-chain quotes can be done both by the vault owner and the given on-chain quote delegate, any incrementing of the off-chain quote nonce can only be done by the vault owner:

function incrementOffChainQuoteNonce(address lenderVault) external {
_checkIsVaultAndSenderIsApproved(lenderVault, true);

@asardon
Copy link
Member Author

asardon commented Aug 8, 2023

Additional Improvements

In order to streamline the process for on-chain quoting with delegates two additional convenience functions were added, ie:

function publishOnChainQuote(
DataTypesPeerToPeer.OnChainQuote calldata onChainQuote
) external {
if (!_isValidOnChainQuote(onChainQuote)) {
revert Errors.InvalidQuote();
}
bytes32 onChainQuoteHash = _hashOnChainQuote(onChainQuote);
if (isPublishedOnChainQuote[onChainQuoteHash]) {
revert Errors.AlreadyPublished();
}
isPublishedOnChainQuote[onChainQuoteHash] = true;
emit OnChainQuotePublished(onChainQuote, onChainQuoteHash, msg.sender);

as well as:

function copyPublishedOnChainQuote(
address lenderVault,
bytes32 onChainQuoteHash
) external {
_checkIsVaultAndSenderIsApproved(lenderVault, false);
mapping(bytes32 => bool)
storage isOnChainQuoteFromVault = isOnChainQuote[lenderVault];
if (
!isPublishedOnChainQuote[onChainQuoteHash] ||
isOnChainQuoteFromVault[onChainQuoteHash]
) {
revert Errors.InvalidQuote();
}
isOnChainQuoteFromVault[onChainQuoteHash] = true;
emit OnChainQuoteCopied(lenderVault, onChainQuoteHash);
}

The rationale behind this is that if the on-chain quoting delegate is a multisig then approving a potentially complex onchain quote struct object via gnosis multisig can create significant friction. Hence, to make this easier the publishOnChainQuote method can be used to publish/stage an on-chain quote (note, this function can be called by anyone as published quotes don't take any effect on any vaults directly). To be more specific, if there's a multisig where multiple users need to sign an on-chain quote then the initiator could propose a quote via publishOnChainQuote and then we can make the quote easily inspectable via the MYSO UI (ie using a shareable link). Once all co-signers then inspected and verified the correctness of the given published on-chain quote they can then proceed to the gnosis vault app to then call the copyPublishedOnChainQuote and only need to compare the onChainQuoteHash on the gnosis vault app with the corresponding onChainQuoteHash seen on the more detailed MYSO UI which shows the underlying quote struct. Moreover, the publish/copy mechanism can also be used by the community to share interesting quotes with the community and then make it easy for others to copy a given quote through shareable links on our dApp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant