Skip to main content


An embedded library helping you to get tokens prices without you caring about the integrations you need for various oracles.

In the current version, our SDK provides a connection to Chainlink. Also, the right oracle adapter is chosen based on which network you are calling the library from


function getTokenPrice(address token) external view returns (uint256) {    return Oracle.getTokenPrice(token);}


// Retrieves token's pricefunction getTokenPrice(address tokenAddress) internal view returns (uint256) {    address oracleAdapter = OracleAdapterGetter.getOracleAdapter();    return IOracle(oracleAdapter).getTokenPrice(tokenAddress);}

Each oracle will have an Adapter. As mentioned above, the oracle the SDK integrates with is Chainlink, for which we created the following adapter

contract ChainlinkAdapter is IOracle, Ownable {    /// @notice maps token address to price feed aggregator    mapping(address => address) public tokenToAggregator;
    /// @notice emits this event when a new price aggregator is added for a token    event AddedTokenPriceAggregator(address _tokenAddress, address _aggregator);
    /// @notice Add a chainlink data feed aggregator for a token    /// @param _tokenAddress The address of the token to add    /// @param _tokenAddress The address of the data feed aggregator for the token    function addTokenPriceAggregator(address _tokenAddress, address _aggregator) external onlyOwner {        require(address(_tokenAddress) != address(0), "INVALID_TOKEN_ADDRESS");        require(address(_aggregator) != address(0), "INVALID_AGGREGATOR_ADDRESS");        tokenToAggregator[_tokenAddress] = _aggregator;        emit AddedTokenPriceAggregator(_tokenAddress, _aggregator);    }
    function getTokenPrice(address _tokenAddress) external view override returns (uint256) {        require(address(_tokenAddress) != address(0), "INVALID_TOKEN_ADDRESS");        address _aggregator = tokenToAggregator[_tokenAddress];        require(address(_aggregator) != address(0), "UNSUPPORTED_TOKEN_ADDRESS");        IChainlinkV3Aggregator priceFeed = IChainlinkV3Aggregator(_aggregator);        (, int256 price, , , ) = priceFeed.latestRoundData();        return uint256(price);    }}