# Dai Savings Rate

Use the `'mcd:savings'` service to work with the Dai Savings Rate system. In the code, this is called [SavingsService](https://github.com/makerdao/dai.js/blob/dev/packages/dai-plugin-mcd/src/SavingsService.js).

```javascript
const service = maker.service('mcd:savings');
```

## Instance methods

All the methods below are asynchronous. `join`, `exit`, and `exitAll` use a [proxy contract](https://docs.makerdao.com/build/dai.js/advanced-configuration/using-ds-proxy).

### join(amount)

Deposit the specified amount of Dai into the Dai Savings Rate (DSR) contract.

```javascript
await service.join(DAI(1000));
```

### exit(amount)

Withdraw the specified amount of Dai from the DSR contract.

### exitAll()

Withdraw all Dai owned by the current account from the DSR contract.

### balance()

Return the amount of Dai in the DSR contract owned by the [current address](https://docs.makerdao.com/build/dai.js/advanced-configuration/using-multiple-accounts). Strictly speaking, this method returns the amount of Dai owned by the proxy contract for the current address. to work with the methods above.

### balanceOf(address)

Return the amount of Dai in the DSR contract owned by the specified address.

### getTotalDai()

Get the total amount of Dai in the DSR contract for all users.

### getYearlyRate()

Get the current annual savings rate.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.makerdao.com/build/dai.js/savingsservice.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
