@tracer-protocol/pools-js
Version:
Javascript library for interacting with Tracer's Perpetual Pools
58 lines (57 loc) • 2.01 kB
TypeScript
import { ChainlinkOracleWrapper } from "@tracer-protocol/perpetual-pools-contracts/types";
import BigNumber from "bignumber.js";
import { providers as MCProvider } from '@0xsequence/multicall';
import { ethers } from "ethers";
import { OracleClass, IContract } from "../types";
/**
* Oracle class constructor inputs
*/
export interface IOracle extends IContract, OracleInfo {
}
/**
* Oracle constructor props
* Only `address` is required, additional props are encouraged
* to reduce the number of RPC calls
*/
export interface OracleInfo {
address: string;
symbol?: string;
decimals?: number;
}
/**
* Oracle class for interacting with Chainlink Oracle Wrappers
* The constructor is private so must be instantiated with {@linkcode Oracle.Create}
*/
export default class Oracle implements OracleClass<ChainlinkOracleWrapper> {
_contract?: ChainlinkOracleWrapper;
address: string;
provider: ethers.providers.Provider | ethers.Signer | undefined;
multicallProvider: MCProvider.MulticallProvider | ethers.Signer | undefined;
/**
* @private
*/
private constructor();
/**
* Replacement constructor pattern to support async initialisations
* @param oracleInfo {@link IOracle | IOracle interface props}
* @returns a Promise containing an initialised Oracle class ready to be used
*/
static Create: (oracleInfo: IOracle) => Promise<Oracle>;
/**
* Creates an empty Oracle that can be used as a default
* @returns default constructed token
*/
static CreateDefault: () => Oracle;
/**
* Private initialisation function called in {@link Oracle.Create}
* @private
* @param oracleInfo {@link IOracle | IOracle interface props}
*/
private init;
/**
* Replaces the provider and connects the contract instance
* @param provider The new provider to connect to
*/
connect: (provider: ethers.providers.Provider | ethers.Signer) => void;
getPrice: () => Promise<BigNumber>;
}