Class ContractAPI

The ContractAPI class extends BaseAPI and is used for interacting with various types of contracts pertaining to the Premia protocol.

It includes methods for connecting to Pool, Token, Oracle Adapter, Pool Factory, Vault Registry, Vault, and Orderbook contracts. The connection to the contracts is made using a Provider, which defaults to premia.signer or premia.provider if not provided.

The class also includes methods for setting the addresses for the Orderbook, Pool Factory, and Vault Registry contracts.

Hierarchy

  • BaseAPI
    • ContractAPI

Constructors

Properties

optionRewardAddress: string = ...

The address of the OptionReward contract.

orderbookAddress: string = ...

The address of the Orderbook contract.

poolDiamondAddress: string = ...

The address of the Premia Diamond IPool contract.

poolFactoryAddress: string = ...

The address of the Pool Factory contract.

premia: Premia

The Premia SDK instance.

referralAddress: string = ...

The address of the Referral contract.

stakingAddress: string = ...

The address of the PremiaStaking contract.

streamIndex: number = 0

The current index of quote streams. Used to cancel stale streams.

userSettingsAddress: string = ...

The address of the UserSettings contract.

vaultMiningAddress: string = ...

The address of the VaultMining contract.

vaultRegistryAddress: string = ...

The address of the Vault Registry contract.

vxPremiaAddress: string = ...

The address of the VxPremia contract.

