Maker Protocol Technical Docs
  • MakerDAO Technical Docs
  • Getting Started
    • Maker Protocol 101
  • Smart Contract Modules
    • Dai Module
      • Dai - Detailed Documentation
    • Core Module
      • Vat - Detailed Documentation
      • Spot - Detailed Documentation
    • Collateral Module
      • Join - Detailed Documentation
    • Liquidation 2.0 Module
    • System Stabilizer Module
      • Flapper - Detailed Documentation
      • Flopper - Detailed Documentation
      • Vow - Detailed Documentation
    • Oracle Module
      • Oracle Security Module (OSM) - Detailed Documentation
      • Median - Detailed Documentation
    • MKR Module
    • Governance Module
      • Spell - Detailed Documentation
      • Pause - Detailed Documentation
      • Chief - Detailed Documentation
    • Rates Module
      • Pot - Detailed Documentation
      • Jug - Detailed Documentation
    • Proxy Module
      • Proxy Actions - Detailed Documentation
      • Vote Proxy - Detailed Documentation
      • CDP Manager - Detailed Documentation
      • DSR Manager - Detailed Documentation
    • Flash Mint Module
    • Maker Protocol Emergency Shutdown
      • Emergency Shutdown for Partners
      • The Emergency Shutdown Process for Multi-Collateral Dai (MCD)
      • End - Detailed Documentation
      • ESM - Detailed Documentation
  • Glossary
    • MCD Glossaries
    • Smart Contract Annotations
  • Deployment Addresses
    • Maker Protocol Deployments
  • Security
    • Security for the Maker Protocol
  • Building on top of the Maker Protocol
    • Developer Guides and Tutorials
    • The Dai Javascript Library of the Maker Protocol
      • Getting started
      • Configuration
        • Plugins
      • Vault manager
      • Collateral types
      • Dai Savings Rate
      • Currency units
      • System data
      • Advanced
        • Transaction manager
        • DSProxy
        • Events
        • Using multiple accounts
        • Adding a new service
      • Single-Collateral Sai
        • Collateralized Debt Position
        • CDP Service
        • Price Service
        • System Status
        • Tokens
        • Token Conversion
        • Exchange Service
    • Pymaker
  • Keepers
    • The Auctions of the Maker Protocol
    • Auction Keepers
      • Auction Keeper Bot Setup Guide
    • Market Maker Keepers
      • Market Maker Keeper Bot Setup Guide
    • Cage Keeper
    • Simple Arbitrage Keeper
    • Chief Keeper
  • Command-line Interfaces
    • Seth
    • Multi Collateral Dai (MCD) CLI
    • Dai and Collateral Redemption during Emergency Shutdown
    • Emergency Shutdown (ES) CLI
  • Miscellaneous
    • Liquidations 1.2 System (Deprecated)
      • Cat - Detailed Documentation
      • Flipper - Detailed Documentation
    • SCD <> MCD Migration
    • Upgrading to Multi-Collateral Dai Guide
Powered by GitBook
On this page
  • Deployment Details
  • Contract Details
  • Math
  • Storage
  • Functions and mechanics
  • daiBalance(address usr) returns (uint wad)
  • join(address dst, uint wad)
  • exit(address dst, uint wad)
  • exitAll(address dst)
  • Gotchas / Integration Concerns
Export as PDF
  1. Smart Contract Modules
  2. Proxy Module

DSR Manager - Detailed Documentation

The simplest way to integrate DSR in smart contracts

PreviousCDP Manager - Detailed DocumentationNextFlash Mint Module

Last updated 4 years ago

The DsrManager provides an easy to use smart contract that allows service providers to deposit/withdraw dai into the DSR contract , and activate/deactivate the Dai Savings Rate to start earning savings on a pool of dai in a single function call. To understand the DsrManager, it is necessary to have an understanding of the first. The DSR is set by Maker Governance, and will typically be less than the base stability fee to remain sustainable. The purpose of DSR is to offer another incentive for holding Dai.

Deployment Details

  • Mainnet:

  • Kovan:

  • Ropsten:

Contract Details

Math

  • wad - some quantity of tokens, as a fixed point integer with 18 decimal places.

  • ray - a fixed point integer, with 27 decimal places.

  • rad - a fixed point integer, with 45 decimal places.

  • mul(uint, uint), rmul(uint, uint), add(uint, uint) & sub(uint, uint) - will revert on overflow or underflow

  • Rdiv - Divide two rays and return a new ray. Always rounds down. A ray is a decimal number with 27 digits of precision that is being represented as an integer.

  • Rdivup - Divide two rays and return a new ray. Always rounds up. A ray is a decimal number with 27 digits of precision that is being represented as an integer.

Storage

  • pot - stores the contract address of the main Dai Savings Rate contract pot.

  • dai - stores the contract address of dai.

  • daiJoin - stores the contract address of the Dai token adapter.

  • supply - the supply of Dai in the DsrManager.

  • pieOf - mapping (addresses=>uint256) mapping of user addresses and normalized Dai balances (amount of dai / chi) deposited into pot.

  • pie - stores the address' pot balance.

  • chi - the rate accumulator. This is the always increasing value which decides how much dai is given when drip() is called.

  • vat - an address that conforms to a VatLike interface.

  • rho - the last time that drip is called.

Functions and mechanics

daiBalance(address usr) returns (uint wad)

  • Calculates and returns the Dai balance of the specified address usr in the DsrManager contract. (Existing Dai balance + accrued dsr)

join(address dst, uint wad)

  • uint wad this parameter specifies the amount of Dai that you want to join to the pot. The wad amount of Dai must be present in the account of msg.sender.

  • address dst specifies a destination address for the deposited dai in the pot. Allows a hot wallet address (msg.sender) to deposit dai into the pot and transfer ownership of that dai to a cold wallet (or any other address for that matter)

  • The normalized balance pie is calculated by dividing wad with the rate acumulator chi.

  • the dst's pieOf amount is updated to include the pie.

  • The total supply amount is also updated by adding the pie.

  • wad amount of dai is transferred to the DsrManager contract

  • The DsrManager contract joins wad amount of dai into the MCD system through the dai token adapter daiJoin.

  • The DsrManager contract joins pie amount of dai to the pot.

exit(address dst, uint wad)

  • exit() essentially functions as the exact opposite of join().

  • uint wad this parameter is based on the amount of dai that you want to exit the pot.

  • address dst specifies a destination address for the retrieved dai from the pot. Allows a cold wallet address (msg.sender) to retrieve dai from the pot and transfer ownership of that dai to a hot wallet (or any other address for that matter)

  • The normalized balance pie is calculated by dividing wad with the rate acumulator chi.

  • The msg.sender’s pieOf amount is updated by subtracting the pie.

  • The total supply amount is also updated by subtracting the pie.

  • The contract calls exit on the pot contract.

  • It calculates the amount of dai to retrieve by multiplying pie with chi.

  • Then exits the dai from the dai token adapter daiJoin to the destination address dst.

exitAll(address dst)

  • exitAll() functions like the exit function, except it simply looks into the mapping pieOf, to determine how much dai the msg.sender has, and exits the entire amount of dai, instead of a specified amount.

Gotchas / Integration Concerns

  • In order to use the join function, you need to approve the contract to transfer Dai from your wallet. You need to call approve on the Dai token, specifying the DsrManager contract and the amount that the contract should be able to pull (can be set to -1, if you want to set an unlimited approval)

pot
pot
0x373238337Bfe1146fb49989fc222523f83081dDb
0x7f5d60432DE4840a3E7AE7218f7D6b7A2412683a
0x74ddba71e98d26ceb071a7f3287260eda8daa045