@anton-seriesfi/doppler-v3-sdk
Version:
SDK for interacting with Doppler v3 protocol
69 lines • 2.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReadEth = void 0;
const drift_1 = require("@delvtech/drift");
const viem_1 = require("viem");
/**
* A class providing read-only access to Ethereum (ETH) token information and balances.
*
* @remarks
* This class implements a consistent interface with other token implementations (like DERC20)
* but handles ETH-specific behavior such as:
* - Hardcoded token metadata (name, symbol, decimals)
* - Simulating unlimited allowance for ETH transfers
* - Querying native ETH balances through the Drift provider
*/
class ReadEth {
/**
* Create a ReadEth instance
* @param drift - Configured Drift instance for blockchain interactions
* (defaults to new instance with default settings)
*/
constructor(drift = (0, drift_1.createDrift)()) {
this.drift = drift;
}
/**
* Get the human-readable name of the token
* @returns Promise resolving to "Ether" (hardcoded ETH name)
*/
async getName() {
return "Ether";
}
/**
* Get the ticker symbol of the token
* @returns Promise resolving to "ETH" (hardcoded ETH symbol)
*/
async getSymbol() {
return "ETH";
}
/**
* Get the number of decimal places used by the token
* @returns Promise resolving to 18 (standard ETH decimals)
*/
async getDecimals() {
return 18;
}
/**
* Get the allowance granted to a spender (always returns maximum value)
* @returns Promise resolving to 2^256 - 1 (simulates unlimited ETH allowance)
*
* @remarks
* ETH doesn't have an allowance mechanism, so this returns max uint256 value
* to represent unlimited approval in systems expecting ERC20-like interfaces
*/
async getAllowance() {
return 2n ** 256n - 1n;
}
/**
* Get the ETH balance of a specified account
* @param account - Address of the account to query
* @returns Promise resolving to the account's ETH balance in wei
*/
async getBalanceOf(account) {
return this.drift.getBalance({ address: account });
}
}
exports.ReadEth = ReadEth;
/** Static ETH address identifier (zero address) */
ReadEth.address = viem_1.zeroAddress;
//# sourceMappingURL=ReadEth.js.map