Wrapped SMART Token
wrappedSmartToken
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
DiscountRates private currentDiscountRates;
Functions
constructor
constructor();
riskInitialize
function riskInitialize(
address underlying_,
address sellingToken_,
string memory name_,
string memory symbol_,
uint256 initialRate,
bool isWrappedX_,
address owner_,
address signer,
uint256 timeout_,
address sanctionsContract_
) public initializer;
initialize
function initialize(address underlying_, string memory name_, string memory symbol_, uint256 initialRate)
public
pure
override;
_authorizeUpgrade
function _authorizeUpgrade(address newImplementation) internal override onlyOwner;
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
function flashLoan(
address receiver,
uint256 amount,
bytes memory encodedData,
bytes memory signature,
bytes memory params
) external nonReentrant stopFlashLoan onlyNotSanctioned(receiver) onlyNotSanctioned(_msgSender());
Parameters
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
function setTimeout(uint256 timeout_) external onlyOwner;
setDiscountRate
function setDiscountRate(uint256 startTime, uint256 endTime, uint256 discountMin, uint256 discountMax)
external
onlyOwner;
setSigners
function setSigners(address signer, bool status) external onlyOwner;
getIsWrappedX
function getIsWrappedX() external view returns (bool);
getTimeout
function getTimeout() external view returns (uint256);
getDiscountRate
function getDiscountRate() external view returns (DiscountRates memory);
getSigners
function getSigners(address signer) external view returns (bool);
calculateUserShare
function calculateUserShare() private view returns (uint256);
refundUnwantedTokens
function refundUnwantedTokens(address user) private;
getConversionRate
function getConversionRate(PriceFeed memory priceFeed, uint256 t1, uint256 t2, uint256 x1, uint256 x2)
private
view
returns (uint256, uint256);
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.
function verifyAndDecode(bytes memory signature, bytes memory encodedData) private view returns (PriceFeed memory);
Parameters
signature
bytes
The signature to be verified.
encodedData
bytes
The data to be decoded into a ScheduledRebalance
struct.
Returns
<none>
PriceFeed
data A ScheduledRebalance
struct containing the decoded data.
burn
Burns wrapper tokens from {msg.sender} and transfers the underlying tokens back.
function burn(uint256 amount) public override returns (uint256);
Parameters
amount
uint256
The amount of wrapper tokens to burn.
Returns
<none>
uint256
The amount of underlying tokens withdrawn.
burnTo
Burns wrapper tokens from {msg.sender} and transfers the underlying tokens to the specified beneficiary.
function burnTo(address to, uint256 amount) public override returns (uint256);
Parameters
to
address
The beneficiary account.
amount
uint256
The amount of wrapper tokens to burn.
Returns
<none>
uint256
The amount of underlying tokens withdrawn.
burnAll
Burns all wrapper tokens from {msg.sender} and transfers the underlying tokens back.
function burnAll() public override returns (uint256);
Returns
<none>
uint256
The amount of underlying tokens withdrawn.
burnAllTo
Burns all wrapper tokens from {msg.sender} and transfers the underlying tokens back.
function burnAllTo(address to) public override returns (uint256);
Parameters
to
address
The beneficiary account.
Returns
<none>
uint256
The amount of underlying tokens withdrawn.
withdraw
Burns wrapper tokens from {msg.sender} and transfers the underlying tokens back.
function withdraw(uint256 uAmount) public override returns (uint256);
Parameters
uAmount
uint256
The amount of underlying tokens to withdraw.
Returns
<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.
function withdrawTo(address to, uint256 uAmount) public override returns (uint256);
Parameters
to
address
The beneficiary account.
uAmount
uint256
The amount of underlying tokens to withdraw.
Returns
<none>
uint256
The amount of wrapper tokens burnt.
withdrawAll
Burns all wrapper tokens from {msg.sender} and transfers the underlying tokens back.
function withdrawAll() public override returns (uint256);
Returns
<none>
uint256
The amount of wrapper tokens burnt.
withdrawAllTo
Burns all wrapper tokens from {msg.sender} and transfers the underlying tokens back.
function withdrawAllTo(address to) public override returns (uint256);
Parameters
to
address
The beneficiary account.
Returns
<none>
uint256
The amount of wrapper tokens burnt.
Errors
WrappedSmartToken__Not_Implemented
error WrappedSmartToken__Not_Implemented();
WrappedSmartToken__PriceFeedOutdated
error WrappedSmartToken__PriceFeedOutdated();
WrappedSmartToken__InvalidSigner
error WrappedSmartToken__InvalidSigner();
WrappedSmartToken__InvalidDiscount
error WrappedSmartToken__InvalidDiscount();
Structs
PriceFeed
struct PriceFeed {
uint256 smartTokenXValue;
uint256 smartTokenYValue;
uint256 timestamp;
}
DiscountRates
struct DiscountRates {
uint256 startTime;
uint256 endTime;
uint256 discountMin;
uint256 discountMax;
}
Last updated