> For the complete documentation index, see [llms.txt](https://docs.makerdao.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.makerdao.com/build/dai.js/single-collateral-dai/exchange-service.md).

# Exchange Service

## Summary

Retrieve the OasisExchangeService (or alternative implementation) through `maker.service('exchange')`. The exchange service allows to buy and sell DAI, MKR, and other tokens. The default OasisExchangeService implementation uses the OasisDEX OTC market for this.

Requires one of the exchange [plugins](/build/dai.js/maker/plugins.md#available-plugins) to be in use.

```javascript
const exchange = maker.service('exchange');
```

## sellDai

Sell a set amount of DAI and receive another token in return.

* **Parameters**
  * `daiAmount` - Amount of DAI to sell.
  * `tokenSymbol` - Token to receive in return.
  * `minFillAmount` - Minimum amount to receive in return.
* **Returns:** promise (resolves to [OasisOrder](https://makerdao.com/documentation/#oasisorder) once mined)

```javascript
// Sell 100.00 DAI for 0.30 WETH or more.
const sellOrder = await exchange.sellDai('100.0', 'WETH', '0.30');
```

## **buyDai**

Buy a set amount of DAI and give another token in return.

* **Parameters**
  * `daiAmount` - Amount of DAI to buy.
  * `tokenSymbol` - Token to give in return.
  * `minFillAmount` - Maximum amount to give in return.
* **Returns:** promise (resolves to [OasisOrder](https://makerdao.com/documentation/#oasisorder) once mined)

```javascript
// Buy 100.00 DAI for 0.30 WETH or less.
const buyOrder = await exchange.buyDai('100.0', 'WETH', '0.35');
```

## **OasisOrder**

`OasisOrders` have a few methods: `fillAmount`: amount of token received in exchange `fees()`: amount of ether spent on gas `created()`: timestamp of when transaction was mined

```javascript
const buyOrder = await exchange.buyDai('100.0', 'WETH', '0.35');
const fillAmount = buyOrder.fillAmount();
const gasPaid = buyOrder.fees();
const created = buyOrder.created();
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.makerdao.com/build/dai.js/single-collateral-dai/exchange-service.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
