Deposit Methods
Deposit methods of Azoth SDK for depositing tokens into the system.
deposit()
deposit()Deposits tokens into AzothPay.
async deposit(amount: bigint | number, isPermit2: boolean = false): Promise<ethers.TransactionResponse>Parameters:
amount: The amount of tokens to deposit, should be formatted usingformatInput()isPermit2(optional): Whether to use Permit2 for the deposit (default: false)
Returns:
An ethers.js
TransactionResponseobject
Example:
// Format the amount correctly (10 USDT with 6 decimals)
const amount = formatInput('10', 6);
// Deposit
const tx = await azoth.deposit(amount);
await tx.wait();
console.log('Deposit successful');depositBySig()
depositBySig()Creates a deposit transaction that can be signed off-chain and executed by anyone.
Parameters:
amount: The amount of tokens to deposit, should be formatted usingformatInput()deadline: Timestamp after which the transaction cannot be executed
Returns:
An ethers.js
TransactionResponseobject
Example:
depositFor()
depositFor()Deposits tokens into another account.
Parameters:
amount: The amount of tokens to deposit, should be formatted usingformatInput()to: The recipient addressisPermit2(optional): Whether to use Permit2 for the deposit (default: false)
Returns:
An ethers.js
TransactionResponseobject
Example:
depositAndSubscribe()
depositAndSubscribe()Deposits tokens and creates a subscription in a single transaction using multicall. This method combines deposit() and subscribe() operations atomically, saving gas and improving user experience.
Parameters:
author: The address of the creator to subscribe toamount: The amount of tokens to deposit (in token units, e.g., "100" for $100)rate: The subscription rate per period (in token units, e.g., "100" for $100/month)period: (Optional) The subscription period (default:RatePeriod.MONTH)projectId: The project ID associated with the subscriptionisPermit2: (Optional) Whether to use Permit2 for deposit (default: false)decimals: (Optional) Token decimals (default: 6 for USDT/USDC)
Returns: An ethers.js TransactionResponse object.
Benefits:
✅ Saves gas by combining two operations into one transaction
✅ Atomic execution: both operations succeed or both fail
✅ Better UX: only one transaction confirmation needed
Example:
Note: The order of operations is important - deposit is executed first, then subscribe. This ensures the account has sufficient balance before creating the subscription.
Last updated