Methods

  • Cancels all ongoing streams.

    Returns Promise<void>

  • Connects to a optionPS contract at a given address using a provider.

    This function uses the IDualMining__factory to connect to the dual mining contract on the blockchain. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • dualMiningAddress: string

      The address of the dual mining contract to connect to.

    • Optional provider: Provider

      The provider to use for the connection. If not specified, the function defaults to using this.premia.signer or this.premia.provider.

    Returns IDualMining

    The connected dual mining contract instance.

  • Connects to an ERC1155 contract using a provider.

    This function leverages the ERC1155__factory to connect to a ERC1155 contract. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • poolAddress: string

      The address of the pool contract to connect to.

    • Optional provider: Provider

      The provider to use for the connection. If not provided, the function defaults to using this.premia.signer or this.premia.provider.

    Returns IERC1155

    The connected ERC1155 contract instance.

  • Connects to an ERC4626 contract using a provider.

    This function leverages the ERC4626__factory to connect to a ERC4626 contract. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • vaultAddress: string

      The address of the Vault contract to connect to.

    • Optional provider: Provider

      The provider to use for the connection. If not provided, the function defaults to using this.premia.signer or this.premia.provider.

    Returns IERC4626

    The connected ERC4626 contract instance.

  • Connects to a optionPS contract at a given address using a provider.

    This function uses the IOptionPS__factory to connect to the OptionPS contract on the blockchain. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • optionPSAddress: string

      The address of the OptionPS contract to connect to.

    • Optional provider: Provider

      The provider to use for the connection. If not specified, the function defaults to using this.premia.signer or this.premia.provider.

    Returns IOptionPS

    The connected optionPS contract instance.

  • Connects to the VxPremia contract using a provider.

    This function leverages the OptionReward __factory to connect to the OptionReward contract. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • Optional provider: Provider

      The provider to use for the connection. If not provided, the function defaults to using this.premia.signer or this.premia.provider.

    Returns IOptionReward

    The connected OptionReward contract instance.

  • Connects to an Oracle Adapter contract at a given address using a provider.

    This function leverages the IOracleAdapter__factory to connect to an Oracle Adapter contract on the blockchain. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • oracleAdapterAddress: string

      The address of the Oracle Adapter contract to connect to.

    • Optional provider: Provider

      The provider to use for the connection. If not provided, the function defaults to using this.premia.signer or this.premia.provider.

    Returns IOracleAdapter

    The connected Oracle Adapter contract instance.

  • Connects to the Orderbook contract using a provider.

    This function leverages the OrderbookStream__factory to connect to the Orderbook contract. If no provider is specified, it will default to using the orderbookSigner or orderbookProvider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • Optional provider: Provider

      The provider to use for the connection. If not provided, the function defaults to using this.premia.orderbookSigner or this.premia.orderbookProvider.

    Returns OrderbookStream

    The connected Orderbook contract instance.

  • Connects to a pool contract at a given address using a provider.

    This function uses the IPool__factory to connect to a pool contract on the blockchain. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • poolAddress: string

      The address of the pool contract to connect to.

    • Optional provider: Provider

      The provider to use for the connection. If not specified, the function defaults to using this.premia.signer or this.premia.provider.

    Returns IPool

    The connected pool contract instance.

  • Connects to the Pool Diamond contract using a provider.

    This function utilizes the IPool__factory to connect to the Pool Diamond contract. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • Optional provider: Provider

      The provider to use for the connection. If not provided, the function defaults to using this.premia.signer or this.premia.provider.

    Returns IPool

    The connected Pool Diamond contract instance.

  • Connects to the Pool Factory contract using a provider.

    This function utilizes the IPoolFactory__factory to connect to the Pool Factory contract. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • Optional provider: Provider

      The provider to use for the connection. If not provided, the function defaults to using this.premia.signer or this.premia.provider.

    Returns IPoolFactory

    The connected Pool Factory contract instance.

  • Connects to the Referral contract using a provider.

    This function leverages the VxPremia __factory to connect to the VxPremia contract. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • Optional provider: Provider

      The provider to use for the connection. If not provided, the function defaults to using this.premia.signer or this.premia.provider.

    Returns IReferral

    The connected VxPremia contract instance.

  • Connects to a token contract at a given address using a provider.

    This function utilizes the SolidStateERC20__factory to connect to a token contract on the blockchain. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • tokenAddress: string

      The address of the token contract to connect to.

    • Optional provider: Provider

      The provider to use for the connection. If not provided, the function will default to using this.premia.signer or this.premia.provider.

    Returns ISolidStateERC20

    The connected token contract instance.

  • Connects to the UserSettings contract using a provider.

    This function leverages the UserSettings__factory to connect to the UserSettings contract. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • Optional provider: Provider

      The provider to use for the connection. If not provided, the function defaults to using this.premia.signer or this.premia.provider.

    Returns IUserSettings

    The connected UserSettings contract instance.

  • Connects to a Vault contract at a given address using a provider.

    This function utilizes the IVault__factory to connect to a Vault contract. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • vaultAddress: string

      The address of the Vault contract to connect to.

    • Optional provider: Provider

      The provider to use for the connection. If not provided, the function defaults to using this.premia.signer or this.premia.provider.

    Returns IVault

    The connected Vault contract instance.

  • Connects to the VxPremia contract using a provider.

    This function leverages the VxPremia __factory to connect to the VxPremia contract. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • Optional provider: Provider

      The provider to use for the connection. If not provided, the function defaults to using this.premia.signer or this.premia.provider.

    Returns IVaultMining

    The connected VxPremia contract instance.

  • Connects to the Vault Registry contract using a provider.

    This function utilizes the IVaultRegistry__factory to connect to the Vault Factory contract. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • Optional provider: Provider

      The provider to use for the connection. If not provided, the function defaults to using this.premia.signer or this.premia.provider.

    Returns IVaultRegistry

    The connected Vault Factory contract instance.

  • Connects to the VxPremia contract using a provider.

    This function leverages the VxPremia __factory to connect to the VxPremia contract. If no provider is specified, it will default to using the signer or provider from the premia object.

    Throws

    Will throw an error if the connection to the contract fails.

    Parameters

    • Optional provider: Provider

      The provider to use for the connection. If not provided, the function defaults to using this.premia.signer or this.premia.provider.

    Returns IVxPremia

    The connected VxPremia contract instance.

  • Sets the orderbook contract address used for this instance.

    Parameters

    • orderbookAddress: string

      The address of the OrderbookStream contract.

    Returns void

  • Sets the pool diamond contract address used for this instance.

    Parameters

    • diamondAddress: string

      The address of the PremiaDiamond contract.

    Returns void

  • Sets the pool factory contract address used for this instance.

    Parameters

    • factoryAddress: string

      The address of the PoolFactory contract.

    Returns void

  • Sets the user settings contract address used for this instance.

    Parameters

    • userSettings: string

      The address of the UserSettings contract.

    Returns void

  • Sets the VaultMining contract address used for this instance.

    Parameters

    • vaultMiningAddress: string

      The address of the VaultMining contract.

    Returns void

  • Sets the vault registry contract address used for this instance.

    Parameters

    • registryAddress: string

      The address of the VaultRegistry contract.

    Returns void

  • Sets the vxPremia contract address used for this instance.

    Parameters

    • vxPremiaAddress: string

      The address of the VxPremia contract.

    Returns void

Generated using TypeDoc