@broxus/js-core
Version:
MobX-based JavaScript Core library
142 lines (141 loc) • 8.13 kB
TypeScript
import { type AbiEventName, type Address, type DecodedEvent, type DelayedMessageExecution, type FullContractState, type ProviderRpcClient, type SendInternalParams, type Transaction } from 'everscale-inpage-provider';
import { type VoteEscrowAbi } from '../../models/vote-escrow/abi';
import { type CallId } from '../../types';
export interface VoteEscrowAverage {
lastUpdateTime: number;
veQubeAverage: string;
veQubeAveragePeriod: number;
veQubeBalance: string;
}
export interface VoteEscrowCurrentEpochDetails {
currentEpoch: number;
currentEpochStartTime: number;
currentEpochEndTime: number;
currentVotingStartTime: number;
currentVotingEndTime: number;
currentVotingTotalVotes: number;
}
export interface VoteEscrowDetails {
dao: Address;
distributionSupply: string;
emergency: boolean;
emissionDebt: string;
gaugeWhitelistPrice: string;
initialized?: boolean;
lastUpdateTime: number;
manager: Address;
owner: Address;
paused: boolean;
qube: Address;
qubeBalance: string;
qubeMaxLockTime: number;
qubeMinLockTime: number;
qubeWallet: Address;
teamTokens: string;
treasuryTokens: string;
veQubeBalance: string;
whitelistPayments: string;
}
export type VoteEscrowGaugeWhitelist = (readonly [gaugeAddress: Address, enabled: boolean])[];
export type VoteEscrowGaugeDaoApproved = (readonly [gaugeAddress: Address, enabled: boolean])[];
export interface VoteEscrowVotingDetails {
epochTime: number;
gaugeMaxDowntime: number;
gaugeMaxVotesRatio: number;
gaugeMinVotesRatio: number;
gaugesNum: number;
maxGaugesPerVote: number;
timeBeforeVoting: number;
votingNormalizing: number;
votingTime: number;
}
export type VoteEscrowVotes = (readonly [gaugeAddress: Address, amount: string]);
export interface VoteEscrowNormalizedVoting {
distribution: VoteEscrowVotes[];
emissionDebt: string;
normalizedVotes: VoteEscrowVotes[];
toDistributeTeam: string;
toDistributeTotal: string;
toDistributeTreasury: string;
votes: VoteEscrowVotes[];
}
export interface VoteEscrowCurrentVotingVotes {
currentVotingVotes: VoteEscrowVotes[];
}
export interface VoteEscrowCalcVeMintAbiParams {
qubeAmount: string | number;
lockTime: number;
}
export interface VoteEscrowVoteEpochAbiParams {
meta: CallId & {
nonce: string | number;
sendGasTo: Address | string;
};
votes: VoteEscrowVotes[];
}
export interface VoteEscrowEnvVotingAbiParams {
meta: CallId & {
nonce: string | number;
sendGasTo: Address | string;
};
}
export interface VoteEscrowWithdrawAbiParams {
meta: CallId & {
nonce: string | number;
sendGasTo: Address | string;
};
}
export interface VoteEscrowCastVoteAbiParams {
proposalId: string | number;
support: boolean;
}
export interface VoteEscrowCastVoteWithReasonAbiParams extends VoteEscrowCastVoteAbiParams {
reason: string;
}
export interface VoteEscrowUnlockCastedVotesAbiParams {
proposalIds: string[];
}
export interface VoteEscrowUnlockVoteTokensAbiParams {
proposalId: string;
}
export interface VoteEscrowEncodeDepositPayloadAbiParams extends CallId {
depositOwner: Address | string;
lockTime: string | number;
nonce: string | number;
}
export interface VoteEscrowEncodeWhitelistPayloadAbiParams extends CallId {
nonce: string | number;
whitelistAddress: Address | string;
}
export type VoteEscrowDecodedEvent = DecodedEvent<typeof VoteEscrowAbi, AbiEventName<typeof VoteEscrowAbi>>;
export declare abstract class VoteEscrowUtils {
static voteEpoch(provider: ProviderRpcClient, voteEscrowAddress: Address | string, params: VoteEscrowVoteEpochAbiParams, args?: Partial<SendInternalParams>): Promise<DelayedMessageExecution>;
static endVoting(provider: ProviderRpcClient, voteEscrowAddress: Address | string, params: VoteEscrowEnvVotingAbiParams, args?: Partial<SendInternalParams>): Promise<DelayedMessageExecution>;
static withdraw(provider: ProviderRpcClient, voteEscrowAddress: Address | string, params: VoteEscrowWithdrawAbiParams, args?: Partial<SendInternalParams>): Promise<DelayedMessageExecution>;
static castVote(provider: ProviderRpcClient, voteEscrowAddress: Address | string, params: VoteEscrowCastVoteAbiParams, args: Pick<SendInternalParams, 'from'> & Omit<Partial<SendInternalParams>, 'from'>): Promise<DelayedMessageExecution>;
static castVoteWithReason(provider: ProviderRpcClient, voteEscrowAddress: Address | string, params: VoteEscrowCastVoteWithReasonAbiParams, args: Pick<SendInternalParams, 'from'> & Omit<Partial<SendInternalParams>, 'from'>): Promise<DelayedMessageExecution>;
static tryUnlockCastedVotes(provider: ProviderRpcClient, voteEscrowAddress: Address | string, params: VoteEscrowUnlockCastedVotesAbiParams, args: Pick<SendInternalParams, 'from'> & Omit<Partial<SendInternalParams>, 'from'>): Promise<DelayedMessageExecution>;
static tryUnlockVoteTokens(provider: ProviderRpcClient, voteEscrowAddress: Address | string, params: VoteEscrowUnlockVoteTokensAbiParams, args: Pick<SendInternalParams, 'from'> & Omit<Partial<SendInternalParams>, 'from'>): Promise<DelayedMessageExecution>;
static encodeDepositPayload(connection: ProviderRpcClient, voteEscrowAddress: Address | string, params: VoteEscrowEncodeDepositPayloadAbiParams, cachedState?: FullContractState): Promise<string>;
static encodeWhitelistPayload(connection: ProviderRpcClient, voteEscrowAddress: Address | string, params: VoteEscrowEncodeWhitelistPayloadAbiParams, cachedState?: FullContractState): Promise<string>;
/**
* Real-time calculating vote escrow average
* @param connection
* @param voteEscrowAddress
* @param cachedState
*/
static calculateAverage(connection: ProviderRpcClient, voteEscrowAddress: Address | string, cachedState?: FullContractState): Promise<VoteEscrowAverage>;
static calculateGasForEndVoting(connection: ProviderRpcClient, voteEscrowAddress: Address | string, cachedState?: FullContractState): Promise<string>;
static calculateVeMint(connection: ProviderRpcClient, voteEscrowAddress: Address | string, params: VoteEscrowCalcVeMintAbiParams, cachedState?: FullContractState): Promise<string>;
static currentVotingVotes(connection: ProviderRpcClient, voteEscrowAddress: Address | string, cachedState?: FullContractState): Promise<VoteEscrowCurrentVotingVotes>;
static distributionSchedule(connection: ProviderRpcClient, voteEscrowAddress: Address | string, cachedState?: FullContractState): Promise<string[]>;
static distributionScheme(connection: ProviderRpcClient, voteEscrowAddress: Address | string, cachedState?: FullContractState): Promise<string[]>;
static gaugeDaoApproved(connection: ProviderRpcClient, voteEscrowAddress: Address | string, cachedState?: FullContractState): Promise<VoteEscrowGaugeDaoApproved>;
static gaugeWhitelist(connection: ProviderRpcClient, voteEscrowAddress: Address | string, cachedState?: FullContractState): Promise<VoteEscrowGaugeWhitelist>;
static getCurrentEpochDetails(connection: ProviderRpcClient, voteEscrowAddress: Address | string, cachedState?: FullContractState): Promise<VoteEscrowCurrentEpochDetails>;
static getDetails(connection: ProviderRpcClient, voteEscrowAddress: Address | string, cachedState?: FullContractState): Promise<VoteEscrowDetails>;
static getVotingDetails(connection: ProviderRpcClient, voteEscrowAddress: Address | string, cachedState?: FullContractState): Promise<VoteEscrowVotingDetails>;
static getNormalizedVoting(connection: ProviderRpcClient, voteEscrowAddress: Address | string, cachedState?: FullContractState): Promise<VoteEscrowNormalizedVoting>;
static getVoteEscrowAccountAddress(connection: ProviderRpcClient, voteEscrowAddress: Address | string, ownerAddress: Address | string, cachedState?: FullContractState): Promise<Address>;
static decodeTransactionEvents(connection: ProviderRpcClient, voteEscrowAddress: Address | string, transaction: Transaction): Promise<VoteEscrowDecodedEvent[]>;
}