Wusdn

Git Source

Inherits: ERC20Permit, IWusdn

The WUSDN token is a wrapped version of the USDN token. While USDN is a rebasing token that inflates user balances periodically, WUSDN provides stable balances by increasing in value instead of rebasing.

State Variables

NAME

The name of the WUSDN token.

string internal constant NAME = "Wrapped Ultimate Synthetic Delta Neutral";

SYMBOL

The symbol of the WUSDN token.

string internal constant SYMBOL = "WUSDN";

SHARES_RATIO

Returns the ratio used to convert USDN shares to WUSDN amounts.

This ratio is initialized in the constructor based on the maximum divisor of the USDN token.

uint256 public immutable SHARES_RATIO;

USDN

Returns the address of the USDN token.

IUsdn public immutable USDN;

Functions

constructor

constructor(IUsdn usdn) ERC20(NAME, SYMBOL) ERC20Permit(NAME);

Parameters

NameTypeDescription
usdnIUsdnThe address of the USDN token.

wrap

Wraps a given amount of USDN into WUSDN.

This function may use slightly less than usdnAmount due to rounding errors. For a more precise operation, use wrapShares.

function wrap(uint256 usdnAmount) external returns (uint256 wrappedAmount_);

Parameters

NameTypeDescription
usdnAmountuint256The amount of USDN to wrap.

Returns

NameTypeDescription
wrappedAmount_uint256The amount of WUSDN received.

wrap

Wraps a given amount of USDN into WUSDN.

This function may use slightly less than usdnAmount due to rounding errors. For a more precise operation, use wrapShares.

function wrap(uint256 usdnAmount, address to) external returns (uint256 wrappedAmount_);

Parameters

NameTypeDescription
usdnAmountuint256The amount of USDN to wrap.
toaddress

Returns

NameTypeDescription
wrappedAmount_uint256The amount of WUSDN received.

wrapShares

Wraps a given amount of USDN shares into WUSDN and sends it to a specified address.

function wrapShares(uint256 usdnShares, address to) external returns (uint256 wrappedAmount_);

Parameters

NameTypeDescription
usdnSharesuint256The amount of USDN shares to wrap.
toaddressThe address to receive the WUSDN.

Returns

NameTypeDescription
wrappedAmount_uint256The amount of WUSDN received.

unwrap

Unwraps a given amount of WUSDN into USDN.

function unwrap(uint256 wusdnAmount) external returns (uint256 usdnAmount_);

Parameters

NameTypeDescription
wusdnAmountuint256The amount of WUSDN to unwrap.

Returns

NameTypeDescription
usdnAmount_uint256The amount of USDN received.

unwrap

Unwraps a given amount of WUSDN into USDN.

function unwrap(uint256 wusdnAmount, address to) external returns (uint256 usdnAmount_);

Parameters

NameTypeDescription
wusdnAmountuint256The amount of WUSDN to unwrap.
toaddress

Returns

NameTypeDescription
usdnAmount_uint256The amount of USDN received.

previewWrap

Computes the amount of WUSDN that would be received for a given amount of USDN.

The actual amount received may differ slightly due to rounding errors. For a precise value, use previewWrapShares.

function previewWrap(uint256 usdnAmount) external view returns (uint256 wrappedAmount_);

Parameters

NameTypeDescription
usdnAmountuint256The amount of USDN to wrap.

Returns

NameTypeDescription
wrappedAmount_uint256The estimated amount of WUSDN that would be received.

previewWrapShares

Computes the amount of WUSDN that would be received for a given amount of USDN shares.

function previewWrapShares(uint256 usdnShares) external view returns (uint256 wrappedAmount_);

Parameters

NameTypeDescription
usdnSharesuint256The amount of USDN shares to wrap.

Returns

NameTypeDescription
wrappedAmount_uint256The amount of WUSDN that would be received.

redemptionRate

Returns the exchange rate between WUSDN and USDN.

function redemptionRate() external view returns (uint256 usdnAmount_);

Returns

NameTypeDescription
usdnAmount_uint256The amount of USDN that corresponds to 1 WUSDN.

previewUnwrap

Computes the amount of USDN that would be received for a given amount of WUSDN.

The actual amount received may differ slightly due to rounding errors. For a precise value, use previewUnwrapShares.

function previewUnwrap(uint256 wusdnAmount) external view returns (uint256 usdnAmount_);

Parameters

NameTypeDescription
wusdnAmountuint256The amount of WUSDN to unwrap.

Returns

NameTypeDescription
usdnAmount_uint256The estimated amount of USDN that would be received.

previewUnwrapShares

Computes the amount of USDN shares that would be received for a given amount of WUSDN.

function previewUnwrapShares(uint256 wusdnAmount) external view returns (uint256 usdnSharesAmount_);

Parameters

NameTypeDescription
wusdnAmountuint256The amount of WUSDN to unwrap.

Returns

NameTypeDescription
usdnSharesAmount_uint256The amount of USDN shares that would be received.

totalUsdnBalance

Returns the total amount of USDN held by the contract.

function totalUsdnBalance() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The total amount of USDN held by the contract.

totalUsdnShares

Returns the total amount of USDN shares held by the contract.

function totalUsdnShares() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The total amount of USDN shares held by the contract.

nonces

Returns the current nonce for owner. This value must be included whenever a signature is generated for {permit}. Every successful call to {permit} increases owner's nonce by one. This prevents a signature from being used multiple times.

function nonces(address owner) public view override(IERC20Permit, ERC20Permit) returns (uint256);

_wrap

Wraps a given USDN token amount into WUSDN.

The caller must have already approved the USDN contract to transfer the required amount of USDN. When calling this function, the transfer is always initiated from the msg.sender.

function _wrap(uint256 usdnAmount, address to) private returns (uint256 wrappedAmount_);

Parameters

NameTypeDescription
usdnAmountuint256The amount of USDN tokens to wrap.
toaddressThe address to receive the WUSDN.

Returns

NameTypeDescription
wrappedAmount_uint256The amount of WUSDN received.

_wrapShares

Wraps a given USDN shares amount into WUSDN.

The caller must have already approved the USDN contract to transfer the required amount of USDN shares. When calling this function, the transfer is always initiated from the msg.sender.

function _wrapShares(uint256 usdnShares, address to) private returns (uint256 wrappedAmount_);

Parameters

NameTypeDescription
usdnSharesuint256The amount of USDN shares to wrap.
toaddressThe address to receive the WUSDN.

Returns

NameTypeDescription
wrappedAmount_uint256The amount of WUSDN received.

_unwrap

Unwraps a given WUSDN token amount into USDN.

This function always burns WUSDN tokens from the msg.sender.

function _unwrap(uint256 wusdnAmount, address to) private returns (uint256 usdnAmount_);

Parameters

NameTypeDescription
wusdnAmountuint256The amount of WUSDN to unwrap.
toaddressThe address to receive the USDN.

Returns

NameTypeDescription
usdnAmount_uint256The amount of USDN received.