> For the complete documentation index, see [llms.txt](https://docs.vulpefi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vulpefi.com/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/chainlinkcalculator.md).

# ChainlinkCalculator

A helper contract for interactions with [https://docs.chain.link](https://docs.chain.link/)

## Functions[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ChainlinkCalculator#functions) <a href="#functions" id="functions"></a>

### singlePrice[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ChainlinkCalculator#singleprice) <a href="#singleprice" id="singleprice"></a>

```javascript
function singlePrice(
  contract AggregatorV3Interface oracle,
  uint256 inverseAndSpread,
  uint256 amount
) external returns (uint256)
```

Calculates price of token relative to oracle unit (ETH or USD)

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ChainlinkCalculator#parameters)

| Name               | Type                           | Description                                                                                                                                                                                                                                                                                                                            |
| ------------------ | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `oracle`           | contract AggregatorV3Interface | concatenated inverse flag and spread. Lowest 254 bits specify spread amount. Spread is scaled by 1e9, i.e. 101% = 1.01e9, 99% = 0.99e9. Highest bit is set when oracle price should be inverted, e.g. for DAI-ETH oracle, inverse=false means that we request DAI price in ETH and inverse=true means that we request ETH price in DAI |
| `inverseAndSpread` | uint256                        |                                                                                                                                                                                                                                                                                                                                        |
| `amount`           | uint256                        |                                                                                                                                                                                                                                                                                                                                        |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ChainlinkCalculator#return-values)

| Name     | Type    | Description           |
| -------- | ------- | --------------------- |
| `Amount` | uint256 | *spread* oracle price |

### doublePrice[​](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ChainlinkCalculator#doubleprice) <a href="#doubleprice" id="doubleprice"></a>

```javascript
function doublePrice(
  contract AggregatorV3Interface oracle1,
  contract AggregatorV3Interface oracle2,
  uint256 spread,
  int256 decimalsScale,
  uint256 amount
) external returns (uint256)
```

Calculates price of token A relative to token B. Note that order is important

**Parameters:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ChainlinkCalculator#parameters-1)

| Name            | Type                           | Description |
| --------------- | ------------------------------ | ----------- |
| `oracle1`       | contract AggregatorV3Interface |             |
| `oracle2`       | contract AggregatorV3Interface |             |
| `spread`        | uint256                        |             |
| `decimalsScale` | int256                         |             |
| `amount`        | uint256                        |             |

**Return Values:**[**​**](https://docs.1inch.io/docs/limit-order-protocol/smart-contract/helpers/ChainlinkCalculator#return-values-1)

| Name     | Type    | Description                         |
| -------- | ------- | ----------------------------------- |
| `Result` | uint256 | Token A relative price times amount |


---

# 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.vulpefi.com/aggregation-protocol/limit-order-protocol/smart-contracts/helpers/chainlinkcalculator.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.
