Giter Club home page Giter Club logo

contract's Introduction

Hipo

Hipo is a decentralized, permission-less, open-source liquid staking protocol on TON blockchain. Visit Hipo.Finance for more information or read the docs.

Hipo consists of these components:

  • Contract: The smart contract codes that are running on-chain. The source code is available here on this repository.
  • Webapp: The web application that helps users in staking and unstaking.
  • Borrower: The application that helps validators in borrowing from the protocol and validating blocks, thereby generating a yield for the whole protocol.

Smart Contracts

There are different smart contracts involved in the protocol. Here is a quick recap.

Treasury

This is the main smart contract of the protocol. All TON coins are deposited here and then given as loans to borrowers. Treasury address:

EQCLyZHP4Xe8fpchQz76O-_RmUhaVc_9BAoGyJrwJrcbz2eZ

Parent

This is the jetton parent/minter/master smart contract. All communication between wallets and treasury go through this smart contract. Current parent address:

EQDPdq8xjAhytYqfGSX8KcFWIReCufsB9Wdg0pLlYSO_h76w

Wallet

It's a jetton wallet implementation with some custom behavior and extra data fields. Each user has its own instance of wallet, deployed at a separate address.

Loan

Loans are given to borrowers using this smart contract which safeguards the loans. New instances of it are deployed on masterchain for each round of validation.

Bill

Some operations cannot happen instantly. For example, unstaking hTON while funds are already staked in the Elector smart contract must wait until the end of the validation round. In these cases, an SBT, which is a non-transferrable NFT, is created and assigned to the user.

Collection

Each bill is a child of an NFT collection, which is also created for each round of validation.

Librarian

Some of the above contracts are implemented using the library feature of Ton blockchain. Librarian is used to help with their deployments, and paying for their storage.

Users

There are two groups of users who would be interested in using Hipo: stakers and borrowers.

Stakers

Stakers are users who have some TON and want to earn staking rewards on their TON. In normal staking, a staker must have a large sum of TON (like at least 300,000 TON) before being able to participate in validation. Most users don't have access to such a big amount, but with a liquid staking protocol like Hipo, they can earn rewards on any TON amount.

When stakers deposit their TON, they will receive hTON jettons (a token in TON blockchain) as a receipt. Stakers can keep it or send it to other users or use it in other DeFi protocols. Whoever brings it back to the protocol, can receive the corresponding amount in TON by burning it.

Meanwhile, protocol puts staked TON from all stakers to use and will give it as a loan to validators. In turn they'll receive a reward and share it with the protocol and stakers. So over time, each hTON will have more TON value, and stakers can burn their hTON jettons to receive TON.

Borrowers

Borrowers are node operators who have the technical knowledge of running a validator server, and have access to such a server. However, they might not have access to the minimum amount required for staking. They can ask for a loan from Hipo, to receive a loan and participate in validation and earn rewards. After earning rewards, they share it with the protocol and stakers.

Loans are given to borrowers in a safe way. Borrowers can't withdraw the loan. They can only use it for staking in TON blockchain. Any punishment will be deducted from the borrower's staked amount, so they'll pay for their own misbehavior, and stakers are not punished in such cases.

Graphs

Both stakers and borrowers use different flows for different tasks. There are Graphviz graphs available for each flow in the graphs/img folder. If you want to learn the internals of the protocol, it's recommended to first look at the graph of each flow to better understand them, and then read the code of smart contracts.

Requirements:

  1. Docker
  2. make

How to generate:

  1. make build_graphviz
  2. make graphs

Development

Hipo is written in FunC, using the Blueprint toolset. It also has a large number of test cases, testing different aspects of the protocol.

  • Install dependencies: npm install
  • Build: npx blueprint build
  • Test: npx blueprint test
  • Deploy: npx blueprint run

contract's People

Contributors

behrang avatar ilyaqznetsow avatar jokly avatar mhbdev avatar mkdir98 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

contract's Issues

Write a lottery smart contract

Write a lottery smart contract where users won't lose money, but they might win a bonus. Users deposit different amounts of TON, TON is staked to hTON contract, after one or more rounds hTON is converted back to TON, the reward portion is given to one lucky user, and the process continues again.

Read source code of the contract and find bugs

Source code of hTON is written in FunC and is available in the /contracts directory. Read it and try to find bugs.

You may create an issue or even better try to write a test case and even a fix for it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.