Inspiration

Climate change may effect the production of green pea crop, mostly affected by high temperature and water stress. Green peas are cold season crops grows in 12-18 degree celsius temperature, as per research >2.2 celsius above soil temperature causes the decrease in yield up to 17.5% per hectare. After doing research I found CDD (Cooling day degree) options are the suitable approach to incentives the farmers care for climate and grow green pea crop in optimal climate conditions.

What it does

CDD is the number of degrees by which the day's average temperature is a above a base temperature. The CDD options measures the cooling demand that arises by upward diversion of average daily temperatures from a base level(>18 Celsius)

Agri companies are the option writers, pays 0.1 LINK for each cooling day(CDD) for 20 CDD(2 LINK as collateral) after the strike CDD. For Green pea crop 120 days are growth period. In his protocol strike CDD at 100 days

Farmers are the option buyers, pays a premium of 0.1 LINK to buy the option and withdraw the collateral, after the strike CDD

In action Agri companies deposit 2 Links as a collateral with strike of 100 CDD. Farmer pays premium of 0.1 link to buy the option and the premium will transfer to the option writers. Farmers can withdraw the 0.1 Link from collateral for each 1 CDD.

How we built it

** Collecting weather Data ** Agromonitoring API provides the soil data (soil temperature, moisture) in real time, we used chainlinkClientInterface to call the API data from smart contract.

** Smart Contract ** I wrote the smart contract only call option derivatives after referring the option.sol contract from smartcontractkit. While my initial plan was take ETH as collateral and transfer to the farmer in DAI using price feed. Hence ETH/DAI address is not present in Goerli, so choose LINK to transfer tokens. I don’t have enough test ETH pay gas fee on Goerli, so switched to the polygon.

With the help of LINKtokenInterface I could be able to transfer LINK, because of low availability of Matic, I choose to add funds(LINK) to the contract through metamask. Write, buy, exercise functions checks the funds availability in contract and transfer to the respective parties as per logic

** Frontend ** I used react js to build the frontend, called all the contract methods using web3.js. I referred previous chainlink hackathon for UI and UX ideas

Challenges we ran into

So far I used only VRF for my other projects, this is the first time I explored more in chainlink. The major challenges I faced while using price feeds, hence there is no direct ETH/DAI address on goerli have to try my own and failed. Also I wasted lot of time transfering LINK through IERC20, until I figured it out LinkTokenInterface. Multiple times transactions got failed because gas estimation errors especially while transferring premium to the writer.

Accomplishments that we're proud of

I could be able to complete this project, the way i thought in the beginning. The best accomplishment i am proud of is figured it out optimizing the contract to collect preloaded tokens and transfer. Well It took me 2 days :-)

What we learned

This is my first Defi app, took little time to understand the architecture, options contract in smartcontractKit helped me to write customized option contract for CDD. Learnt many things from Chain link documentation, videos and previous hackathon resources

What's next for Peas for Climate

We want to build this single crop(Green Peas) CDD option derivatives as a model to onboard farmers and Agri companies

Built With

Share this project:

Updates