Wrapped SMART Token

wrappedSmartToken

Git Source

Inherits: UnbuttonToken, UUPSUpgradeable, OwnableUpgradeable, ReentrancyGuardUpgradeable, FlashloanSpecifics, BaseContract

State Variables

sellingToken

address private sellingToken;

isWrappedX

bool private isWrappedX;

timeout

uint256 private timeout;

SCALING_FACTOR

uint256 private constant SCALING_FACTOR = 10 ** 18;

signers

This is the signers address of RP api's that generate encoded params for rebalance

mapping(address => bool) private signers;

currentDiscountRates

Functions

constructor

riskInitialize

initialize

_authorizeUpgrade

flashLoan

Allows user to take flashloans from the wrapper

This function is guarded by the nonReentrant modifiers. we offer unwanted tokens (sellingToken) in exchange of underlying tokens

Parameters

Name
Type
Description

receiver

address

The address of the receiver.

amount

uint256

The amount of underlying assets to flashloan.

encodedData

bytes

signature

bytes

params

bytes

The parameters for the flashloan. Used by the receiver contract(Aave's interface)

setTimeout

setDiscountRate

setSigners

getIsWrappedX

getTimeout

getDiscountRate

getSigners

calculateUserShare

refundUnwantedTokens

getConversionRate

verifyAndDecode

Verifies the provided signature and decodes the encoded data into ScheduledRebalance struct.

It recovers the address from the Ethereum signed message hash and the provided signature. If the recovered address doesn't match the signersAddress, it reverts the transaction. If the signature is valid, it decodes the encodedData into a ScheduledRebalance struct and returns it.

Parameters

Name
Type
Description

signature

bytes

The signature to be verified.

encodedData

bytes

The data to be decoded into a ScheduledRebalance struct.

Returns

Name
Type
Description

<none>

PriceFeed

data A ScheduledRebalance struct containing the decoded data.

burn

Burns wrapper tokens from {msg.sender} and transfers the underlying tokens back.

Parameters

Name
Type
Description

amount

uint256

The amount of wrapper tokens to burn.

Returns

Name
Type
Description

<none>

uint256

The amount of underlying tokens withdrawn.

burnTo

Burns wrapper tokens from {msg.sender} and transfers the underlying tokens to the specified beneficiary.

Parameters

Name
Type
Description

to

address

The beneficiary account.

amount

uint256

The amount of wrapper tokens to burn.

Returns

Name
Type
Description

<none>

uint256

The amount of underlying tokens withdrawn.

burnAll

Burns all wrapper tokens from {msg.sender} and transfers the underlying tokens back.

Returns

Name
Type
Description

<none>

uint256

The amount of underlying tokens withdrawn.

burnAllTo

Burns all wrapper tokens from {msg.sender} and transfers the underlying tokens back.

Parameters

Name
Type
Description

to

address

The beneficiary account.

Returns

Name
Type
Description

<none>

uint256

The amount of underlying tokens withdrawn.

withdraw

Burns wrapper tokens from {msg.sender} and transfers the underlying tokens back.

Parameters

Name
Type
Description

uAmount

uint256

The amount of underlying tokens to withdraw.

Returns

Name
Type
Description

<none>

uint256

The amount of wrapper tokens burnt.

withdrawTo

Burns wrapper tokens from {msg.sender} and transfers the underlying tokens back to the specified beneficiary.

Parameters

Name
Type
Description

to

address

The beneficiary account.

uAmount

uint256

The amount of underlying tokens to withdraw.

Returns

Name
Type
Description

<none>

uint256

The amount of wrapper tokens burnt.

withdrawAll

Burns all wrapper tokens from {msg.sender} and transfers the underlying tokens back.

Returns

Name
Type
Description

<none>

uint256

The amount of wrapper tokens burnt.

withdrawAllTo

Burns all wrapper tokens from {msg.sender} and transfers the underlying tokens back.

Parameters

Name
Type
Description

to

address

The beneficiary account.

Returns

Name
Type
Description

<none>

uint256

The amount of wrapper tokens burnt.

Errors

WrappedSmartToken__Not_Implemented

WrappedSmartToken__PriceFeedOutdated

WrappedSmartToken__InvalidSigner

WrappedSmartToken__InvalidDiscount

Structs

PriceFeed

DiscountRates

Last updated