LitePSM
- Level: Beginner
- Estimated Time: 15 minutes
- Last Updated : 2025-07-15
LitePSMs stabilize the USDS and DAI stablecoins against their pegged value by enabling users to trade USDS or DAI with other stablecoins like USDC (referred to as “gems”) at fixed exchange ratios and fees. LitePSM’s primary goal is to minimize gas costs for users. To achieve this, Sky Ecosystem and its keeper ecosystem will absorb some of the gas expenses for all swaps by performing background bookkeeping tasks. This reduction in total gas costs benefits users swapping between USDS or DAI and USDC, whether directly or through DEX aggregators like CoWSwap, 1inch, or Uniswap.
Learning objectives
Section titled “Learning objectives”- Using the LitePSM
- Migrate your integration from PSM to LitePSM
Pre-requisites
Section titled “Pre-requisites”Familiarity with USDS, DAI, and USDC ERC20 tokens.
LitePSM Deployments
Section titled “LitePSM Deployments”Ethereum Mainnet
- LitePSMWrapper-USDS-USDC: 0xA188EEC8F81263234dA3622A406892F3D630f98c
- LitePSM-DAI-USDC: 0xf6e72Db5454dd049d0788e411b06CfAF16853042
Available PSMs
Section titled “Available PSMs”LitePSMWrapper-USDS-USDC is designed as a wrapper which routes all USDS to USDC and USDC to USDS swaps to the LitePSM-DAI-USDC by converting USDS to DAI internally. This allows Sky Protocol to share USDC liquidity among both USDS and DAI and avoid fragmentation.
LitePSMWrapper-USDS-USDC Usage
Section titled “LitePSMWrapper-USDS-USDC Usage”Public
All users will have access to the following functions:
sellGem: Sell USDC and receive USDSbuyGem: Buy USDC with USDS
sellGem function accepts two inputs:
usr: Address of the USDS recipientgemAmt: Amount of USDC being sold
The gemAmt is denominated in 6 decimals because “Gem” refers to USDC in a LitePSMWrapper-USDS-USDC deployment, which uses 6 decimals instead of the more common 18
decimals. After a successful swap, this amount of USDC is transferred from msg.sender
to the LitePSMWrapper-USDS-USDC. The function returns a value denominated in 18 decimals,
representing the USDS amount the user receives. The usr address then receives the USDS
ERC20 balance from the LitePSMWrapper-USDS-USDC.
buyGem function accepts two inputs:
usr: Address of the USDC recipientgemAmt: Amount of USDC being bought
The gemAmt is denominated in 6 decimals because “Gem” refers to USDC in a LitePSMWrapper-USDS-USDC deployment, which uses 6 decimals instead of the more common 18
decimals. After a successful swap, this amount of USDC is transferred to the usr
address. The function returns a value denominated in 18 decimals, representing the USDS
amount that msg.sender transfers from their address to the LitePSMWrapper-USDS-USDC. The usr
address then receives the USDC balance from the LitePSMWrapper-USDS-USDC.
LitePSM-DAI-USDC Usage
Section titled “LitePSM-DAI-USDC Usage”Public
All users will have access to the following functions:
sellGem: Sell USDC and receive DAIbuyGem: Buy USDC with DAI
sellGem function accepts two inputs:
usr: Address of the DAI recipientgemAmt: Amount of USDC being sold
The gemAmt is denominated in 6 decimals because “Gem” refers to USDC in a LitePSM-DAI-USDC deployment, which uses 6 decimals instead of the more common 18
decimals. After a successful swap, this amount of USDC is transferred from msg.sender
to the LitePSM-DAI-USDC. The function returns a value denominated in 18 decimals,
representing the DAI amount the user receives. The usr address then receives the DAI
ERC20 balance from the LitePSM-DAI-USDC.
buyGem function accepts two inputs:
usr: Address of the USDC recipientgemAmt: Amount of USDC being bought
The gemAmt is denominated in 6 decimals because “Gem” refers to USDC in a LitePSM-DAI-USDC deployment, which uses 6 decimals instead of the more common 18
decimals. After a successful swap, this amount of USDC is transferred to the usr
address. The function returns a value denominated in 18 decimals, representing the DAI
amount that msg.sender transfers from their address to the LitePSM-DAI-USDC. The usr
address then receives the USDC balance from the LitePSM-DAI-USDC.
Authorized Users
Authorized users have access to two additional functions: sellGemNoFee and
buyGemNoFee, which allow them to execute swaps without paying additional PSM fees.
Authorized users will still need to pay the gas fees for their transactions. Governance
must add an authorized user to an access list on the LitePSM-DAI-USDC to allow them
access to these additional functions.
sellGemNoFee and buyGemNoFee accept the same inputs and return the same values as
sellGem and buyGem, respectively.
Maximum Swap Size
All users, both public and authorized, can only swap up to the DAI and USDC balances
held by LitePSM-DAI-USDC. DAI balance is held by LitePSM-DAI-USDC in its own contract
address. USDC balance is held in a separate Pocket contract whose address can be
read from litepsm.pocket(). Please note that other LitePSM-DAI-USDC swap transactions
included in a block could affect the available DAI and USDC amounts.
The USDC balance held by LitePSM-DAI-USDC is determined by external usage and periodic liquidity management by Sky Ecosystem actors.
The DAI balance held by LitePSM-DAI-USDC is determined by internal protocol bookkeeping
activities. The maximum DAI balance held by LitePSM-DAI-USDC at any time is dictated by
the buf value set by Sky Ecosystem governance. Sky Ecosystem keepers periodically execute a
set of public functions: fill, trim, and chug to keep the DAI balance of the
LitePSM-DAI-USDC in line with the buf parameter. These functions are not restricted, and
any address can execute them.
The Maximum Swap Size limit restricts a single sellGem transaction. As integrators, you
can handle swaps beyond this limit by constructing an atomic batch of transactions. This
batch can interleave any number of psm.sellGem() transactions to swap up to the
currently available DAI balance with psm.fill() transactions to refill the DAI balance in the LitePSM. This approach allows you to complete a large USDC to DAI swap
transaction atomically for your users.
Public
The tin fee is assessed on all sellGem transactions, and the tout fee is assessed on
all buyGem transactions. Both tin and tout values are set by Sky Ecosystem governance.
Governance can set either tin or tout to the value of type(uint256).max, halting
sellGem and buyGem transactions respectively on the LitePSM. Transactions would be
halted for both public and authorized users.
Fees are represented as fixed decimal-point numbers with 18 decimals. Fee values will
always be equal to or less than a WAD, which is (10^{ 18 }). Some examples are:
- A
tinvalue of 1, represented as a WAD, would assess a 100% fee on asellGemtransaction. This should never happen in practice. - A
tinvalue of 0.01, represented as WAD/100, would assess a fee of 1% (100 basis points) on asellGemtransaction. - A
toutvalue of 0.001, represented as WAD/10000, would assess a fee of 0.01% (^1 basis point) on abuyGemtransaction.
Authorized Users
Authorized users are not assessed the tin and tout fees when they execute the
sellGemNoFee and buyGemNoFee functions. However, they will be assessed fees like
public users when they execute the regular sellGem and buyGem functions instead of
the NoFee variants.
Authorized users can check their authorization status with the bud() function.
The bud function accepts the address of the authorized user. It returns a value of 1
when the address is authorized to execute both sellGemNoFee and buyGemNoFee, and a
value of 0 when the address is not authorized to execute these functions.
Gas Costs
Section titled “Gas Costs”| Transaction Type | Gas Limit |
|---|---|
| BuyGem (DAI to USDC) - LitePSM (Public User) | 78,867 |
| BuyGem (DAI to USDC) - LitePSM (Authorized User) | _ |
| SellGem (USDC to DAI) - LitePSM (Public User) | 93,742 |
| SellGem (USDC to DAI) - LitePSM (Authorized User) | _ |
Please refer to LitePSM Dashboard for current LitePSM-DAI-USDC stats after launch.
Troubleshooting
Section titled “Troubleshooting”Potential Issues
Section titled “Potential Issues”- Swaps will fail if the LitePSM has zero DAI balance.
- Swaps will fail if other transactions have consumed the DAI balance of the LitePSM in the same block before your transaction.
- LitePSM offers no slippage protection, and fees could change within the same block if a pending governance action goes live in a transaction before yours.
Refill Dai Buffer
Section titled “Refill Dai Buffer”Steps to refill the DAI Balance of LitePSM-DAI-USDC:
- Call the
rushfunction to check whether the DAI balance of LitePSM-DAI-USDC can be increased. - If
rushreturns a value greater than zero, you can executefillto increase the DAI balance of LitePSM-DAI-USDC up to the limit set by the buf parameter.
LitePSM Halt Status
Section titled “LitePSM Halt Status”- You can check whether
sellGemandsellGemNoFeeare halted by verifying if thetinvalue is set touint.max. - You can check whether
buyGemandbuyGemNoFeeare halted by verifying if thetoutvalue is set touint.max.
Next steps
Section titled “Next steps”N/A
Resources
Section titled “Resources” Released into the public domain (CC0 1.0 Universal) – trademarks remain with their owners; no warranty. See full license.