📑 Absorption Sale Smart Contract

The TreedefiCOTAbsorptionSale contract is designed to facilitate the swapping of BNB and USDT for Carbon Tokens (COT) using Oracle for price feeds. If the USDT oracle is not available, the contract owner can set the price of USDT / USD.

Security Considerations

The contract includes security functions to manage pause and unpause actions. It also includes a function torenounce 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.

Oracle Considerations

The contract uses Oracle for price feeds. If the USDT oracle is not available, the contract owner can set the price of USDT / USD. The contract emits events when Oracle status is enabled or disabled.

The contract also includes a function to set the oracle fee adapter.

We would like to assure that the oracle will always be available during the swapping process. This is to maintain the integrity of the swap and to ensure that users receive the correct amount of COT tokens based on the current value of USDT.

However, we also recognize that there may be extraordinary circumstances, or force majeure events, that could necessitate the temporary disabling of the oracle. In such rare and exceptional situations, we may revert to the predetermined 'USD to COT' ratio for the swap.

Please be assured that any such changes would only be made in the best interests of our users and the stability of the platform, and would be communicated in a timely manner. We remain committed to providing a fair and transparent swapping process for all our users.

Swap Mechanism

The contract facilitates the swapping of BNB and USDT for Carbon Tokens (COT). It includes functions to swap BNB tokens for COT tokens and to swap USDT for COT. The contract emits a swap event upon successful swap.

Absorption Sale Stages

The contract manages different stages of the absorption sale. Each stage has a name and a price for the COT at that stage. The contract emits an event when the absorption sale stage is changed. The owner can set the ratio from USD to COT for a specific absorption sale stage.

Other Considerations

The contract includes a function to recover a specific BEP20 token from the contract's balance. It also includes a function to send the accrued BNB to a given address.

The contract stores the docn URI 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 and USDT 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.

Events

  • AbsorptionSaleStageChanged: Emitted when the absorption sale stage is changed.

  • AdminChanged: Emitted when the admin is changed.

  • BeaconUpgraded: Emitted when the beacon is upgraded.

  • ChangeDocs: Emitted when docURI is changed.

  • ChangeOracle: Emitted when Oracle feeds are changed.

  • Initialized: Emitted when the contract is initialized.

  • OwnershipTransferred: Emitted when the ownership is transferred.

  • Paused: Emitted when the contract is paused.

  • Swap: Emitted when the absorption sale stage is changed.

  • Unpaused: Emitted when the contract is unpaused.

  • Upgraded: Emitted when the contract is upgraded.

  • usdtOracleActivated: Emitted when Oracle status is enabled.

  • usdtOracleDeactivated: Emitted when Oracle status is disabled.

State Variables

  • docURI: It stores the docn URI for the specific smart contract.

Methods

  • DECIMALS: Returns the decimals.

  • absorptionStages: Stores the different stages of the absorption sale.

  • bnbTokenCode: Returns the BNB token code.

  • contractSwaps: Stores the contract swaps.

  • endSale: Returns the end sale timestamp.

  • finalizeSale: Finalizes the sale when the current stage is the 4th stage.

  • getEndSale: Returns the end sale date.

  • getLatestBNBPrice: Gets BNB price from oracle.

  • getLatestUSDTPrice: Gets USDT price from oracle.

  • getRatioUSDtoCOT: Returns the ratio of USD to COT.

  • initialize: Initialize the contract with the specified parameters.

  • isPaused: Gets information about pause status.

  • isSwapOracle: Returns the status of the oracle usage for swaps.

  • owner: Returns the address of the current owner.

  • pause: Manages pause.

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

  • proxiableUUID: Returns the storage slot used by the implementation.

  • renounceOwnership: Leaves the contract without owner.

  • setDocURI: Sets doc URI for this smart contract.

  • setOracleFeed: Sets oracle fee adapter.

  • setRatioUSDtoCOT: Sets the ratio from USD to COT for the specified absorption sale stage.

  • setUsdtOracleEnabled: Enables the Oracle.

  • swapBNBforCOT: Swaps BNB tokens for COT tokens.

  • swapUSDTforCOT: Swaps USDT for COT.

  • transferOwnership: Transfers ownership of the contract to a new account.

  • unpause: Manages unpause.

  • upgradeTo: Upgrades the implementation of the proxy to newImplementation.

  • upgradeToAndCall: Upgrades the implementation of the proxy to newImplementation, and subsequently execute the function call encoded in data.

  • usdtTokenCode: Returns the USDT token code.

  • withdrawBNB: Sends the accrued BNB to a given address.

  • withdrawTokens: Recovers a specific BEP20 token from the contract's balan

Last updated