Skip to main content

User

A User for a PrizePool. Provides read & write functionality for a Prize Pool. Reads use the provider from the PrizePool. Writes use the signer from the contructor. Throws an error if a write is triggered with a signer that does not match the network of the Prize Pool.

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new User(prizePoolMetadata, signer, prizePool)

Creates an instance of a User for a specific PrizePool

Parameters

NameTypeDescription
prizePoolMetadataContract-
signerSignersigner to submit transactions with
prizePoolPrizePoolPrizePool that the User should interact with

Overrides

PrizePool.constructor

Defined in

src/User.ts:24

Properties

address

Readonly address: string

Inherited from

PrizePool.address

Defined in

src/PrizePool.ts:30


chainId

Readonly chainId: number

Inherited from

PrizePool.chainId

Defined in

src/PrizePool.ts:29


contractMetadataList

Readonly contractMetadataList: Contract[]

Inherited from

PrizePool.contractMetadataList

Defined in

src/PrizePool.ts:27


prizePoolContract

Readonly prizePoolContract: Contract

Inherited from

PrizePool.prizePoolContract

Defined in

src/PrizePool.ts:38


prizePoolMetadata

Readonly prizePoolMetadata: Contract

Inherited from

PrizePool.prizePoolMetadata

Defined in

src/PrizePool.ts:33


signer

Readonly signer: Signer

Defined in

src/User.ts:17


signerOrProvider

Readonly signerOrProvider: Signer | Provider

Inherited from

PrizePool.signerOrProvider

Defined in

src/PrizePool.ts:28


ticketContract

ticketContract: Contract

Inherited from

PrizePool.ticketContract

Defined in

src/PrizePool.ts:39


ticketMetadata

ticketMetadata: Contract

Inherited from

PrizePool.ticketMetadata

Defined in

src/PrizePool.ts:34


tokenContract

tokenContract: Contract

Inherited from

PrizePool.tokenContract

Defined in

src/PrizePool.ts:40


tokenMetadata

tokenMetadata: Contract

Inherited from

PrizePool.tokenMetadata

Defined in

src/PrizePool.ts:35

Methods

approveDeposits

approveDeposits(amountUnformatted?, overrides?): Promise<TransactionResponse>

Submits a transaction to set an allowance for deposits into the Prize Pool.

Parameters

NameTypeDescription
amountUnformatted?BigNumberan unformatted and decimal shifted amount to approve for deposits
overrides?Overridesoptional overrides for the transaction creation

Returns

Promise<TransactionResponse>

the transaction response

Defined in

src/User.ts:111


delegateTickets

delegateTickets(address, overrides?): Promise<TransactionResponse>

Delegates the users ticket chance to the provided address

Parameters

NameTypeDescription
addressstringthe address to delegate to
overrides?Overridesoptional overrides for the transaction creation

Returns

Promise<TransactionResponse>

the transaction response

Defined in

src/User.ts:150


deposit

deposit(amountUnformatted, overrides?): Promise<TransactionResponse>

Submits a transaction to deposit a controlled token into the Prize Pool to the Signer.

Parameters

NameTypeDescription
amountUnformattedBigNumberan unformatted and decimal shifted amount to deposit from the prize pool
overrides?Overridesoptional overrides for the transaction creation

Returns

Promise<TransactionResponse>

the transaction response

Defined in

src/User.ts:59


depositAndDelegate

depositAndDelegate(amountUnformatted, to?, overrides?): Promise<TransactionResponse>

Submits a transaction to deposit a controlled token into the Prize Pool to the Signer.

Parameters

NameTypeDescription
amountUnformattedBigNumberan unformatted and decimal shifted amount to deposit from the prize pool
to?string-
overrides?Overridesoptional overrides for the transaction creation

Returns

Promise<TransactionResponse>

the transaction response

Defined in

src/User.ts:77


getDepositAllowance

getDepositAllowance(): Promise<{ allowanceUnformatted: BigNumber ; isApproved: boolean = !allowanceUnformatted.isZero() }>

Fetches the allowance the User has for depositing into the Prize Pool.

Returns

Promise<{ allowanceUnformatted: BigNumber ; isApproved: boolean = !allowanceUnformatted.isZero() }>

the allowance the user has set for deposits

Defined in

src/User.ts:187


getTicketBalance

getTicketBalance(): Promise<BigNumber>

Fetches the Users ticket balance.

Returns

Promise<BigNumber>

the users ticket balance

Defined in

src/User.ts:169


getTicketContract

getTicketContract(): Promise<Contract>

Fetches the addresses to build an instance of an ethers Contract for the Ticket

Returns

Promise<Contract>

an ethers contract for the ticket

Inherited from

PrizePool.getTicketContract

Defined in

src/PrizePool.ts:273


getTicketData

getTicketData(): Promise<TokenData>

Fetches decimals, name and symbol for the Ticket.

Returns

Promise<TokenData>

decimals, name and symbol for the ticket

Inherited from

PrizePool.getTicketData

Defined in

src/PrizePool.ts:201


getTicketDelegate

getTicketDelegate(): Promise<string>

Fetches the address the user has delegated to

Returns

Promise<string>

the address the user has delegated to

Defined in

