Skip to main content

Token Manager References

constructor

Creates an instance of the TokenManager class.

Parameters

NameTypeDescriptionRequired
tokenManagerAddressstringThe address of the token manager contract.Yes
web3ProviderRpcProviderThe web3 provider used to interact with the blockchain.Yes
accountAccountThe account used for transactions. If not provided, the default account will be used.No

Return Value

This constructor does not return a value but initializes an instance of the TokenManager class.


underlying

Asynchronously retrieves the underlying token contract.

Parameters

This function does not take any parameters.

Return Value

TypeDescription
Promise<Contract>A promise that resolves with the underlying token contract.

token

Asynchronously retrieves the token share contract.

Parameters

This function does not take any parameters.

Return Value

TypeDescription
Promise<Contract>A promise that resolves with the token share contract.

performanceFees

Asynchronously retrieves the current performance fees.

Parameters

This function does not take any parameters.

Return Value

TypeDescription
Promise<bigint>A promise that resolves with the current performance fees.

depositLimitLow

Asynchronously retrieves the low deposit limit.

Parameters

This function does not take any parameters.

Return Value

TypeDescription
Promise<bigint>A promise that resolves with the low deposit limit.

depositLimitHigh

Asynchronously retrieves the high deposit limit.

Parameters

This function does not take any parameters.

Return Value

TypeDescription
Promise<bigint>A promise that resolves with the high deposit limit.

withdrawalLimitLow

Asynchronously retrieves the low withdraw limit.

Parameters

This function does not take any parameters.

Return Value

TypeDescription
Promise<bigint>A promise that resolves with the low withdraw limit.

withdrawalLimitHigh

Asynchronously retrieves the high withdraw limit.

Parameters

This function does not take any parameters.

Return Value

TypeDescription
Promise<bigint>A promise that resolves with the high withdraw limit.

_withdrawalInfo

Fetches the request withdraw info by user address and id.

Parameters

NameTypeDescriptionRequired
addressstringThe user address.Yes
idBigNumberishThe request withdrawal id.Yes

Return Value

TypeDescription
Promise<WithdrawalInfo>The withdraw request info.

_userWithdrawalLen

Fetches the total number of request withdrawals a user made.

Parameters

NameTypeDescriptionRequired
addressstringThe user address.Yes

Return Value

TypeDescription
Promise<bigint>The total withdrawals.

totalAssets

Fetches the total assets, including the buffered amount, the bridged amount to L1, and the tokens in transit.

Parameters

This function does not take any parameters.

Return Value

TypeDescription
Promise<bigint>The total assets.

withdrawalExchangeRate

Calculates the withdrawal exchange rate for a given epoch.

Parameters

NameTypeDescriptionRequired
epochBigNumberishThe epoch number.Yes

Return Value

TypeDescription
Promise<bigint>The withdrawal exchange rate.

listUserRequestWithdrawal

Lists all withdrawal requests made by a specific user.

Parameters

NameTypeDescriptionRequired
addressstringThe user address.Yes

Return Value

TypeDescription
Promise<Array<RequestWithdrawal>>A promise that resolves with a list of withdrawal info made by the user.

_formatRequestWithdrawal

Formats the withdrawal request based on the provided withdrawal information.

Parameters

This function takes an object with the following properties:

NameTypeDescriptionRequired
claimedbooleanStatus of the claim.Yes
epochnumberThe epoch of the withdrawal.Yes
sharesBigNumberishThe amount in shares.Yes

Return Value

TypeDescription
Promise<RequestWithdrawal>The formatted withdrawal request.

lastUserRequestWithdrawal

Lists the last withdrawal request made by a specific user.

Parameters

NameTypeDescriptionRequired
addressstringThe user address.Yes

Return Value

TypeDescription
Promise<RequestWithdrawal>The last request withdrawal made by the user.

shareToUnderlying

Converts shares token to the underlying amount.

Parameters

NameTypeDescriptionRequired
sharesBigNumberishThe amount in shares.Yes

Return Value

TypeDescription
Promise<bigint>The amount of underlying corresponding to the shares.

UnderlyingToShare

Converts underlying token amount to shares.

Parameters

NameTypeDescriptionRequired
assetsBigNumberishThe amount in underlying.Yes

Return Value

TypeDescription
Promise<bigint>The amount of shares corresponding to the underlying.

Let's continue with the structured Markdown documentation for the remaining function interfaces you've provided. Here's how you can document them:

deposit

Deposits tokens into the token manager.

Parameters

This function takes an object with the following properties:

NameTypeDescriptionRequired
amountbigintThe amount to deposit in underlying token.Yes
receiverstringThe receiver address.Yes
referralstringThe referral address.No
onTxStageChangefunctionTransaction status hook.No

Return Value

TypeDescription
Promise<DepositResponse>The deposit request response data.

requestWithdrawal

Requests withdrawal to the token manager.

Parameters

This function takes an object with the following properties:

NameTypeDescriptionRequired
sharesBigNumberishThe amount of shares user want to convert to underlying.Yes
onTxStageChangefunctionTransaction status hook.No

Return Value

TypeDescription
Promise<RequestWithdrawalResponse>The request withdrawal response data.

claimWithdrawal

Claims a request withdrawal from the token manager by ID.

Parameters

This function takes an object with the following properties:

NameTypeDescriptionRequired
idbigintThe request withdrawal ID.Yes
onTxStageChangefunctionTransaction status hook.No

Return Value

TypeDescription
Promise<string>Transaction hash.

_enoughAllowance

Checks if the user has enough allowance to the token manager.

Parameters

NameTypeDescriptionRequired
addressstringThe user address.Yes
assetsbigintThe amount in underlying token.Yes

Return Value

TypeDescription
Promise<boolean>Whether the user has enough allowance.

_validateDepositLimit

Validates the deposit call data.

Parameters

NameTypeDescriptionRequired
assetsbigintThe amount in underlying token.Yes

Return Value

This function does not return a value but throws an error if validation fails.


_validateRequestWithdraw

Validates the request withdraw call data.

Parameters

NameTypeDescriptionRequired
addressstringThe user address.Yes
sharesbigintThe amount in share token.Yes

Return Value

This function does not return a value but throws an error if validation fails.


_validateClaimWithdrawal

Validates the claim request withdraw call data.

Parameters

NameTypeDescriptionRequired
addressstringThe user address.Yes
idbigintThe request withdraw ID.Yes

Return Value

This function does not return a value but throws an error if validation fails.