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

Kinked Swap Pool #105

Closed
wants to merge 17 commits into from
Closed

Kinked Swap Pool #105

wants to merge 17 commits into from

Conversation

hexonaut
Copy link
Contributor

@hexonaut hexonaut commented Mar 17, 2023

NOTE: This is no longer needed. Leaving in case someone needs a kinked pool in the future. Pools that will be used have been merged into ALM Controller PR: #104

psm-2 0-design

This will merge the PSM into the D3M design by pre-minting the DAI into the swap pool. The pool will be designed to target a particular desired exposure to an asset and use negative fees to pay arbitragers to fill the pool.

Contains the following new features beyond the original PSM:

  • DAI is pre-minted into the swap contract via D3M. This will save a lot of gas and is standard for D3M interfaces.

psm-2 0-oracles

  • Swaps are performed at an Oracle price instead of 1:1 with a buy and sell oracle.
  • No more dealing with fees inside the PSM. Using standard assetBalance() to return market valuation and the D3MHub will compare assets vs liabilities to determine how much to send to surplus buffer (or take back).

psm-2 0-ratio-targeting

  • ratio parameter is added to set a desired gem/dai ratio. Additionally tin and tout are split into two versions (one for below the desired gem/dai ratio and one above). This serves a few use cases:
  1. Tokens that are being used as investments we want ways for arbitragers to wind them to desired levels by using negative fees.
  2. Having an extra buffer allows for payments in the token itself. For example, Gemini can just send GUSD tokens to the swap contract to automatically transfer the value to the surplus buffer via D3M asset/liability accounting. Arbitragers would then be able to periodically clear it out back to the target ratio level (where the tout fee would switch to a higher value to prevent full unwind). In the GUSD case this would be like keeping 490m GUSD and 10m DAI so that interest can be paid periodically without going over the 500m debt ceiling.
  3. For USDC where we may want to increase the redemption price a ratio can be set to some low amount say 40% where if the gem/dai ratio drops below this then the tout increases to a larger number for market price discovery.

Uses:

  • Backed Finance bTokens
  • Ondo OUSG
  • GUSD

@hexonaut hexonaut changed the base branch from master to add-debt-ceiling-plan March 21, 2023 11:00
@hexonaut hexonaut self-assigned this Mar 21, 2023
@chechu
Copy link

chechu commented Apr 10, 2023

Great PR, thanks for sharing it. I was trying to understand the Oracles graph, and I had some doubts:

(I will ignore fees in every case, assuming they don't exist)

  • top-left. Applicable when the user sends DAI to the contract and receives the Gem (i.e. USDC), right? My understanding is: if the USDC market price is $0.5, and the user sends 1 DAI, the PSM will send to the user 2 USDC. But if the market price of USDC is $1.5 and the user sends 1 DAI, the PSM will send to the user 1 USDC. Is that correct?
  • top-right. Applicable when the user sends Gem (i.e. USDC) to the contract and receives DAI, right? My understanding is: if the USDC market price is $1.5, and the user sends 1 USDC, the PSM will send to the user 1.5 DAI. But if the market price of USDC is $0.5 and the user sends 1 USDC, the PSM will send to the user 1 DAI. Is that correct?
  • in the bottom graphs, what NAV means?

Thanks again ❤️

@hexonaut
Copy link
Contributor Author

hexonaut commented Apr 11, 2023

The directions are the opposite. It's from the protocol's perspective on how much to pay for buying a gem in the top left (say USDC).

NAV = Net Asset Value, the book value of the assets in this example.

@hexonaut hexonaut changed the base branch from add-debt-ceiling-plan to master April 11, 2023 08:19
@hexonaut hexonaut changed the title Add PSM swap pool Add PSM swap pools Apr 11, 2023
@hexonaut hexonaut changed the base branch from master to add-debt-ceiling-plan April 11, 2023 09:02
@hexonaut hexonaut changed the title Add PSM swap pools Kinked Swap Pool Apr 12, 2023
@lucas-manuel
Copy link
Contributor

Closing with permission from @hexonaut

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

Successfully merging this pull request may close these issues.

3 participants