# NDVI outcome reporting guide for Tellor Reporters

## Introduction

The [third parametric conditional donation campaign](https://www.divaprotocol.io/posts/diva-conditional-donations-pastoralists-3) on DIVA Donate, which uses Tellor Protocol for outcome reporting, will expire and **open for reporting on Monday, June 10, 2024, at 6:00 PM UTC** (unix timestamp: 1718042400). This article provides a guide for Tellor reporters on how to participate in the outcome reporting and verify the accuracy of reported values.

## Pool details

This campaign is linked to the following `poolId` on DIVA Protocol: [0x8c85108a28a163d1722c2140eea57f9d1cb7f83f69dfc04eb0d9e51298dea2b6](https://louper.dev/diamond/0x2C9c47E7d254e493f02acfB410864b9a86c28e1D?network=polygon#read).

To access the pool parameters, visit [louper.dev](https://louper.dev/diamond/0x2C9c47E7d254e493f02acfB410864b9a86c28e1D?network=polygon#read) (Etherscan for EIP-2535 based contracts) and input the `poolId` into the `getPoolParameters` function. The detailed description of the reference asset can be found via the [IPFS](https://bafybeibdjwmxn3r7cxx4bqqolqp3qib6l2co6mdrqh46ry2ab7cgbsamtu.ipfs.w3s.link/tellor_reference_asset_kajiado.json) link in the `referenceAsset` field:

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXdGdi9DDiawtFpOxlyVFop9dmnGrBhj_AalTRenwQhUzf_IydarQxSZcqJlpxniWNIuaUtwJxLMNS3z_Zqop5KQVJZjxK-99Z0FVgaHfQSnRsKWM8tHQUXebVxxb2F6e_EjKxDZWgBvAqqxnKiAp__kGtpC?key=WD92XiiSWdXI6vNzb6_qLQ" alt=""><figcaption></figcaption></figure>

Accessing the IPFS link in your browser will display the following:

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXcOWslIzjDKt-3YRvsWliOvPfYY6IY3ycxLDkiGYDt1fQDePy7duUMXboj_Kp0HXaKPh5Q6d-2jblQvJCePYFaP_BNTS1ZIPPckFOQpSYsRBxzQAv24OICpMbrWO9dBDz__1QfOeO6k29ENs_SPQ-68r_sW?key=WD92XiiSWdXI6vNzb6_qLQ" alt=""><figcaption></figcaption></figure>

## Reporting

The reporting process consists of the following four steps which are described in detail in the subsequent sections:

1. Sourcing the NDVI value
2. Sourcing the USD rate of the collateral token (USDT)
3. Preparing the values for submission
4. Submitting to Tellor contract
5. Submitting to DIVA Protocol

### 1 - Sourcing the NDVI value

To manually source the NDVI value:

1. Visit [USGS Early Warning Site](https://earlywarning.usgs.gov/fews/ewx/index.html).&#x20;
2. Double-click on “NDVI eVIIRs” in the Dataset panel on the left.

<figure><img src="https://1305042189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHZJ0AbZj1fc1i5a58eEE%2Fuploads%2FHWP3FMB4CrntBu3UQEeG%2Fimage.png?alt=media&#x26;token=499705cb-b3c0-41e3-83ea-0b30ddad7424" alt=""><figcaption></figcaption></figure>

3. Locate and select "Kenya Kajiado" on the map.

<figure><img src="https://1305042189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHZJ0AbZj1fc1i5a58eEE%2Fuploads%2FHVUgCESh1CQbrrGnumrt%2Fimage.png?alt=media&#x26;token=88847271-4a2c-4711-a525-adc6e1672ef5" alt=""><figcaption></figcaption></figure>

4. Ensure the year 2024 curve is selected.

<figure><img src="https://1305042189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHZJ0AbZj1fc1i5a58eEE%2Fuploads%2FHcTCoXxcZUNFdrjbPDeM%2Fimage.png?alt=media&#x26;token=bb8aae2c-c6f8-4e25-b67f-534d16548d4c" alt=""><figcaption></figcaption></figure>

5. Read the value on 31th May 2024.

<figure><img src="https://1305042189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHZJ0AbZj1fc1i5a58eEE%2Fuploads%2FzI2gCPt6cMAipui8cwF7%2Fimage.png?alt=media&#x26;token=5d6b1c83-1588-4a1c-88f1-6282ea19ee37" alt=""><figcaption></figcaption></figure>

### 2 - Sourcing the USD rate of the collateral token (USDT)

In addition to the NDVI value, the reporter must also submit the USD rate of the collateral token, USDT, which is utilized to calculate the reporter's reward. You can confirm that [USDT](https://polygonscan.com/address/0xc2132D05D31c914a87C6611C10748AEb04B58e8F) (at address 0xc2132D05D31c914a87C6611C10748AEb04B58e8F) is the pool's collateral token by checking the `getPoolParameters` [output](#pool-details).

The USD rate can be obtained from price aggregators like [Coingecko](https://www.coingecko.com/en/coins/tether) or [Coinmarketcap](https://coinmarketcap.com/currencies/tether/), or exchanges.

The reference asset description does not specify whether the observation date for the USD rate should be May 31, 2024, or June 10, 2024, at 6:00 PM UTC. For consistency, use the same time as the observation timepoint for the reference asset, which is May 31, 2024. Use the end-of-day price at 11:59:59 PM UTC, round to two decimal places. It is anticipated that the USD value of USDT will be 1.00, thereby minimizing any potential for ambiguity or dispute.

### 3 - Preparing the values for submission

Prepare the two values as per below and encode them as `bytes`:

1. **NDVI value**
   * Shift the observed NDVI value by +1 and round it to two decimal places, which is the default precision in the NDVI chart. For instance, an NDVI value of 0.75 becomes 1.75.
   * Convert the adjusted NDVI value into an unsigned integer with 18 decimals. Thus, 1.75 becomes 1750000000000000000.
2. **USD value of the collateral token (USDT)**
   * Convert the value into an unsigned integer with 18 decimals. Thus, 1.00 becomes 1000000000000000000.

#### Encode the values

Use the following function to encode your values. Check out [this example](https://github.com/divaprotocol/oracles/blob/48d1209bb55d1f1eb0b5dbcbadfad7be2ec3de6b/scripts/examples/tellor_submitValue.js#L116) for reference.

```typescript
encodeOracleValue = (finalReferenceValue, collateralToUSDRate) => {
  return new ethers.utils.AbiCoder().encode(
    ["uint256", "uint256"],
    [finalReferenceValue, collateralToUSDRate]
  );
};
```

**Example:** With `finalReferenceValue =  1750000000000000000` and `collateralToUSDRate = 1000000000000000000`, the encoded oracle value will be:

`0x00000000000000000000000000000000000000000000000018493fba64ef00000000000000000000000000000000000000000000000000000de0b6b3a7640000`

### 4 - Submitting to Tellor contract

To submit the encoded value to the Tellor contract, use the [`submitValue`](https://polygonscan.com/address/0xD9157453E2668B2fc45b7A803D3FEF3642430cC0#writeContract#F8) function on the (old) Tellor contract at the address [0xD9157453E2668B2fc45b7A803D3FEF3642430cC0](https://polygonscan.com/address/0xD9157453E2668B2fc45b7A803D3FEF3642430cC0). Enter the encoded value into the `_value` field and include the following parameters that are independent of the NDVI value / collateral USD value:

* `_queryId`: `0xf5b0d276ce38d3776861fb978b066a0ade32227dd84c282dbdda40d31fbda068`
* `_nonce`: `0`
* `_queryData`: `0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000c4449564150726f746f636f6c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000608c85108a28a163d1722c2140eea57f9d1cb7f83f69dfc04eb0d9e51298dea2b60000000000000000000000002c9c47e7d254e493f02acfb410864b9a86c28e1d0000000000000000000000000000000000000000000000000000000000000089`

  <figure><img src="https://1305042189-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHZJ0AbZj1fc1i5a58eEE%2Fuploads%2FrXpELV8Y666iftXmqGG1%2Fimage.png?alt=media&#x26;token=b2ac6700-8b41-4e7f-bf13-7e2e04e6147d" alt=""><figcaption></figcaption></figure>

#### Additional comments

* To verify that the provided `queryId` and `queryData` are indeed correct, refer to [this script](https://github.com/divaprotocol/oracles/blob/main/scripts/examples/divaTellor_getQueryDataAndId.js).
* Ensure that you have staked TRB tokens to be eligible for reporting. For detailed instructions on how to become a reporter, refer to the official [Tellor docs](https://docs.tellor.io/tellor/reporting-data/becoming-a-reporter) (note that these documents may reference the newer, gas-optimized Tellor contracts, whereas the DIVA Tellor adapter used in this campaign is still linked to the older version).
* Please note that values submitted to the Tellor contract *before* campaign expiration (**Monday, June 10, 2024, at 6:00 PM UTC**) will be ignored.
* If you prefer to submit the value via a script, refer to [this example](https://github.com/divaprotocol/oracles/blob/main/scripts/examples/tellor_submitValue.js). Make sure to update the script setting `const tellorVersion = TELLOR_VERSION.PLAYGROUND` to `const tellorVersion = TELLOR_VERSION.`**`ACTUAL`** to reflect the mainnet environment.

### 5 - Submitting to DIVA Protocol

If the reported NDVI value remains undisputed for at least 12 hours, anyone can execute the [`setFinalReferenceValue`](https://polygonscan.com/address/0x7950db13cc37774614b0aa406e42a4c4f0bf26a6#writeContract) function on the DIVA Tellor adapter contract on the Polygon chain at address [0x7950db13cc37774614b0aa406e42a4c4f0bf26a6](https://polygonscan.com/address/0x7950db13cc37774614b0aa406e42a4c4f0bf26a6). This action pulls the value from the Tellor contract into DIVA Protocol and determines the payouts for each leg of the market.&#x20;

When executing the function `setFinalReferenceFunction`, set `_tippingTokens` to an empty array and `_claimDIVAReward` to `true`. This will transfer the data provider reward from DIVA Protocol to the original Tellor reporter, amounting to 0.05% of the deposited funds, approximately $4.30.

<figure><img src="https://lh7-us.googleusercontent.com/docsz/AD_4nXfUFcc4U5Q0xFp3DL5nkgJpDmvCXcvtt6JWCeZiZK_c8Cj_G2fIPjA1bd_beM3KjV1b6kX1hr8lpRYfvqpMGjNHo3HMJXoRw8uXCdLny9FmDybWZBmZDtRinQzYuLZ6-Lp985ynpjFNnS3JBNhEbkyO8fE?key=WD92XiiSWdXI6vNzb6_qLQ" alt=""><figcaption></figcaption></figure>

## Additional Notes

The NDVI value is updated every five days and historical values are subject to slight variations due to a smoothing algorithm applied to the data. **It is recommended that reporters read the NDVI value for May 31th shortly after the campaign expiration on June 10th, as this timing makes the May 31th value less likely to change. Additionally, it is advisable to record a video of your value reading from the chart as proof should your reported value be disputed later.**

## Reporting information summary

Below table summarizes the key information required for reporting. The mentioned contract addresses can be found in the official [DIVA Tellor oracle adapter docs](https://github.com/divaprotocol/oracles/blob/main/docs/Tellor.md#polygon) on Github.

| Network                               | Polygon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `poolId`                              | [`0x8c85108a28a163d1722c2140eea57f9d1cb7f83f69dfc04eb0d9e51298dea2b6`](https://louper.dev/diamond/0x2C9c47E7d254e493f02acfB410864b9a86c28e1D?network=polygon#read)                                                                                                                                                                                                                                                                                                                                                                   |
| Tellor contract address (old version) | [`0xD9157453E2668B2fc45b7A803D3FEF3642430cC0`](https://polygonscan.com/address/0xD9157453E2668B2fc45b7A803D3FEF3642430cC0)                                                                                                                                                                                                                                                                                                                                                                                                           |
| DIVA Tellor adapter contract          | [`0x7950db13cc37774614b0aa406e42a4c4f0bf26a6`](https://polygonscan.com/address/0x7950db13cc37774614b0aa406e42a4c4f0bf26a6)                                                                                                                                                                                                                                                                                                                                                                                                           |
| `queryId`                             | `0xf5b0d276ce38d3776861fb978b066a0ade32227dd84c282dbdda40d31fbda068`                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `queryData`                           | `0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000c4449564150726f746f636f6c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000608c85108a28a163d1722c2140eea57f9d1cb7f83f69dfc04eb0d9e51298dea2b60000000000000000000000002c9c47e7d254e493f02acfb410864b9a86c28e1d0000000000000000000000000000000000000000000000000000000000000089` |

## Questions?

Reach out to us on:

* [Discord (DIVA)](https://discord.gg/v4KYKms6zh)
* [Twitter (DIVA)](https://twitter.com/divaprotocol_io)
* [Discord (Tellor)](https://discord.gg/n7drGjh)
