Skip to content

Instantly share code, notes, and snippets.

@billyjitsu
billyjitsu / Normalized.sol
Created February 4, 2025 02:12
Normalized Oracle
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol";
contract DataConsumerV3 {
AggregatorV3Interface internal dataFeed;
uint256 constant NORMALIZED_DECIMALS = 18;
constructor(address _priceFeed) {
//SPDX-License-Identifier: Unlicense
//CAUTION: NOT AUDITED, NO GUARANTEES OF PERFORMANCE
/*******************************************
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~ ROULETTE ~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--------------------------------------------
@billyjitsu
billyjitsu / Adaptor.sol
Last active June 1, 2024 13:19
Adaptor Contract
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "@api3/contracts/api3-server-v1/proxies/interfaces/IProxy.sol";
contract Api3AggregatorAdaptor {
// Updating the proxy address is a security-critical action which is why
// we have made it immutable.
address public immutable proxy;
@billyjitsu
billyjitsu / otherOracle.sol
Created May 28, 2024 20:26
Other Oracle - AggregatorV3Interface
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol";
contract DataConsumerV3 {
AggregatorV3Interface internal dataFeed;
constructor(address _priceFeed) {
dataFeed = AggregatorV3Interface(_priceFeed);
@billyjitsu
billyjitsu / PriceFeed.sol
Last active February 4, 2025 17:38
Price feed Example
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "@api3/contracts/api3-server-v1/proxies/interfaces/IProxy.sol";
import "@openzeppelin/contracts@4.9.3/access/Ownable.sol";
contract API3PriceFeed is Ownable {
address public proxyAddress;
@billyjitsu
billyjitsu / PriceFeed.sol
Created May 3, 2024 21:00
Price Feed Example
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
import "@api3/contracts/api3-server-v1/proxies/interfaces/IProxy.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract API3PriceFeed is Ownable {
address public proxyAddress;
@billyjitsu
billyjitsu / gist:b3a8fdfcd4dbdb095a41b26f75db1712
Created March 27, 2024 14:56
API3 AggregatorV3Interface Adapter
/*
Deploy this with the Price Feed address from https://market.api3.org/dapis
From your selected network
*/
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import "@api3/contracts/v0.8/interfaces/IProxy.sol";
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract StakingContract is Ownable {
IERC20 public stakingToken;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract MyToken is ERC20, Ownable {
constructor(address initialOwner) ERC20("MyToken", "MTK") Ownable(initialOwner)
{
_mint(msg.sender, 1000 * 10**18);
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
// https://docs.api3.org/reference/qrng/chains.html
// https://docs.api3.org/reference/qrng/providers.html
// https://docs.api3.org/reference/airnode/latest/packages/admin-cli.html
import "@api3/airnode-protocol/contracts/rrp/requesters/RrpRequesterV0.sol";
import "@openzeppelin/contracts@4.9.5/access/Ownable.sol";