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

[SC-466] Add testing support psm variant 2 #6

Merged
merged 10 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added .assets/user-actions-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 30 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,56 @@ These contracts will be deployed at well-known addresses to be used across the M

## Top Level Actions Mapping

### Ethereum (pre-NST launch)
![Actions Mapping](./.assets/user-actions-overview.png)

### Ethereum (Original PSM - Variant 1)

DAI <-> sDAI: sDAI ERC-4626 interface
USDC <-> DAI: Use PSM directly
USDC <-> sDAI: PSMVariant1Actions

### Ethereum (PSM Lite - Variant 2)

DAI <-> sDAI: sDAI ERC-4626 interface
USDC <-> DAI: Use PSM directly
USDC <-> sDAI: PSMVariant1Actions

### Ethereum (post-NST launch)
*Note: No code changes are needed. Only a redeploy of `PSMVariant1Actions`.*

### Ethereum (PSM Wrapper - Variant 3)

NST <-> sNST: sNST ERC-4626 interface
USDC <-> NST: [NstPsmWrapper](https://github.com/makerdao/nst-wrappers/blob/dev/src/NstPsmWrapper.sol)
USDC <-> sNST: PSMVariant1Actions (future iterations)
DAI <-> NST: PSMVariant1Actions (future iterations)
sDAI <-> NST: PSMVariant1Actions (future iterations)
DAI <-> sNST: PSMVariant1Actions (future iterations)
sDAI <-> sNST: PSMVariant1Actions (future iterations)
USDC <-> sNST: PSMVariant1Actions

NST <-> NGT Farm: Directly deposit
USDC <-> NGT Farm: PSMVariant1Actions (future iterations)
NST <-> SPK Farm: Directly deposit
USDC <-> SPK Farm: PSMVariant1Actions (future iterations)
NST <-> Farms: Directly deposit/withdraw

### Ethereum (Migration Actions)

DAI <-> NST: MigrationActions
sDAI -> NST: MigrationActions
DAI -> sNST: MigrationActions
sDAI -> sNST: MigrationActions

### Non-Ethereum chains

A three-way PSM will be provided here: https://github.com/marsfoundation/spark-psm. This can be used directly by UIs.

NST <-> sNST: Swap in PSM
USDC <-> NST: Swap in PSM
USDC <-> sNST: PSMVariant2Actions (to deal with dust)
USDC <-> sNST: Swap in PSM

NST <-> NGT Farm: Directly deposit
USDC <-> NGT Farm: PSMVariant2Actions
NST <-> SPK Farm: Directly deposit
USDC <-> SPK Farm: PSMVariant2Actions
NST <-> Farms: Directly deposit/withdraw

## PSMVariant1Actions

Intended to be used with the first version of the USDC PSM at `0x89B78CfA322F6C5dE0aBcEecab66Aee45393cC5A` and sDAI. This contract will not support NST, sNST. It is expected that the upgrade to the second verison of the USDC PSM will be done before the launch of these tokens.
Intended to be used with the first version of the USDC PSM at `0x89B78CfA322F6C5dE0aBcEecab66Aee45393cC5A` and sDAI, but also compatible with the newer lite psm and NST wrapper.

The code is written in a general way, but it is expected for this to be used with the USDC PSM and sDAI. Please note that all values are measured in either USDC or DAI and not sDAI shares. This keeps the UI simple in that you can specify `100e18` of sDAI to mean "100 DAI worth of sDAI" instead of doing the share conversion.

Deployed at: [0x52d298ff9e77e71c2eb1992260520e7b15257d99](https://etherscan.io/address/0x52d298ff9e77e71c2eb1992260520e7b15257d99)

Please note this variant is also compatible with the new [dss-lite-psm](https://github.com/makerdao/dss-lite-psm), so another deployment will be made after it is live.
Deployed at (Original PSM): [0x52d298ff9e77e71c2eb1992260520e7b15257d99](https://etherscan.io/address/0x52d298ff9e77e71c2eb1992260520e7b15257d99)
Deployed at (PSM Lite): TBD
Deployed at (NST PSM Wrapper): TBD

### swapAndDeposit

Expand Down Expand Up @@ -130,14 +137,11 @@ actions.redeemAndSwap(address(this), bal, sDAI.convertToAssets(bal));
// User has withdrawn as much USDC as possible
```

## PSMVariant2Actions

TODO. Intended to be used with the third version of the USDC PSM located at https://github.com/marsfoundation/spark-psm. This is intented to only be used with USDC, NST and sNST.
## MigrationActions

Supported actions:
TODO.

* USDC <-> NGT Farms
* USDC <-> SPK Farms
Used to upgrade from DAI, sDAI to NST, sNST. Also contains a downgrade path for NST -> DAI for backwards compatibility.

## Usage

Expand Down
5 changes: 1 addition & 4 deletions test/PSMVariant1Actions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { PSMVariant1Mock } from "./mocks/PSMVariant1Mock.sol";

import { PSMVariant1Actions } from "src/PSMVariant1Actions.sol";

contract PSMVariant1ActionsBase is Test {
abstract contract PSMVariant1ActionsBase is Test {

// 1 trillion max of each
uint256 constant MAX_DAI_AMOUNT = 1e12 * 1e18;
Expand All @@ -36,9 +36,6 @@ contract PSMVariant1ActionsBase is Test {
// Set the savings token to 1.25 conversion rate to keep the shares different
savingsToken.__setShareConversionRate(1.25e18);

// Put some existing gems into the PSM
gem.mint(address(psm), 1000e6);

actions = new PSMVariant1Actions(
address(psm),
address(savingsToken)
Expand Down
Loading
Loading