Wrappers

Wrapped smart tokensare a specialized form of SMART Tokens designed to simplify user interactions and provide a stable representation of a user's share in the total deposit pool. By wrapping smart tokens, we create a fixed balance representation, where the ratio of a user's balance to the total supply represents their proportionate share of the underlying assets.

1. Customization & Utility

Built on top of Buttonwood’s Unbutton contracts, these wrapped smart tokens have been customized specifically to meet the unique requirements of the Risk Protocol. This customization allows us to integrate the advanced features of SMART Tokens while providing users with a more accessible and user-friendly interface.

Benefits and Usage of Wrapped Smart Tokens

  1. Simplified User Experience:

    • Accessibility for non-technical users: Unlike smart tokens, which may experience balance fluctuations due to rebalancing, wrapped smart tokens maintain a fixed balance. This means users don’t need to worry about understanding or managing the complex mechanics of rebalancing, making it easier for them to hold and interact with the tokens.

    • Stable Proportional Ownership: The ratio of a user’s balance to the total supply of wrapped smart tokens directly represents their share of the total deposit pool. This proportional ownership model ensures that users can easily track their investment in the protocol without dealing with fluctuating balances.

  2. Extended Utilities:

    • Composability: By wrapping smart tokens, we ensure compatibility with a variety of DeFi protocols and applications that may not natively support the rebalancing properties of the original SMART Tokens. This opens up additional avenues for users to utilize their tokens, such as creating liquidity pools on DEXs, in lending/borrowing and yield farming.

    • Access to Flashloans: Users can participate in Flashloans using unwanted tokens held by the Wrapped SMART Token contracts, providing opportunities for arbitrage. For more info, check the Flashloan section.

2. Wrap

The Wrap function enables users to convert their SMART tokens (RiskON or RiskOFF) into Wrapped SMART tokens. By depositing SMART tokens, users receive a proportional share of wrapped tokens representing their stake in the total deposit pool.

Wrap Algorithm: wrappedTokens = (depositAmount × totalSupply) / totalUnderlying

Key Functions

  • Deposit Method: Converts a specific amount of underlying SMART Tokens into wrapped tokens.

    • Parameters:

      1. uAmount: The amount of underlying SMART tokens to deposit

  • DepositFor Method: Deposits SMART tokens and mints wrapped tokens to a specified recipient.

    • Parameters:

      1. to: The recipient address for wrapped tokens

      2. uAmount: The amount of underlying SMART tokens to deposit

Process

  1. Preparation

    • User holds SMART Tokens (RiskON or RiskOFF)

    • User approves the Wrapped SMART Token contract to transfer their tokens

  2. Execution

    • User calls deposit(uAmount) specifying the amount of SMART Tokens to wrap

    • Contract calculates proportional wrapped tokens based on current exchange rate

  3. Conversion

    • The wrapped token amount is calculated as: wrappedAmount = (uAmount × totalSupply) / totalUnderlying, ensuring users receive a proportional share of the total pool

3. Unwrap

The Unwrap function enables users to convert their Wrapped SMART Tokens back into the underlying SMART Tokens. When unwrapping, users also receive their proportional share of any "unwanted tokens" (see Flashloans for explanation) that have accumulated (through rebalances) in the wrapper.

Unwrap Algorithm: underlyingAmount = (wrappedAmount × totalUnderlying) / totalSupply

Key Functions

  • Withdraw Method: Converts a specific amount of underlying back by burning the required wrapped tokens.

    • Parameters:

      1. uAmount: The amount of underlying SMART Tokens to withdraw

  • WithdrawTo Method: Withdraws underlying tokens to a specified recipient.

    • Parameters:

      1. to: The recipient address for underlying token

      2. uAmount: The amount of underlying SMART Tokens to withdraw

Process

  1. Preparation

    • User holds Wrapped SMART tokens

  2. Execution

    • User calls withdraw(uAmount) specifying how much to unwrap

    • Contract calculates proportional underlying based on current exchange rate

  3. Conversion

    • The underlying amount is calculated as: underlyingAmount = (wrappedAmount × totalUnderlying) / totalSupply

    • Additionally, users receive their proportional share of unwanted tokens: unwantedTokenShare = (unwantedBalance × userShare) / totalSupply

Last updated