Created
September 2, 2021 00:22
-
-
Save bitcoinwarrior1/fba2069c4711a4680925e7b8f91d9a4f to your computer and use it in GitHub Desktop.
Get prices from the NEST Oracle and then provide the prices for free
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'https://raw.githubusercontent.com/NEST-Protocol/NEST-Oracle-V3.5/main/contracts/iface/INestQuery.sol'; | |
pragma solidity ^0.6.12; | |
contract NESTBootleg { | |
struct Price { | |
uint ethAmount; | |
uint erc20Amount; | |
uint blockNum; | |
} | |
mapping(address => mapping(uint => Price)) prices; | |
INestQuery iNestQuery; | |
constructor(_nestQueryAddress) { | |
iNestQuery = INestQuery(_nestQueryAddress); | |
} | |
function updatePrice(address token) public payable { | |
(uint ethAmount, uint erc20Amount, uint blockNum) = iNestQuery.query(token, msg.sender); | |
Price newPrice = Price(ethAmount, erc20Amount, blockNum); | |
prices[token][blockNum] = newPrice; | |
} | |
function getPrice(address token, uint blockNum) public view returns(Price) { | |
return prices[token][blockNum]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment