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

fix: Spearbit audit fixes #45

Merged
merged 6 commits into from
Oct 21, 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

This repository contains the implementation of a Peg Stability Module (PSM) contract, which facilitates the swapping, depositing, and withdrawing of three given assets to maintain stability and ensure the peg of involved assets. The PSM supports both yield-bearing and non-yield-bearing assets.

The PSM contract allows users to swap between USDC, USDS, and sSUDS, deposit any of the assets to mint shares, and withdraw any of the assets by burning shares.
The PSM contract allows users to swap between USDC, USDS, and sUSDS, deposit any of the assets to mint shares, and withdraw any of the assets by burning shares.

The conversion between a stablecoin and `susds` is provided by a rate provider contract. The rate provider returns the conversion rate between `susds` and the stablecoin in 1e27 precision. The conversion between the stablecoins is one to one.

The conversion rate between assets and shares is based on the total value of assets held by the PSM. The total value is calculated by converting the assets to their equivalent value in USD with 18 decimal precision. The shares represent the ownership of the underlying assets in the PSM. Since three assets are used, each with different precisions and values, they are converted to a common USD-denominated value for share conversions.
The conversion rate between assets and shares is based on the total value of assets within the PSM. This includes USDS and sUSDS held custody by the PSM, and USDC held custody by the `pocket`. The total value is calculated by converting the assets to their equivalent value in USD with 18 decimal precision. The shares represent the ownership of the underlying assets in the PSM. Since three assets are used, each with different precisions and values, they are converted to a common USD-denominated value for share conversions.

For detailed implementation, refer to the contract code and `IPSM3` interface documentation.

Expand Down
9 changes: 9 additions & 0 deletions src/PSM3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ import { Math } from "openzeppelin-contracts/contracts/utils/math/Math.sol";
import { IPSM3 } from "src/interfaces/IPSM3.sol";
import { IRateProviderLike } from "src/interfaces/IRateProviderLike.sol";

/*
███████╗██████╗ █████╗ ██████╗ ██╗ ██╗ ██████╗ ███████╗███╗ ███╗
██╔════╝██╔══██╗██╔══██╗██╔══██╗██║ ██╔╝ ██╔══██╗██╔════╝████╗ ████║
███████╗██████╔╝███████║██████╔╝█████╔╝ ██████╔╝███████╗██╔████╔██║
╚════██║██╔═══╝ ██╔══██║██╔══██╗██╔═██╗ ██╔═══╝ ╚════██║██║╚██╔╝██║
███████║██║ ██║ ██║██║ ██║██║ ██╗ ██║ ███████║██║ ╚═╝ ██║
╚══════╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
*/

contract PSM3 is IPSM3, Ownable {

using SafeERC20 for IERC20;
Expand Down
3 changes: 1 addition & 2 deletions src/interfaces/IPSM3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ interface IPSM3 {

/**
* @dev Returns the IERC20 interface representing sUSDS. This asset is the yield-bearing
* asset in the PSM (e.g., sUSDS). The value of this asset is queried from the
* rate provider.
* asset in the PSM. The value of this asset is queried from the rate provider.
* @return The IERC20 interface of sUSDS.
*/
function susds() external view returns (IERC20);
Expand Down
File renamed without changes.
Loading