📑 Legacy Swap Smart Contract

As per our previous communications, we would like to inform you that the option to swap your legacy tokens will be discontinued after July 17th. After this date, the functionality to exchange your existing legacy tokens will no longer be available. We encourage all token holders to complete any necessary swaps before this deadline to ensure a smooth transition.

TreedefiLegacySwap Contract

The TreedefiLegacySwap contract is designed to handle the swapping of legacy tokens to CarbonToken. It supports three different types of swaps: independent Sale Swaps, Market Swaps (with vest), and Investment Swaps (with vest). This contract should be deployed after the deployment of the three contracts: TREE, SEED, TCO2, and TreedefiCOTAbsorptionSale.

Security Considerations

The contract includes security functions to manage pause and unpause actions. It also includes a function to renounce ownership, leaving the contract without an owner and removing any functionality that is only available to the owner. This function can only be called by the current owner.

The contract also includes a function to transfer ownership of the contract to a new account. This function can only be called by the current owner.

The contract has an upgrade mechanism, allowing the implementation of the proxy to be upgraded to a new implementation. This includes a function to upgrade the implementation and subsequently execute a function call encoded in data.

Swap Mechanism

The contract facilitates the swapping of legacy tokens (SEED, TCO2, or TREE) for Carbon Tokens (COT). It includes functions to perform independent swaps, market swaps, and investment swaps. The contract emits events upon successful swaps.

Oracle Considerations

The contract uses Oracle for price feeds. The contract owner can set the oracle system to get BNB/USD price.

COT withdraw availability

we would like to assure our community that the exact amount of Carbon Offset Tokens (COT) will always be available within the smart contract. This is to facilitate the seamless withdrawal of COT by our token holders at any given time.

Our approach ensures that all necessary tokens are already available in the smart contract, eliminating the need for additional minting. This maintains the integrity of the fixed supply of COT and provides assurance to our users that their tokens will be available for withdrawal as per the smart contract's logic.

Our system is designed with utmost precision to match the number of tokens held in the smart contract with the number of tokens owed to users. This ensures that there is always a one-to-one correspondence between the tokens available and the tokens that can be withdrawn, providing our users with the confidence and assurance that their COT can be accessed whenever they wish.

Other Considerations

The contract includes a function to recover a specific BEP20 token from the contract's balance. It also includes a function to set the documentation URI for this smart contract.

The contract stores the docURI for the specific smart contract. It includes a function to set the doc URI for this smart contract.

The contract includes a function to return the ratio of USD to COT. If 1 COT = 0.50 $, the ratio is 2 ether.

The contract includes a function to get the latest BNB price from oracle.

The contract includes a function to initialize the contract with the specified parameters. As there is no constructor, the libraries need to be initialized explicitly.

The contract includes a function to allow users to immediatly swap their Legacy Tokens using the market price (indipendent swap)

The contract includes a function to allow users to withdraw their vested investment COT tokens after the token sale ends (info got from Sale contract) + investment locking time (two years).

The contract includes a function to allow users to withdraw their vested CarbonTokens (COT) after the vesting period. The amount of COT that can be withdrawn depends on the elapsed time since the user's deposit. The user can withdraw 25%, 50%, 75%, or 100% of their COT tokens based on the elapsed time.

Events

  • AdminChanged: Emitted when the admin is changed.

  • BeaconUpgraded: Emitted when the beacon is upgraded.

  • ChangeDocs: Emitted when docURI is changed.

  • ChangeOracle: Emitted when BNB Oracle feed is changed.

  • Initialized: Emitted when the contract is initialized.

  • InvestmentSwap: Emitted when an Investment Swap is done.

  • MarketSwap: Emitted when a Market Swap is done.

  • OwnershipTransferred: Emitted when the ownership is transferred.

  • Paused: Emitted when the contract is paused.

  • Unpaused: Emitted when the contract is unpaused.

  • Upgraded: Emitted when the contract is upgraded.

  • independentSwap: Emitted when a Market Swap is done.

  • setLegacyFeed: Emitted when a new Legacy Pair feed is enabled.