src/User.ts:196


getTicketTotalSupply

getTicketTotalSupply(): Promise<BigNumber>

Fetches total supply for the Ticket.

Returns

Promise<BigNumber>

the total supply of the ticket

Inherited from

PrizePool.getTicketTotalSupply

Defined in

src/PrizePool.ts:213


getTokenBalance

getTokenBalance(): Promise<BigNumber>

Fetches the Users token (underlying token) balance.

Returns

Promise<BigNumber>

the users underlying token balance

Defined in

src/User.ts:178


getTokenContract

getTokenContract(): Promise<Contract>

Fetches the addresses to build an instance of an ethers Contract for the underlying Token

Returns

Promise<Contract>

an ethers contract for the underlying token

Inherited from

PrizePool.getTokenContract

Defined in

src/PrizePool.ts:296


getTokenData

getTokenData(): Promise<TokenData>

Fetches decimals, name and symbol for the underling Token.

Returns

Promise<TokenData>

decimals, name and symbol for the underling token

Inherited from

PrizePool.getTokenData

Defined in

src/PrizePool.ts:189


getUsersDepositAllowance

getUsersDepositAllowance(usersAddress): Promise<{ allowanceUnformatted: BigNumber ; isApproved: boolean = !allowanceUnformatted.isZero() }>

Fetches a users deposit allowance for the Prize Pool.

Parameters

NameTypeDescription
usersAddressstringthe address to fetch the deposit allowance for

Returns

Promise<{ allowanceUnformatted: BigNumber ; isApproved: boolean = !allowanceUnformatted.isZero() }>

the amount the user has approved for deposits

Inherited from

PrizePool.getUsersDepositAllowance

Defined in

src/PrizePool.ts:159


getUsersPrizePoolBalances

getUsersPrizePoolBalances(usersAddress): Promise<PrizePoolTokenBalances>

Fetches a users balances for the Prize Pool underlying Token and Ticket.

Parameters

NameTypeDescription
usersAddressstringthe users address to fetch balances for

Returns

Promise<PrizePoolTokenBalances>

the users balances for the underlying deposit token and the ticket token

Inherited from

PrizePool.getUsersPrizePoolBalances

Defined in

src/PrizePool.ts:93


getUsersTicketBalance

getUsersTicketBalance(usersAddress): Promise<BigNumber>

Fetches a users balance for the Prize Pools Ticket.

Parameters

NameTypeDescription
usersAddressstringthe address to fetch the balance for

Returns

Promise<BigNumber>

the users ticket balance

Inherited from

PrizePool.getUsersTicketBalance

Defined in

src/PrizePool.ts:114


getUsersTicketDelegate

getUsersTicketDelegate(usersAddress): Promise<string>

Fetches the address a user has delegated to.

Parameters

NameTypeDescription
usersAddressstringthe address to fetch the delegate for

Returns

Promise<string>

the address a user has delegated to

Inherited from

PrizePool.getUsersTicketDelegate

Defined in

src/PrizePool.ts:176


getUsersTicketTwabAt

getUsersTicketTwabAt(usersAddress, unixTimestamp): Promise<BigNumber>

Fetches a users Ticket TWAB at a specific unix timestamp.

Parameters

NameTypeDescription
usersAddressstringthe address to fetch the ticket TWAB for
unixTimestampnumberthe unix timestamp to fetch in seconds

Returns

Promise<BigNumber>

the users TWAB at the requested time

Inherited from

PrizePool.getUsersTicketTwabAt

Defined in

src/PrizePool.ts:129


getUsersTokenBalance

getUsersTokenBalance(usersAddress): Promise<BigNumber>

Fetches a users balance for the Prize Pools underlying Token.

Parameters

NameTypeDescription
usersAddressstringthe address to fetch the balance for

Returns

Promise<BigNumber>

the users token balance

Inherited from

PrizePool.getUsersTokenBalance

Defined in

src/PrizePool.ts:145


id

id(): string

Returns a unique id string for this Prize Pool.

Returns

string

a unique id for the Prize Pool

Inherited from

PrizePool.id

Defined in

src/PrizePool.ts:82


selfDelegateTickets

selfDelegateTickets(overrides?): Promise<TransactionResponse>

Submits a transaction to delegate to ticket chance to the users self

Parameters

NameTypeDescription
overrides?Overridesoptional overrides for the transaction creation

Returns

Promise<TransactionResponse>

the transaction response

Defined in

src/User.ts:132


validateSignerNetwork

validateSignerNetwork(errorPrefix): Promise<void>

Validates the provided signers network. Throws if it does not match the expected network.

Parameters

NameTypeDescription
errorPrefixstringthe class and function name of where the error occurred

Returns

Promise<void>

Defined in

src/User.ts:208


withdraw

withdraw(amountUnformatted, overrides?): Promise<TransactionResponse>

Submits a transaction to withdraw a controlled token from the Prize Pool to the Signer.

Parameters

NameTypeDescription
amountUnformattedBigNumberan unformatted and decimal shifted amount to withdraw from the prize pool
overrides?Overridesoptional overrides for the transaction creation

Returns

Promise<TransactionResponse>

the transaction response

Defined in

src/User.ts:38