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

orderbookAddress: string = ...

The address of the Orderbook contract.

poolFactoryAddress: string = ...

The address of the Pool Factory contract.

premia: Premia
stakingAddress: string = ...

The address of the PremiaStaking contract.

userSettingsAddress: string = ...

The address of the UserSettings contract.

vaultRegistryAddress: string = ...

The address of the Vault Registry contract.

vxPremiaAddress: string = ...

The address of the VxPremia contract.

Methods

  • 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 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 novaSigner or novaProvider 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.novaSigner or this.premia.novaProvider.

    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 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 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 SolidStateERC20

    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 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 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 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