doppler-v3-sdk
Version:
SDK for interacting with Doppler v3 protocol
98 lines • 3.54 kB
JavaScript
import { createDrift, } from "@delvtech/drift";
import { derc20Abi } from "../../../abis";
/**
* A class providing read-only access to a DERC20 token contract.
* Enables querying standard ERC20 token properties along with custom vesting
* and minting-related state information.
*/
export class ReadDerc20 {
/**
* Create a ReadDerc20 instance
* @param address - Contract address of the DERC20 token
* @param drift - Drift instance for blockchain interaction (defaults to new instance)
*/
constructor(address, drift = createDrift()) {
this.contract = drift.contract({ abi: derc20Abi, address });
}
/** Get the human-readable name of the token */
async getName() {
return this.contract.read("name");
}
/** Get the symbol/ticker of the token */
async getSymbol() {
return this.contract.read("symbol");
}
/** Get the number of decimals used for token divisions */
async getDecimals() {
return this.contract.read("decimals");
}
/** Get the token URI for the token */
async getTokenURI() {
return this.contract.read("tokenURI");
}
/**
* Get the allowance granted by an owner to a spender
* @param params - Arguments for the allowance contract method
*/
async getAllowance(params) {
return this.contract.read("allowance", params);
}
/**
* Get the token balance of a specific account
* @param account - Address to check balance for
*/
async getBalanceOf(account) {
return this.contract.read("balanceOf", { account });
}
/** Get the total supply of tokens in circulation */
async getTotalSupply() {
return this.contract.read("totalSupply");
}
/** Get the duration (in seconds) of the vesting period */
async getVestingDuration() {
return this.contract.read("vestingDuration");
}
/** Get the timestamp when vesting begins */
async getVestingStart() {
return this.contract.read("vestingStart");
}
/** Get the total amount of tokens allocated for vesting */
async getVestedTotalAmount() {
return this.contract.read("vestedTotalAmount");
}
/** Get the amount of vested tokens available for a specific address */
async getAvailableVestedAmount(account) {
return this.contract.read('computeAvailableVestedAmount', { account });
}
/** Get the current annual mint rate in tokens per year */
async getYearlyMintRate() {
return this.contract.read("yearlyMintRate");
}
/** Get the pool address for the token */
async getPool() {
return this.contract.read("pool");
}
/** Check if the liquidity pool is unlocked */
async getIsPoolUnlocked() {
return this.contract.read("isPoolUnlocked");
}
/** Get the timestamp when token minting begins */
async getCurrentYearStart() {
return this.contract.read("currentYearStart");
}
/** Get the timestamp of the last mint */
async getLastMintTimestamp() {
return this.contract.read("lastMintTimestamp");
}
/**
* Get detailed vesting information for a specific account
* @param account - Address to retrieve vesting data for
* @returns Object containing:
* - totalAmount: Total amount of tokens vested
* - releasedAmount: Amount already claimed
*/
async getVestingData(account) {
return this.contract.read("getVestingDataOf", { account });
}
}
//# sourceMappingURL=ReadDerc20.js.map