Deposit & Withdraw

This section covers the core fund management functions for depositing and withdrawing tokens from the Papaya protocol.

deposit

Deposits tokens into the user's account for streaming payments.

function deposit(uint256 amount, bool isPermit2) external

Parameters

  • amount (uint256): The amount of tokens to deposit

  • isPermit2 (bool): Whether to use Permit2 for the transfer

Description

This function allows users to deposit tokens into their Papaya account. The tokens are transferred from the caller's address to the contract. If isPermit2 is true, the function uses the Permit2 protocol for the transfer.

Example

// Deposit 1000 tokens using standard transfer
await papayaContract.deposit(ethers.utils.parseEther("1000"), false);

// Deposit using Permit2
await papayaContract.deposit(ethers.utils.parseEther("1000"), true);

depositFor

Deposits tokens into a specific user's account.

Parameters

  • amount (uint256): The amount of tokens to deposit

  • to (address): The address to deposit tokens for

  • isPermit2 (bool): Whether to use Permit2 for the transfer

Description

This function allows depositing tokens into another user's account. This is useful for applications that want to fund user accounts on their behalf.

Example

withdraw

Withdraws tokens from the user's account.

Parameters

  • amount (uint256): The amount of tokens to withdraw

Description

Allows users to withdraw their deposited tokens back to their address. The tokens are transferred from the contract to the caller's address.

Example

withdrawTo

Withdraws tokens from the user's account to a specific address.

Parameters

  • to (address): The address to withdraw tokens to

  • amount (uint256): The amount of tokens to withdraw

Description

Allows users to withdraw their deposited tokens to a specific address. This is useful for withdrawing to a different wallet or contract.

Example

pay

Pays tokens directly to a receiver.

Parameters

  • receiver (address): The address to pay tokens to

  • amount (uint256): The amount of tokens to pay

Description

Allows users to pay tokens directly to a receiver without creating a subscription. This is useful for one-time payments.

Example

rescueFunds

Rescues tokens that may be stuck in the contract.

Parameters

  • token (address): The token address to rescue

  • amount (uint256): The amount of tokens to rescue

Description

Allows the contract owner to rescue tokens that may be stuck in the contract. This is an emergency function for recovering funds.

Example

Last updated