Skip to content

createPool

Create a new staking pool where users can stake tokens to earn rewards.

Usage

example.tsx
import { mintclub } from 'mint.club-v2-sdk'
import { useWalletClient } from 'wagmi'
import { base } from 'viem/chains'
 
function CreatePoolExample() {
  const { data: walletClient } = useWalletClient()
 
  const handleCreatePool = async () => {
    await mintclub
      .withWalletClient({
        ...walletClient,
        chain: base,
      } as any)
      .network('base')
      .stake
      .createPool({
        stakingToken: '0x1234567890123456789012345678901234567890',
        isStakingTokenERC20: true,
        rewardToken: '0x0987654321098765432109876543210987654321',
        rewardAmount: BigInt('1000000000000000000'), // 1 token (18 decimals)
        rewardStartsAt: Math.floor(Date.now() / 1000) + 3600, // Start in 1 hour
        rewardDuration: 7 * 24 * 60 * 60, // 7 days in seconds
        onSuccess: (receipt) => {
          console.log('Pool created successfully!', receipt)
        },
        onError: (error) => {
          console.error('Failed to create pool:', error)
        },
      })
  }
 
  return <button onClick={handleCreatePool}>Create Pool</button>
}

Return Value

Promise<TransactionReceipt>

Returns a promise that resolves to a TransactionReceipt object when the transaction is successful.

Parameters

stakingToken

  • Type: '0x${string}'

The address of the token that users will stake in this pool.

await mintclub.network('base').stake.createPool({
  stakingToken: '0x1234567890123456789012345678901234567890', 
  isStakingTokenERC20: true,
  rewardToken: '0x0987654321098765432109876543210987654321',
  rewardAmount: BigInt('1000000000000000000'),
  rewardStartsAt: Math.floor(Date.now() / 1000) + 3600,
  rewardDuration: 7 * 24 * 60 * 60,
})

isStakingTokenERC20

  • Type: boolean

Whether the staking token is an ERC20 token (true) or ERC1155 token (false).

await mintclub.network('base').stake.createPool({
  stakingToken: '0x1234567890123456789012345678901234567890',
  isStakingTokenERC20: true, 
  rewardToken: '0x0987654321098765432109876543210987654321',
  rewardAmount: BigInt('1000000000000000000'),
  rewardStartsAt: Math.floor(Date.now() / 1000) + 3600,
  rewardDuration: 7 * 24 * 60 * 60,
})

rewardToken

  • Type: '0x${string}'

The address of the ERC20 token that will be distributed as rewards.

await mintclub.network('base').stake.createPool({
  stakingToken: '0x1234567890123456789012345678901234567890',
  isStakingTokenERC20: true,
  rewardToken: '0x0987654321098765432109876543210987654321', 
  rewardAmount: BigInt('1000000000000000000'),
  rewardStartsAt: Math.floor(Date.now() / 1000) + 3600,
  rewardDuration: 7 * 24 * 60 * 60,
})

rewardAmount

  • Type: bigint

The total amount of reward tokens to be distributed over the entire duration.

await mintclub.network('base').stake.createPool({
  stakingToken: '0x1234567890123456789012345678901234567890',
  isStakingTokenERC20: true,
  rewardToken: '0x0987654321098765432109876543210987654321',
  rewardAmount: BigInt('1000000000000000000'), 
  rewardStartsAt: Math.floor(Date.now() / 1000) + 3600,
  rewardDuration: 7 * 24 * 60 * 60,
})

rewardStartsAt

  • Type: number

The timestamp (in seconds) when reward distribution should begin.

await mintclub.network('base').stake.createPool({
  stakingToken: '0x1234567890123456789012345678901234567890',
  isStakingTokenERC20: true,
  rewardToken: '0x0987654321098765432109876543210987654321',
  rewardAmount: BigInt('1000000000000000000'),
  rewardStartsAt: Math.floor(Date.now() / 1000) + 3600, 
  rewardDuration: 7 * 24 * 60 * 60,
})

rewardDuration

  • Type: number

The duration (in seconds) over which rewards will be distributed.

await mintclub.network('base').stake.createPool({
  stakingToken: '0x1234567890123456789012345678901234567890',
  isStakingTokenERC20: true,
  rewardToken: '0x0987654321098765432109876543210987654321',
  rewardAmount: BigInt('1000000000000000000'),
  rewardStartsAt: Math.floor(Date.now() / 1000) + 3600,
  rewardDuration: 7 * 24 * 60 * 60, 
})

onSignatureRequest (optional)

  • Type: onSignatureRequest?: () => void;
  • Default: undefined

Callback function for when the user is requested to sign the transaction.

await mintclub.network('base').stake.createPool({
  // ... other parameters
  onSignatureRequest: () => {
    console.log('Please sign the transaction')
  }, 
})

onSigned (optional)

  • Type: onSigned?: (txHash: '0x${string}') => void;
  • Default: undefined

Callback function for when the user signs the transaction.

await mintclub.network('base').stake.createPool({
  // ... other parameters
  onSigned: (txHash) => {
    console.log('Transaction signed:', txHash)
  }, 
})

onSuccess (optional)

  • Type: onSuccess?: (receipt: TransactionReceipt) => void;
  • Default: undefined

Callback function for when the transaction is successful.

await mintclub.network('base').stake.createPool({
  // ... other parameters
  onSuccess: (receipt) => {
    console.log('Pool created successfully!', receipt)
  }, 
})

onError (optional)

  • Type: onError?: (error: unknown) => void;
  • Default: undefined

Callback function for when the transaction fails. This also includes when the user rejects the transaction.

await mintclub.network('base').stake.createPool({
  // ... other parameters
  onError: (error) => {
    console.error('Failed to create pool:', error)
  }, 
})