---
description: Deriving the value of underlying tokens in their paired currency
---

# Underlying Value

This process is crucial for our protocol and is the core mechanism behind all our OTC tools.

All tokens deposited into our protocol have a underlying value derived. This refers to the process of determining the equivalent value of a particular ERC20 token in the paired currency.

The utility of deriving the underlying value of tokens can be found here:

{% content-ref url="https://app.gitbook.com/s/KqdGuy6RKkzLXn1lnU6Y/costing-and-valuation/underlying-value" %}
[Underlying Value](https://app.gitbook.com/s/KqdGuy6RKkzLXn1lnU6Y/costing-and-valuation/underlying-value)
{% endcontent-ref %}

## getUnderlyingValue

This is the primary function of our protocol engine / core mechanisms.

The function accepts input of token address and amount, then returns the value (in paired currency) and the paired currency address to the caller.

It only measure the value of the ERC20 tokens being hedged, i.e. the underlying assets. The cost or premium is excluded from this.

Its depended on the following helper functions:

* `getPairAddressZK`
* `IUniswapV2Pair`
* `getReserves`
* `token0`() and `token1`()

### Functions that use this:

* `writeHedge` - used to derive `createValue` of the underlying tokens in the hedge.
* `buyHedge` - used to derive the `startValue` of the underlying tokens in the hedge.
* `settleHedge` - used to derive the `endValue` of the underlying tokens in the hedge, and to determine the payoff for each party in the hedge.
* `depositToken, withdrawToken` - used to derive the paired value equivalent of each transfer.
* `getuserTokenBalances` - used to retrieve the paired value for a specific balance of tokens held by a wallet on the protocol.

## Conclusion

`getUnderlyingValue` function is the core function of our protocol engine. By embracing the fact that all ERC20 tokens have a measurable value in their paired currency, we open up the door to developing advanced OTC tools that are inclusive of all ERC20 tokens.&#x20;

It enables Neon Protocol to build sound risk management and lending tools.
