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

Add Collateral Swap Extension #29

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

sraver
Copy link

@sraver sraver commented Jun 16, 2023

Context

The Wido team (https://www.joinwido.com/) is submitting this PR to add a Collateral Swap extension for Compound v3. This work was created as part of the CGP grants.

More context about this work has been posted on the Compound Forum.

Sandbox

You can play with the extension here: https://app.compound.finance/extensions/sandbox?market=usdc-mainnet&sandboxsource=https%3A%2F%2Ffleek.ipfs.io%2Fipfs%2FQmQjT6NRo4Hvj7ZGdfA5UMLzN9ZSveN2oxQykugKZoFhgV%2Fembedded.html

Curation and Safety

Our answers to the Curation and Safety Questions can be found in the Forum Post.

Links to accompanying code

@sraver sraver marked this pull request as draft June 17, 2023 08:43
@sraver sraver marked this pull request as ready for review June 22, 2023 12:23
@ajb413 ajb413 requested a review from kevincheng96 July 14, 2023 17:22
Copy link
Contributor

@kevincheng96 kevincheng96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really neat extension! I have a few comments regarding the extension UI:

  1. In the warning banner at the top, it would be good to explicitly call out that the contracts have not been audited yet.

Screen Shot 2023-07-14 at 11 15 14 AM
The numbers are difficult to read, so I suggest adding comma separators or using abbreviations (K, M, B, etc.).
3. It's nice that the extension displays the expected amount of new collateral I'll receive as well as the position summary after the swap. I think it would be useful to also see the exchange rate I'm getting for the collateral. e.g. what's the MATIC / WETH price or the dollar price of MATIC that I am getting with this swap
4. The information toggle next to the fees is not working for me.

@kevincheng96 kevincheng96 changed the title Add Collataral Swap Extension Add Collateral Swap Extension Jul 14, 2023
@torreyatcitty
Copy link
Contributor

Cool stuff, I noticed 2 things.

  1. Could we update this info text when the user is not on the correct wallet network or the correct Compound market selected?
Screen Shot 2023-07-14 at 12 10 14 PM

Maybe something like Please ensure both the correct Compound Market is selected and your wallet is connected to the same network

We ran into some user error testing getting the extension to enable first time.

  1. I noticed the following error when trying to do a swap. My swap eventually worked but I've attached a video and text dump of the error:
wido-swap-bug.mov

wido-swap-bug.txt

sign: '*',
},
source: {
url: "https://wido-extension-template.vercel.app/embedded.html"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use an ipfs link instead? See the comet_migrator extension above for an example of how to configure it.

Copy link

@mazurroman mazurroman Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be acceptable to use our backend to serve the "Beta" version, and only deploy the final version to IPFS?

Please let us know if deploying to IPFS even for the Beta launch is necessary and we will do that.

Note: In this post, we proposed the Beta to run for 1 month, in which we would collect feedback. After incorporating the feedback we can launch the final version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just spoke with the team about this and we think using IPFS links is necessary. Even though most third-party devs like yourself that are taking the time to build extensions are probably very trustworthy, we want to remove that layer of trust altogether and make sure that whatever is approved as an extension can't be changed without another set of approvals.

@mazurroman
Copy link

mazurroman commented Jul 18, 2023

Hey @ajb413 @kevincheng96 @torreyatcitty thank you for your reviews. We will follow up soon

@kevincheng96 regarding your point 4: information toggle next to the fees is not working. Try hovering for longer time, the info should popup. We currently use browser's native way to display that info and it only works with hover. Is there a UI component by Compound that we could reuse for this element, to avoid building custom one?

@kevincheng96
Copy link
Contributor

Try hovering for longer time, the info should popup. We currently use browser's native way to display that info and it only works with hover. Is there a UI component by Compound that we could reuse for this element, to avoid building custom one?

Ah I see, I had to hover for a couple of seconds, but am able to see it now. Btw the cursor turns into the clickable icon when hovering over it, so may be another small fix that should be done. I don't think we currently have a custom toggle component, but will let @torreyatcitty confirm.

@torreyatcitty
Copy link
Contributor

Hey @ajb413 @kevincheng96 @torreyatcitty thank you for your reviews. We will follow up soon

@kevincheng96 regarding your point 4: information toggle next to the fees is not working. Try hovering for longer time, the info should popup. We currently use browser's native way to display that info and it only works with hover. Is there a UI component by Compound that we could reuse for this element, to avoid building custom one?

We have a custom built tooltip component in our app that's probably a little too highly coupled with our architecture to just send over as is. Are you using React to build the front end?

Another super easy way if it's nothing fancy is to just do it all in css like it's done here: https://www.w3schools.com/css/tryit.asp?filename=trycss_tooltip

@mazurroman
Copy link

We resolved all the issues mentioned above, namely:

Resolved issues (raised by @kevincheng96):

Warning banner at the top should contain Audit info

It now looks like this:

image

Comma separators to make numbers easier to read

It now looks like this:

image

Add exchange rate

It now looks like this:
image

Fix info toggle

Resolved issues (raised by @torreyatcitty)

Update tech to switch wallet to correct network

It now looks like this:
image

Fix error when trying to swap

Next steps: final review & deployment to IPFS

@kevincheng96 mentioned to deploy the UI to IPFS. We propose to do that as the final step in this PR, right before it gets merged.

@kevincheng96 @torreyatcitty Can we kindly ask you for another round of reviews and if everything is now good from your side (except for deploying to IPFS)? Once you confirm, we will deploy to IPFS and ask you to merge this PR.

Note: Thank you @torreyatcitty for your hint on the CSS tooltip. We ended up using it.

@kevincheng96
Copy link
Contributor

@kevincheng96 @torreyatcitty Can we kindly ask you for another round of reviews and if everything is now good from your side (except for deploying to IPFS)?

The fixes in the UI look good to me.

@torreyatcitty
Copy link
Contributor

Cool, confirmed the fixes look good to me also.

@mazurroman
Copy link

mazurroman commented Aug 7, 2023

@torreyatcitty @kevincheng96 thank you for your reviews, glad to hear it's all good!

We will now proceed to deploying to IPFS so that this PR can be merged and the Collateral Swap Extension is launched as BETA.

Will also plan some marketing around this to ensure people see it and try it out, hopefully with help from the Compound marketing team (@ajb413 for visibility)

Comment on lines +70 to +76
trx: [
{
contract: '$operator',
abi: 'swapCollateral((address,uint256),(address,uint256),((uint8,bytes32,bytes32),(uint8,bytes32,bytes32)),(address,address,bytes),address)',
params: '*'
}
]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevincheng96 @hayesgm @mykelp I have added the required permission for the app to execute the transaction. Could you verify that it looks fine? I am most interested in the contract: '$operator' line, since I'm not sure what the "$operator" placeholder is replaced with.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the trx object does look ok to me. $operator is meant to signal your smart contract and you do look to have it specified correctly. What error are you currently getting?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@torreyatcitty thanks, with this changes it should work fine then.

Currently the issue is that the deployed version didn't include the trx permissions, so it's failing at the time of actually executing the transaction.

On the embedded sandbox it works fine, with or without the permissions, but once deployed it gets blocked without them.

Being this correct, I think next step would be to re-deploy so it takes the right permissions on the prod app?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah i see, yes the current version on prod does not have the trx permission. Will share an updated test build with the newer permission.

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 this pull request may close these issues.

6 participants