Liquid Splits

Liquid Splits

Begin by importing LiquidSplitClient into your app. If you are using the SplitsClient, you can access the liquid split client as well.

import { LiquidSplitClient } from '@0xsplits/splits-sdk'
 
const liquidSplitClient = new LiquidSplitClient({
  chainId,
  publicClient, // viem public client (optional, required if using any of the contract functions)
  walletClient, // viem wallet client (optional, required if using any contract write functions. must have an account already attached)
  includeEnsNames, // boolean, defaults to false. If true, will return ens names for any liquid split holder (only for mainnet)
  // If you want to return ens names on chains other than mainnet, you can pass in a mainnet public client
  // here. Be aware though that the ens name may not necessarily resolve to the proper address on the
  // other chain for non EOAs (e.g. Gnosis Safe's)
  ensPublicClient, // viem public client (optional)
  apiConfig: {
    apiKey: string // You can create an API key by signing up on our app, and accessing your account settings at app.splits.org/settings.
  }, // Splits GraphQL API key config, this is required for the data client to access the splits graphQL API.
})

OR

import { SplitsClient } from '@0xsplits/splits-sdk'
 
const splitsClient = new SplitsClient({
  chainId,
  publicClient,
  walletClient,
  includeEnsNames,
  ensPublicClient,
})
 
const liquidSplitClient = splitsClient.liquidSplits

Liquid Split Writes

These functions make it easier to call Liquid Split functions.

createLiquidSplit

Creates a new Liquid Split contract.

Usage

const args = {
  holders: [
    {
      address: '0x442C01498ED8205bFD9aaB6B8cc5C810Ed070C8f',
      percentAllocation: 50.0,
    },
    {
      address: '0xc3313847E2c4A506893999f9d53d07cDa961a675',
      percentAllocation: 50.0,
    },
  ],
  distributorFeePercent: 1.0,
  owner: '0x442C01498ED8205bFD9aaB6B8cc5C810Ed070C8f',
}
 
const response = await liquidSplitClient.createLiquidSplit(args)

Arguments

{
  holders: {
    address: string
    percentAllocation: number # >0 and <100 and up to 1 decimal
  }[]
  distributorFeePercent: number # <10 and up to 4 decimals
  owner?: string # defaults to signer
}

Response

{
  liquidSplitAddress: string
  event: Log # CreateLS1155Clone emitted on LiquidSplitFactory
}

distributeToken

Distributes the current token balance for the given liquid split to the current NFT holders

Usage

const args = {
  liquidSplitAddress: '0xb5Ce41320F3d486671918733BB3226E3981Db62b',
  token: '0x64d91f12ece7362f91a6f8e7940cd55f05060b92',
  distributorAddress: '0x2fa128274cfcf47afd4dc03cd3f2a59af09b6a72',
}
 
const response = await liquidSplitClient.distributeToken(args)

Arguments

{
  liquidSplitAddress: string
  token: string
  distributorAddress?: string # defaults to signer
}

Response

{
  event: Log # DistributeETH or DistributeERC20 emitted on the Liquid Split contract
}

transferOwnership

Transfer ownership of the given liquid split to the newOwner. Only callable by the owner of the liquid split contract.

Usage

const args = {
  liquidSplitAddress: '0xb5Ce41320F3d486671918733BB3226E3981Db62b',
  newOwner: '0x2fa128274cfcf47afd4dc03cd3f2a59af09b6a72',
}
 
const response = await liquidSplitClient.transferOwnership(args)

Arguments

{
  liquidSplitAddress: string
  newOwner: string
}

Response

{
  event: Log # OwnershipTransferred emitted on the Liquid Split contract
}

Gas Estimation

The client has a gas estimation feature that can be used with any of the above write functions. Just call the function off of the estimateGas property. Estimating the gas for the create liquid split function would look like:

const args = {
  holders: [
    {
      address: '0x442C01498ED8205bFD9aaB6B8cc5C810Ed070C8f',
      percentAllocation: 50.0,
    },
    {
      address: '0xc3313847E2c4A506893999f9d53d07cDa961a675',
      percentAllocation: 50.0,
    },
  ],
  distributorFeePercent: 1.0,
  owner: '0x442C01498ED8205bFD9aaB6B8cc5C810Ed070C8f',
}
 
const gasEstimate = await liquidSplitClient.estimateGas.createLiquidSplit(args)

CallData

The client has a call data feature that can be used with any of the above write functions. Just call the function off of the callData property. Generating call data for the create liquid split function would look like:

const args = {
  holders: [
    {
      address: '0x442C01498ED8205bFD9aaB6B8cc5C810Ed070C8f',
      percentAllocation: 50.0,
    },
    {
      address: '0xc3313847E2c4A506893999f9d53d07cDa961a675',
      percentAllocation: 50.0,
    },
  ],
  distributorFeePercent: 1.0,
  owner: '0x442C01498ED8205bFD9aaB6B8cc5C810Ed070C8f',
}
 
const callData = await liquidSplitClient.callData.createLiquidSplit(args)

Liquid Split Reads

These functions make it easier to query the Liquid Split contracts.

getDistributorFee

Returns the distributor fee of a given liquidSplitAddress.

Usage

const args = {
  liquidSplitAddress: '0xb5Ce41320F3d486671918733BB3226E3981Db62b',
}
 
const response = await liquidSplitClient.getDistributorFee(args)

Arguments

{
  liquidSplitAddress: string
}

Response

{
  distributorFee: number
}

getPayoutSplit

Returns the payout split of a given liquidSplitAddress.

Usage

const args = {
  liquidSplitAddress: '0xb5Ce41320F3d486671918733BB3226E3981Db62b',
}
 
const response = await liquidSplitClient.getPayoutSplit(args)

Arguments

{
  liquidSplitAddress: string
}

Response

{
  payoutSplitId: string
}

getOwner

Returns the owner of a given liquidSplitAddress.

Usage

const args = {
  liquidSplitAddress: '0xb5Ce41320F3d486671918733BB3226E3981Db62b',
}
 
const response = await liquidSplitClient.getOwner(args)

Arguments

{
  liquidSplitAddress: string
}

Response

{
  owner: string
}

getUri

Returns the uri of a given liquidSplitAddress.

Usage

const args = {
  liquidSplitAddress: '0xb5Ce41320F3d486671918733BB3226E3981Db62b',
}
 
const response = await liquidSplitClient.getUri(args)

Arguments

{
  liquidSplitAddress: string
}

Response

{
  uri: string
}

getScaledPercentBalanceOf

Returns the current percent ownership of a given liquidSplitAddress for an address.

Usage

const args = {
  liquidSplitAddress: '0xb5Ce41320F3d486671918733BB3226E3981Db62b',
  address: '0x2fa128274cfcf47afd4dc03cd3f2a59af09b6a72',
}
 
const response = await liquidSplitClient.getScaledPercentBalanceOf(args)

Arguments

{
  liquidSplitAddress: string
  address: string
}

Response

{
  scaledPercentBalance: number
}