State Variables

  • MARKET_REVALUATION: A market revaluation for users who want to swap their tokens with an increase of 30%. This value is used on marketSwap() function.

  • _seedWbnbPair: Pairs for swaps (legacy-WBNB).

  • absorptionSale: Address to get Absorption sale status.

Methods

  • DECIMALS: Returns the decimals.

  • FOUR_MONTHS: Returns the four months duration in seconds.

  • INVESTMENT_LOCKING_TIME: Returns the investment locking time.

  • ONE_MONTH: Returns the one month duration in seconds.

  • THREE_MONTHS: Returns the three months duration in seconds.

  • TWO_MONTHS: Returns the two months duration in seconds.

  • VESTING_PERIOD: Returns the vesting periods in seconds.

  • WITHDRAW_PERCENTAGE: Returns the withdraw percentage.

  • getCotValuePerLegacyToken: Calculate how much COT is worth one Legacy Token.

  • getEndSale: Returns the sale end date if it is ended, reverts if the Absorption Sale has not ended yet.

  • getInvestmentSwaps: Function to get the Investment Deposit list.

  • getInvestmentSwapsByTokenCode: Returns the number of Investment Swaps made by a user for a specific token type.

  • getLatestBNBPrice: Get BNB price from oracle.

  • getLegacyCode: Utility functions to get legacy codes.

  • getLegacyTokenWbnbPrice: Fetches the current token-WBNB price from the PancakeSwap V2 pair (or Treedefi Dex).

  • getMarketSwaps: Function to get the Market Deposit list.

  • getMarketSwapsByTokenCode: Returns the number of Market Swaps made by a user for a specific token type.

  • getRatioUSDtoCOT: Return how many COT are worth 1 USD.

  • getSwaps: Get the sum of swaps for the specified token.

  • independentSwapForCot: Implementation of the independent swap feature.

  • initialize: Initializes the contract with the addresses of the legacy tokens and Carbon Offset Token.

  • investmentSwapForCot: Invests the specified amount of legacy tokens (SEED, TCO2, or TREE)

and converts them to COT tokens. The COT will be released after 2 years of the Absorption Sale end date. 1 SEED = 1 COT, 1 TREE = 1 COT, 1 TCO2 = 1 COT. The COT corresponding amount will be stored in the investmentSwapHistory mapping for later withdrawal.

  • isPaused: Verify if the contract is paused or not.

  • marketSwapForCot: Accepts an amount of Legacy Token tokens to swap and vests COT tokens for the user in 12 months. Maximum 3 swaps per token type are allowed.

  • pause: Security functions to manage pause.

  • paused: Returns true if the contract is paused, and false otherwise.

  • proxiableUUID: Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the implementation. It is used to validate the implementation's compatibility when performing an upgrade.

  • recoverTokens: Recover a specific BEP20 token from the contract's balance.

  • renounceOwnership: Leaves the contract without owner. It will not be possible to call onlyOwner functions anymore. Can only be called by the current owner.

  • setDocURI: Sets the documentation URI for this smart contract.

  • setLegacyPairs: Specify where we can get the price of Legacy Tokens. Specify the PancakeSwap v2 pair (or Treedefi Dex).

  • setOracleFeed: Set the oracle system to get BNB/USD price.

  • transferOwnership: Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.

  • unpause: Security functions to manage unpause.

  • upgradeTo: Upgrade the implementation of the proxy to newImplementation. Calls {_authorizeUpgrade}. Emits an {Upgraded} event.

  • upgradeToAndCall: Upgrade the implementation of the proxy to newImplementation, and subsequently execute the function call encoded in data. Calls {_authorizeUpgrade}. Emits an {Upgraded} event.

  • withdrawInvestmentSwap: Allows the users to withdraw their vested investment COT tokens after the token sale ends (info got from Sale contract) + investment locking time (two years).

  • withdrawMarketSwap: This function allows the users to withdraw their vested CarbonTokens (COT) after the vesting period. The amount of COT that can be withdrawn depends on the elapsed time since the user's deposit. The user can withdraw 25%, 50%, 75%, or 100% of their COT tokens based on the elapsed time.

Last updated