Teneo Finance
  • Welcome to the Teneo Project
  • Introduction
    • ⚙️ How it works ⚙️
    • 🙋🏻 Example: Ether and Pether
    • 🙋🏿‍♂️ Example: Adam and the Arbitrage
    • 🙋🏽‍♀️ Example: Paula the Project CEO
  • tenXXX Token Ecosystem
    • 💱 tenXXX Tokens 💱
    • ⛓⚖️ AMM ⚖️⛓
    • ⛓ Underlying Token ⛓
    • ⚖️ Liquidity Pools on DEX ⚖️
    • 🏛👛 DAO Wallet 👛🏛
  • Teneo Token Ecosystem
    • 💎Teneo Tokenomics
    • 🚆ROADMAP
  • Interface Guide
    • 🔛Swap
    • 🥃Add Liquidity
    • 🏦Get DEI
    • 🌉Bridge $TEN
  • MISC
    • 🔛Contracts
    • 🥃Audits
  • FAQ
    • 💎Get tenXXX Token
    • ❓FAQ for Hodler
    • 🐞Known Issues
      • 🐛DEX Swap UI
      • 🐞Wrong decimals at scan sides
  • Testnet
    • 🥸Testnet Guide
    • 📔Testnet Contracts
  • Contract Documentation
    • Contracts on BSC Mainnet
    • AMM ERC
    • AMM ETH
    • TenToken
Powered by GitBook
On this page

Was this helpful?

  1. Contract Documentation

AMM ETH

The AMMs are used to swap a pegged token to the tenXXX version of the token and the other way around.

Functions

  • toggleBuy() external onlyOwner returns (bool)

  • canBuy() external view returns (bool)

  • getTenToken() external view returns (address)

  • buy(uint256 tokenAmount) external nonReentrant payable returns (bool)

  • sell(uint256 tokenAmount) external nonReentrant returns (bool)

  • getInPrice(uint256 amount) external view returns (uint256)

  • getOutPrice(uint256 amount) external view returns (uint256)

toggleBuy() external onlyOwner returns (bool)

Toggles the possibility to buy over the amm.

function toggleBuy() external onlyOwner returns (bool) {
        _canBuy = !_canBuy;
        return _canBuy;
    }

canBuy() external view returns (bool)

Getter for the possibility to buy over the amm.

function canBuy() external view returns (bool) {
        return _canBuy;
    }

getTenToken() external view returns (address)

Returns the ten-Token address.

function getTenToken() external view returns (address) {
        return address(_tenToken);
    }

buy(uint256 tokenAmount) external nonReentrant payable returns (bool)

Mints new ten-Tokens for the sent ERC20 tokens.

function buy(uint256 tokenAmount) external nonReentrant payable returns (bool) {
        require(msg.value == tokenAmount, "buy: Sent value is not equal to the amount");
        require(_canBuy == true, "buy: The buying function is not activated");

        _tenETH.mint(msg.sender, msg.value);

        emit Bought(msg.sender, tokenAmount);

        return true;
    }

sell(uint256 tokenAmount) external nonReentrant returns (bool)

Burns ten-Tokens and sends the ERC20 token amount.

function sell(uint256 tokenAmount) external nonReentrant returns (bool) {
        require(address(this).balance >= tokenAmount / 10**_calcDecimals, "sell: Too few pegged tokens locked");
        require(_tenETH.totalSupply() >= tokenAmount, "sell: That's too much");

        uint256 toSend = _tenETH.burn(msg.sender, tokenAmount);
        bool sendTx = payable(msg.sender).send(toSend);

        require(sendTx, "sell: No fallback function in contract"); //fix

        emit Sold(msg.sender, toSend);

        return sendTx;
    }

getInPrice(uint256 amount) external view returns (uint256)

Returns the actual price for swapping pegged token to ten-Token which can change. And also have nothing to do with the transaction fees of the ten-Tokens.

function getInPrice(uint256 amount) external view returns (uint256) {
        uint256 divisor;
        uint256 multiplier;
        (divisor, multiplier) = _tenToken.getActualBuyFees();

        uint256 fee = amount * multiplier / divisor;
        uint256 price = amount - fee;

        return price * 10**_calcDecimals;
    }

getOutPrice(uint256 amount) external view returns (uint256)

Returns the actual price for swapping ten-Token to pegged token which can change. And also have nothing to do with the transaction fees of the ten-Tokens.

function getOutPrice(uint256 amount) external view returns (uint256) {
        uint32 divisor;
        uint32 multiplier;
        (divisor, multiplier) = _tenToken.getActualSellFees();

        uint256 fee = amount * multiplier / divisor;
        uint256 price = amount - fee;
        
        return price / 10**_calcDecimals;
    }
PreviousAMM ERCNextTenToken

Last updated 3 years ago

Was this helpful?