Skip to content

Instantly share code, notes, and snippets.

@andrecronje
Created August 17, 2021 08:30
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save andrecronje/962932e2301f0b217c13f1ed0b7ca594 to your computer and use it in GitHub Desktop.
Save andrecronje/962932e2301f0b217c13f1ed0b7ca594 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;
interface v3oracle {
function assetToAsset(address, uint, address, uint) external view returns (uint);
}
contract ContractThatUsesOracle {
v3oracle constant oracle = v3oracle(0x0F1f5A87f99f0918e6C81F16E59F3518698221Ff);
function functionThatUsesOracle() external returns (uint) {
uint _twap = oracle.assetToAsset(TOKEN_FROM, TOKEN_FROM_AMOUNT, TOKEN_TO, TWAP_PERIOD);
//uint _twap = oracle.assetToAsset(ETH, 1e18, DAI, 3600); ~ 1 ETH to DAI over last 30 minutes
return _twap;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment