SIP-112: Swap ETH for WETH in contract logic#432
SIP-112: Swap ETH for WETH in contract logic#432kaleb-keny merged 9 commits intoSynthetixio:masterfrom
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/synthetixio/sips/12kecZ4xjV9uAcnmujSLbuyiX9fq |
kaleb-keny
left a comment
There was a problem hiding this comment.
Hey all good with the changes, thank you for incorporating them, although need to ask one thing, what if the user sends both wETH and ETH at the same time... I think then the logic would be to wrap the ETH sent added to the wETH received and then proceed with the calculations? Or does it revert because it kind of adds too much complexity to dealing with summing (meaning the cost of working with the contract would increase significantly)...
Also I believe i need to amend all the test cases to incorporate the case of receiving wETH and receiving ETH. As in the latter we don't have wrapping, while in the former ETH is wrapped... What do you think? I could help with that.
Good question, I didn't clarify this. How much demand is there for paying with both WETH+ETH? My guess is towards the low end, ready to be refuted here. |
If you'd like to write the test cases, that'd be great and I'll review. I think this change is mostly technical, rather than conceptual. So let me know how much detail you think is necessary. I'm still learning about SIP's and who reads em. If it helps, here's a bit of a breakdown of the logic of accepting both: |
Yeah, i'd rather not have to deal with this complication 😅 but in case it does happen... of someone calling the contract and sending wETH and ETH at the same time, I'd rather not have any ETH locked in the contract without sETH being minted... As that would break the logic on burning sETH.... since more sETH can be burned later than is minted... |
Yeah fully agree with what you're saying here 👍 Clint and I had a bit of discussion today on #core about the design. I will probably design the contracts such that there is a base contract which only uses wETH, and then some utility code (possibly a utility contract) which allows the user to transact with ETH. This will simplify the core interactions of what we're discussing, while allowing users to still interact with ETH. What are your thoughts / do you see any problems? |
Yeah that would work I think, so just to confirm if I understood it right, the utility function is @payable and does not accept any tokens, what it can do basically wrap the ETH and sends it across to the main core wrapper function. The main core wrapper is no @payble so does not accept any ETH and can only take in wETH..... |
|
Alright after some thinking, I think it's fine if wETH is sent to the contract (without minting) and later burned ... as it'll just lower the debt on all minters... So i guess it's fine |
Test cases include the case of user depositing wETH or depositing ETH and withdrawing ETH or wETH
seems like a problem with ruby handling many levels of indentation
After the feasibility study, I decided a robust design would involve a core contract handling WETH, and a utility contract that handles native ether.
- Including bounds on burning and minting amounts - Including bounds on burnFeeRate and mintFeeRate - Including test case of minting with both ETH and WETH simultaneously
sips/sip-112.md
Outdated
|
|
||
| #### Key Bounds | ||
|
|
||
| - The upper bound on the amount of *Minting* is determined with a helper function, `capacity`, defined as `maxETH` less `wETH` locked in the contract. In case the user attempts to mint an amount greater than the upper bound, then `capacity` is minted and the residual is returned to the user (please refer to test cases for calculation specs). |
There was a problem hiding this comment.
capacity is actually max(maxETH - weth, 0) if we're to be precise?
There was a problem hiding this comment.
sure, updated the full function
sips/sip-112.md
Outdated
|
|
||
| #### Key Bounds | ||
|
|
||
| - The upper bound on the amount of *Minting* is determined with a helper function, `capacity`, defined as `maxETH` less `wETH` locked in the contract. In case the user attempts to mint an amount greater than the upper bound, then `capacity` is minted and the residual is returned to the user (please refer to test cases for calculation specs). |
There was a problem hiding this comment.
nitpick - can we use consistent naming for wETH or WETH (I prefer the latter).
There was a problem hiding this comment.
old habits die hard, 😅 all wETH changed to WETH
sips/sip-112.md
Outdated
|
|
||
| - The upper bound on the amount of *Minting* is determined with a helper function, `capacity`, defined as `maxETH` less `wETH` locked in the contract. In case the user attempts to mint an amount greater than the upper bound, then `capacity` is minted and the residual is returned to the user (please refer to test cases for calculation specs). | ||
|
|
||
| - The upper bound on the amount of *Burning* is computed as `wETH` locked in the contract multiplied `(1+burnFeeRate)` (please refer to test cases for calculation specs). |
There was a problem hiding this comment.
🙏 thanks for clarifying this one.
- Giving more scope on the capacity function - change of `wETH` to `WTH`
No description provided.