Giter Club home page Giter Club logo

wton-contract's Introduction

Wrapped TON contract

Basic implementation of WTON contract.

Motivation

Interaction with different kinds of assets requires additional conditional logic. This contract unifies interaction with assets and splits assets from paying for gas.

Summary

The contract is compatible to TEP-74 and TEP-89 standards.

Implementation is based on locking TON coins on minter contract on minting jettons and releasing TON on burning jettons.

The contract implement WTON specific operations:

burn_notification_ext#84106950 query_id:uint64 amount:Coins
                           sender:MsgAddress response_destination:MsgAddress
                           custom_payload:(Maybe ^Cell) = InternalMsgBody;

mint#864e0716 query_id:uint64 amount:Coins recipient:MsgAddress forward_amount:Coins
              forward_payload:(Maybe ^Cell) return_excesses_to:MsgAddress = InternalMsgBody;

release#71c6af6b query_id:uint64 custom_payload:(Maybe ^Cell) = InternalMsgBody;

Use Cases

Wrapping

It reserves amount + minimal_balance() TON on the minter contract and sends the rest to a WTON wallet of recipient within internal_transfer message. One of the most important things is an ability to attach forward_amount and forward_payload to build a pipeline of transactions.

The message should be rejected if:

  • msg_value is less than amount + forward_amount + gas_fee
  • recipient is in different workchain than the minter

Unwrapping

In order to unwrap tokens from jettons to TON, burn operation should be used. Current relies on existing operation burn (including custom_payload) but uses a new operation burn_notification_ext instead of burn_notification. The only reason of replacing burn_notification by a new burn_notification_ext is inability to attach a custom_payload.

After burning, a jetton wallet sends burn_notification_ext to a minter. As soon as a minter receive burn_notification_ext message, it decreased total_supply by amount, reserves total_supply + minimal_balance() and sends a message release to response_destination attaching the rest of TON and optional custom_payload.

The message burn should be rejected if:

  • response_destination is not specified
  • amount is less than jetton balance of jetton wallet
  • msg_sender is not an owner of jetton wallet
  • msg_value is not enough for handling both messages burn and burn_notification_ext

wton-contract's People

Contributors

tolya-yanot avatar emelyanenkok avatar nicknekilov avatar sasha1618 avatar pyandr3w avatar p0lunin avatar dvlkv avatar

Stargazers

Roman avatar

Forkers

trinketer22

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.