@bayswap/sdk
Version:
SDK for BaySwap smart contract
78 lines (77 loc) • 2.64 kB
TypeScript
import { JsonRpcProvider, SuiObjectResponse, TransactionBlock } from '@mysten/sui.js';
import { StakeRegistry } from '../types';
import { TxBuilderConfig } from '../sdk';
export interface StakePool {
packageID: string;
poolID: string;
poolType: string;
stakeCoinType: string;
rewardCoinType: string;
startTime: bigint;
endTime: bigint;
rewardRemaining: bigint;
stake: bigint;
reward: bigint;
lastUpdateTime: bigint;
accRewardPerShare: bigint;
}
export interface CreateStakePoolTypes {
stakeCoinType: string;
rewardCoinType: string;
}
export interface CreateStakePoolParams {
duration: bigint;
rewardCoinIds: string[];
rewardAmount: bigint;
}
export interface StakeTypes {
stakeCoinType: string;
rewardCoinType: string;
}
export interface StakeParams {
stakeCoinIds: string[];
stakeAmount: bigint;
}
export interface ClaimTypes {
stakeCoinType: string;
rewardCoinType: string;
}
export interface UnstakeTypes {
stakeCoinType: string;
rewardCoinType: string;
}
export interface UnstakeParams {
amount: bigint;
}
export interface EventCreatedStakePool {
adminCapID: string;
startTime: bigint;
endTime: bigint;
reward: bigint;
}
export interface UserPosition {
owner: string;
positionType: string;
lastAccRewardPerShare: bigint;
stakedAmount: bigint;
}
export declare class StakeModule {
protected _provider: JsonRpcProvider;
protected _registry: StakeRegistry;
protected _poolsParentID: string | undefined;
protected _positionsParentID: string | undefined;
protected _txBuilderConfig: TxBuilderConfig;
constructor(provider: JsonRpcProvider, registry: StakeRegistry, txBuiderConfig: TxBuilderConfig);
parseStorageToSetIDs(): Promise<void>;
getBatchStakePoolInfo(poolID: string[]): Promise<StakePool[]>;
getAllPoolIDs(): Promise<string[]>;
getUserPosition(stakeCoinType: string, rewardCoinType: string, owner: string): Promise<UserPosition | undefined>;
calculatePendingRewards(pool: StakePool, positionLastAccRewardPerShare: bigint, stakedAmount: bigint, now: bigint): bigint;
buildCreateStakePoolUnsignedTx(t: CreateStakePoolTypes, p: CreateStakePoolParams): TransactionBlock;
buildStakeRawTx(t: StakeTypes, p: StakeParams): TransactionBlock;
buildClaimRawTx(t: ClaimTypes): TransactionBlock;
buildMultipleClaimsRawTx(tz: ClaimTypes[]): TransactionBlock;
buildUnstakeRawTx(t: UnstakeTypes, p: UnstakeParams): TransactionBlock;
parsePool(resp: SuiObjectResponse): StakePool;
parseRespToGetAllPositionsID(resp: SuiObjectResponse): string;
}