Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DripsHubClient

A client for interacting with the DripsHub.

Hierarchy

  • DripsHubClient

Index

Constructors

Properties

#contractAddress: string
#driver: DripsHub
#provider: Provider
#signer: undefined | Signer

Accessors

  • get contractAddress(): string
  • get provider(): Provider
  • get signer(): undefined | Signer
  • Returns the DripsHubClient's signer.

    This is the user to which the DripsHubClient is linked and manages Drips.

    Note that for read-only client instances created with the {@link createReadonly} method it returns undefined.

    Returns undefined | Signer

Methods

  • cycleSecs(): Promise<number>
  • dripsState(userId: string, tokenAddress: string): Promise<DripsState>
  • Returns the user's drips state.

    throws

    {@link DripsErrors.addressError} if the tokenAddress is not valid.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    Parameters

    • userId: string

      The user ID.

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    Returns Promise<DripsState>

    A Promise which resolves to the DripsState.

  • getCollectableBalanceForUser(userId: string, tokenAddress: string): Promise<CollectableBalance>
  • Returns the user's collectable balance. Collectable balance contains the user's funds that are already split and ready to be collected.

    throws

    {@link DripsErrors.addressError} if the tokenAddress address is not valid.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    Parameters

    • userId: string

      user ID.

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    Returns Promise<CollectableBalance>

    A Promise which resolves to the the collectable balance.

  • getDripsBalanceAt(userId: string, tokenAddress: string, receivers: DripsReceiverStruct[], timestamp: BigNumberish): Promise<bigint>
  • Returns the user's drips balance at a given timestamp. Drips balance contains the funds the user can stream to other users.

    throws

    {@link DripsErrors.argumentMissingError} if any of the required parameters is missing.

    throws

    {@link DripsErrors.addressError} if the tokenAddress is not valid.

    throws

    {@link DripsErrors.argumentError} if receivers' count exceeds the max allowed drips receivers.

    throws

    {@link DripsErrors.dripsReceiverError} if any of the the receivers is not valid.

    throws

    {@link DripsErrors.dripsReceiverConfigError} if any of the receivers' configuration is not valid.

    Parameters

    • userId: string

      The user ID.

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    • receivers: DripsReceiverStruct[]

      The users's current drips receivers.

    • timestamp: BigNumberish

      The timestamp for which the balance should be calculated. It can't be lower than the timestamp of the last call to setDrips. If it's bigger than block.timestamp, then it's a prediction assuming that setDrips won't be called before timestamp.

    Returns Promise<bigint>

    A Promise which resolves to the user balance on timestamp.

  • getReceivableBalanceForUser(userId: string, tokenAddress: string, maxCycles: BigNumberish): Promise<ReceivableBalance>
  • Calculates the user's receivable balance for the given token. Receivable balance contains the funds other users drip to and is updated once every cycle.

    throws

    {@link DripsErrors.addressError} if the tokenAddress address is not valid.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    throws

    {@link DripsErrors.argumentError} if maxCycles is not valid.

    Parameters

    • userId: string

      The user ID.

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    • maxCycles: BigNumberish

      The maximum number of received drips cycles. Must be greater than 0. If too low, receiving will be cheap, but may not cover many cycles. If too high, receiving may become too expensive to fit in a single transaction.

    Returns Promise<ReceivableBalance>

    A Promise which resolves to the receivable balance.

  • Calculates the result of splitting an amount using the user's current splits configuration.

    throws

    {@link DripsErrors.argumentMissingError} if any of the required parameters is missing.

    throws

    {@link DripsErrors.argumentError} if amount or currentReceivers' is not valid.

    throws

    {@link DripsErrors.splitsReceiverError} if any of the currentReceivers is not valid.

    Parameters

    • userId: string

      The user ID.

    • currentReceivers: SplitsReceiverStruct[]

      The current splits receivers.

    • amount: BigNumberish

      The amount being split. It must be greater than 0.

    Returns Promise<SplitResult>

    A Promise which resolves to the split result.

  • getSplittableBalanceForUser(userId: string, tokenAddress: string): Promise<SplittableBalance>
  • Returns the user's splittable balance for the given token. Splittable balance contains the user's received but not split yet funds.

    throws

    {@link DripsErrors.addressError} if the tokenAddress address is not valid.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    Parameters

    • userId: string

      user ID.

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    Returns Promise<SplittableBalance>

    A Promise which resolves to the the splittable balance.

  • getSqueezableBalance(userId: string, tokenAddress: string, senderId: string, historyHash: string, dripsHistory: DripsHistoryStruct[]): Promise<bigint>
  • Calculates the user's squeezable balance. Squeezable balance contains the funds that can be received from the currently running cycle from a single sender.

    throws

    {@link DripsErrors.addressError} if the tokenAddress address is not valid.

    throws

    {@link DripsErrors.argumentMissingError} if any of the required parameters is missing.

    Parameters

    • userId: string

      The ID of the user receiving drips to squeeze funds for.

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    • senderId: string

      The ID of the user sending drips to squeeze funds from.

    • historyHash: string

      The sender's history hash which was valid right before they set up the sequence of configurations described by dripsHistory.

    • dripsHistory: DripsHistoryStruct[]

      The sequence of the sender's drips configurations.

    Returns Promise<bigint>

    A Promise which resolves to the the squeezable balance.

  • getTokenBalance(tokenAddress: string): Promise<bigint>
  • Returns the total amount currently stored in DripsHub for the given token.

    throws

    {@link DripsErrors.addressError} if the tokenAddress address is not valid.

    Parameters

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    Returns Promise<bigint>

    A Promise which resolves to the balance of the token.

  • receivableCyclesCount(userId: string, tokenAddress: string): Promise<number>
  • Returns the count of cycles from which drips can be collected. This method can be used to detect if there are too many cycles to analyze in a single transaction.

    throws

    {@link DripsErrors.addressError} if the tokenAddress address is not valid.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    Parameters

    • userId: string

      The user ID.

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    Returns Promise<number>

    A Promise which resolves to the number of receivable cycles.

  • receiveDrips(userId: string, tokenAddress: string, maxCycles: BigNumberish): Promise<ContractTransaction>
  • Receives user's drips. Calling this function does not collect but makes the funds ready to split and collect.

    throws

    {@link DripsErrors.addressError} if the tokenAddress address is not valid.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    throws

    {@link DripsErrors.argumentError} if maxCycles is not valid.

    Parameters

    • userId: string

      The user ID.

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    • maxCycles: BigNumberish

      The maximum number of received drips cycles. Must be greater than 0. If too low, receiving will be cheap, but may not cover many cycles. If too high, receiving may become too expensive to fit in a single transaction.

    Returns Promise<ContractTransaction>

    A Promise which resolves to the contract transaction.

  • split(userId: BigNumberish, tokenAddress: string, currentReceivers: SplitsReceiverStruct[]): Promise<ContractTransaction>
  • Splits user's received but not split yet funds among receivers.

    throws

    {@link DripsErrors.addressError} if the tokenAddress address is not valid.

    throws

    {@link DripsErrors.argumentMissingError} if currentReceivers are missing.

    throws

    {@link DripsErrors.argumentError} if currentReceivers' count exceeds the max allowed splits receivers.

    throws

    {@link DripsErrors.splitsReceiverError} if any of the currentReceivers is not valid.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    Parameters

    • userId: BigNumberish

      The user ID.

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    • currentReceivers: SplitsReceiverStruct[]

      The current splits receivers.

    Returns Promise<ContractTransaction>

    A Promise which resolves to the contract transaction.

  • squeezeDrips(userId: string, tokenAddress: string, senderId: BigNumberish, historyHash: string, dripsHistory: DripsHistoryStruct[]): Promise<ContractTransaction>
  • Receives drips from the currently running cycle from a single sender. It doesn't receive drips from the previous, finished cycles, to do that use receiveDrips. Squeezed funds won't be received in the next calls to squeezeDrips or receiveDrips. Only funds dripped before block.timestamp can be squeezed.

    Tip: you might want to use DripsSubgraphClient.getArgsForSqueezingAllDrips to easily populate the arguments for squeezing all Drips up to "now".

    throws

    {DripsErrors.addressError} if the tokenAddress address is not valid.

    throws

    {DripsErrors.argumentMissingError} if any of the required parameters is missing.

    Parameters

    • userId: string

      The ID of the user receiving drips to squeeze funds for.

    • tokenAddress: string

      The ERC20 token address.

      It must preserve amounts, so if some amount of tokens is transferred to an address, then later the same amount must be transferrable from that address. Tokens which rebase the holders' balances, collect taxes on transfers, or impose any restrictions on holding or transferring tokens are not supported. If you use such tokens in the protocol, they can get stuck or lost.

    • senderId: BigNumberish

      The ID of the user sending drips to squeeze funds from.

    • historyHash: string

      The sender's history hash which was valid right before they set up the sequence of configurations described by dripsHistory.

    • dripsHistory: DripsHistoryStruct[]

      The sequence of the sender's drips configurations. It can start at an arbitrary past configuration, but must describe all the configurations which have been used since then including the current one, in the chronological order. Only drips described by dripsHistory will be squeezed. If dripsHistory entries have no receivers, they won't be squeezed.

    Returns Promise<ContractTransaction>

    A Promise which resolves to the contract transaction.

  • create(provider: Provider, signer?: Signer, customDriverAddress?: string): Promise<DripsHubClient>
  • Creates a new immutable DripsHubClient instance.

    throws

    {@link DripsErrors.initializationError} if the client initialization fails.

    Parameters

    • provider: Provider

      The network provider. It cannot be changed after creation.

      The provider must be connected to one of the following supported networks:

      • 'mainnet': chain ID 1
      • 'goerli': chain ID 5
      • 'polygon-mumbai': chain ID 80001
    • Optional signer: Signer

      The singer used to sign transactions. It cannot be changed after creation.

      Important: If the signer is not connected to a provider it will try to connect to the provider, else it will use the signer.provider.

    • Optional customDriverAddress: string

      Overrides the NFTDriver contract address. If it's undefined (default value), the address will be automatically selected based on the provider's network.

    Returns Promise<DripsHubClient>

    A Promise which resolves to the new client instance.

Generated using TypeDoc