Free TON

Contest: Atomic Swaps on Free TON [31 August 2020 - 20 September 2020]

Atomic Swaps on Free TON [31 August 2020 - 20 September 2020] SUBMISSION

Our team is pleased to present you a fully decentralized infrastructure for two-way exchange between the following blockchains / tokens:

  • Free TON <-> Ethereum
  • Free TON <-> ERC20 Token (currently USDT supported)
  • Free TON <-> Bitcoin in progress…

The exchange is based on HTLC Smart Contracts on each blockchain. This type of contracts allows exchanges between blockchains with guaranteed atomicity - that is, the exchange will either take place, or you will receive your funds back.

At the moment, HTLC smart contracts have been implemented for the following blockchains:

Distributed backend

To place / search for orders, as well as synchronize the exchange between participants, an order book based on a smart contract in the TON network is used. It allows you to place orders for both buy and sell tokens with an indication of the volume range, exchange rate and maximum time for blocking funds.

Work with a smart contract is carried out by depositing TON CRYSTALS to the account of the order book contract, after which the funds are blocked for the duration of the exchange. This makes it possible to guarantee the receipt of funds by the buyer, and prevents the placement of a large number of fake orders.

No deposit is required to purchase TON CRYSTALS, however, a small amount of TON CRYSTALS is required to pay for transactions in the order book.

Unlocked funds can be withdrawn at any time without commission.

Since there is no intermediary when exchanging through the Free TON smart contract, you do not need to pay commissions for the exchange, only commissions for the transactions themselves. When you make a deposit, the amount required to cover the storage fees of the smart contract data is debited from you (after the automatic calculation of the storage cost function is implemented, this amount will not exceed 0.001 TON CRYSTAL).

User support can be provided on a paid basis as an additional service (which is often found in the open source world).

Frontend

A javascript library is implemented to interact with smart contracts in all supported blockchains.

Git repository link: https://github.com/ton-swaps/tonswaplib

To demonstrate the possibility of exchange and debugging of the solution, a JavaScript application for browsers was developed. It allows you to make a deposit / withdrawal of funds, place and confirm orders, and exchange or refund funds in a fully automatic mode.

Git repository link: https://github.com/ton-swaps/tonswapapp
Live demo: https://ton-swaps.github.io

Demonstration

https://youtu.be/cYRapYvWuFo - This video demonstrates the automatic exchange between USDT <-> TON CRYSTAL with comments (on test networks ropsten and net.ton.dev). Links to transactions are provided in the video description.

https://youtu.be/kz50UGwD01Y - This video demonstrates the automatic exchange between ETH <-> TON CRYSTAL with partial closing of the order volume.

Further tasks

To add a new coin, the target blockchain does not need to support a Turing-complete language, only 3 conditions must be met:

  • It should be possible to block funds by sha256 hashsum
  • It should be possible to block funds by time
  • The participant exchange data must fit into 32 bytes (we will expand it later, since the bitcoin Public Key requires 33 bytes)

During the development, a number of ideas were put forward to improve the exchange protocol, which are planned to be implemented in the future. Among them:

  • Purchase of TON CRYSTALS by participants who do not have this tokens (gas credit in TON allows you to do it).
  • Completion of the exchange protocol by third parties for a small reward in case of deviations from the protocol by participants, which increases the stability of the exchange.
  • Collecting verified statistics of participants will allow you to exchange with those participants who have proven themselves well.

Disclaimer:
Due to the extremely limited time for the contest, this software is for testing purposes only . The production-ready solution requires much more time. Thank you for understanding.

License:
Source code licensed under the MIT license.

Communication:
Telegram: @Sergeydobkin
E-mail: sergeydobkin8@gmail.com
Free TON Address: 0:b25b1add7706d9fa2f4e67fff7a5790563b258bff996fe9d4d5ceda826e9f725
GitHub: https://github.com/ton-swaps/

5 Likes

Dear jurors, dear community,

My name is Sergey, I am the leading blockchain developer in Broxus. Let me present the solution that our team has implemented.

Link to Github

The sources are licensed under GPL3.

Demonstration video

Description

As required by the contest’s terms, we have implemented the following features:

  • Smart contracts allowing exchange TON <> BTC, TON <> ETH, TON <> ERC20
  • Protection from the unauthorized withdrawal of funds from published contracts
  • The possibility of a safe return of funds to each of the parties if the other party does not comply with the terms of the trade
  • Possibility to set a fee and target wallet for the fee collection of the organizer of the trade (broker)

Extra features implemented:

  • Smart contracts also allow the exchange ETH <> BTC, ERC20 <> BTC

Contact information

Telegram: @sergey_pavlovdog

Jury disclaimer

Broxus team officially abstains from voting for this contest submissions.

5 Likes

ton-swap.live – easy Free TON swaps

Submission

Contacts

Our contacts:
Telegram: @inyellowbus
Telegram: @RRoman_Tver
Email: hello@rrstd.ru
Free TON Address:
0:699029b342411e9df797ab657b3aca0e53feea7714cb4e7f0e04311e3db15b48

Scope & Comments

  • Available types of cross-chain trades (via low-level or console):
  • Ethereum (native ETH and ERC20 tokens) vs Free TON
  • Bitcoin vs Free TON (needs additional testing)
  • The prototype of end-user interface (as a part of a future Free TON Atomic Swap solution) is
    available here: https://ton-swap.live
  • cross-chain trades between Ethereum (inc. ERC20) and Free TON are available
  • cross-chain trades end-user interface between Bitcoin and Free TON is under
    development
  • The prototype of end-user interface is working in net.ton.dev and Rinkeby (supported ERC
    address: 0x27A6971737Cc8CF9C0806ED3B1c4aD8e4DBDb37a)
  • Disclaimer:
  • the current version of software is for testing purpose only!

Find presentations there — https://drive.google.com/file/d/1QNtnyRB5wDOqQ7_r9pHFEAEpDMkGJ-Kz/view?usp=sharing

Or in submission attachment

3 Likes

Developers Contest: Atomic Swaps on Free TON

Repository

Requirements

  • The possibility of a safe return of funds to each of the parties if the other party does not comply with the terms of the trade
  • Open sources of smart contracts published at GitHub/GitLab or another open repository
  • Documentation
  • Name and contact information of the contestant for communication (Telegram username, e-mail)

Summary

Author - Nail Khafizov, independent software developer.

Implementation and demonstration smart contracts of Atomic Swaps:

Ton Crystal, Native Ether, Ethereum ERC20, Bitcoin

Motivation

Develop an infrastructure that allows users to perform transactions between different blockchains without escrow in an untrusted environment. It will make the exchange market around TON Crystal more secure for OTC transactions.

Abstract

Atomic Swap — a smart contract technology enables the exchange of one cryptocurrency for another without using centralized intermediaries (such as exchanges).
I’ve learned two ways of swaps:

  1. By using Hashed TimeLock Contract
  2. By using Simplified Payment Verification.

HTLC — the most simple. It requires supporting common hash function (e.g. sha256) from blockchain and TimeLock contract functionality.
+ Сan be fully decentralised
- Requires side communication between participants and locking money on specific time

SPV requires from one of two blockchains supporting runnig complex smart contracts (e.g. Ethereum or Ton) to verify transaction’s Merke Proof of transfer.
+ Transfer can be fast and automatic
- Requires solution to identify the source of the transaction:
mainnet / testnet / side blockchain by using oracles smart contracts / supporting SPV verification by validators.


I chose HTLC, because:

  • Time of contest is limited to 3 weeks
  • High transmission speed can be achieved through automation Atomic Swap Wallet, which supports SPV verification different blockchains off-chain.

Implementation

Tech Stack

FreeTon: TON-Solidity-Compiler, Solidity, JS for testing
Ethereum: Truffle, Solidity, JS for testing
Bitcoin (Work in progress): bitcoinjs-lib, JS

Repository structure

./ton - Atomic Swap Contracts for FreeTon blockchain
./eth - Atomic Swap Contracts for Ethereum blockchain
./btc - Atomic Swap Contracts for Bitcoin blockchain
./app - App for demostrating working of Smart Contracts at testnets. Not used in production, only for learning purpose

WorkFlow

workflow image

Commands:

initiate (participant address, amount, secret hash, lock time)
participate (initiator address, amount, secret hash, lock time)
redeem (secret)
refund

Steps:

  1. Part A have to generate the secret limited by 32 bytes and store it securely. Next, Part A initiate and create contract with hash of secret and participant’s address. In this contract the locktime should be doubled to avoid scam (e. g. 24h * 2 = 48h). After that, Part A have to send transaction or smart contract address to Part B.
  2. Part B have to verify Part A’s contract: participant’s address, lockTime, amount, hash of code. If everything is OK — Part B should participate and create contract with Part A’s secret hash, otherwise Part B can do nothing. Part B should be careful, lockTime should be less Part A’s lockTime at the moment of creating contract. After, Part B have to send transaction or smart contract address to Part A.
  3. Part A have to verify Part B’s contract. If everything is OK — Part A can redeem from Part B’s contract and reveal secret, otherwise Part A can wait timeLock and refund his transfer.
  4. Part B should extract secret and redeem from Part A’s contract.

The most part of steps can be automated by wallet, with the exception of exchange address and transactions

FreeTon Atomic Swap Smart Contract

Source code

./contracts/AtomicSwap.sol - Atomic Swap Smart Contract

Commands

npm test - run tests. Require running tondev docker instance.
npm run build - compile solidity smart contracts and generate js wrappers.

Requirements:

Tests

Specification AtomicSwap.sol

  • contract AtomicSwap - This contract implements Hashed TimeLock Contract. Lock ton crystals until lock time or redeem by secret.
  • constructor(address initiator, address participant, uint128 amount, uint32 timeLock) public - Constructor for creating Atomic Swap. Initiator must ptovide all required params. Constructor can be called in two ways: by external or external message. At first case, initator should send a small amount ton crystals to UNINIT account before deploying with bounce=false. After deploying initiator must send rest ton crystals. At second case, internal message, initiator must send required amount of ton crystals with internal deploy message.
  • function redeem(bytes secret) external; - Redeem Atomic Swap by participant before time lock. Emit Redeemed event to reveal secret. Sender must be participant. Destruct contract after execution.
  • function refund() external; - Refund Atomic Swap by initiator after time lock. Sender must be initiator. Destruct contract after execution.
  • function params() public view returns (address initiator, address participant, uint32 timeLock, uint32 now, uint256 secretHash, uint128 amount, uint256 balance) - Fetch params of Atomic Swap to verify it.

Bitcoin Atomic Swap Smart Contract

Description

Here is implementation of Hashed TimeLock Contract for Bitcoin using Script. This library doesn’t interact with blockchain and don’t implement wallet logic. Using this lib you can create raw transactions or calculate p2sh address of Atomic Swap. For interacting with bitcoin blockchain you should use your wallet, but I reccomend bitcoin-core.

Source code

./contracts/AtomicSwapContracts.js - Atomic Swap Smart Contract

Tests

Command line interface for testing bitcoin Atomic Swap contracts on regtest. To run it you should run regtest bitcoin network and send bitcoins to Alice’s and Dave’s p2wpkh addresses. In this exmaple Dave want to transfer btc to Alice using Atomic Swap.

Required to install bitcoin-core.

./test/AtomicSwapTest.js

There are 4 commands:

  • node ./test/AtomicSwapTest.js create - creates p2sh address of Atomic Swap contract. Next you should send required bitcoins to this address using your bitcoin-core wallet from Dave p2wpkh address. At this step we store params, secretHash adn etc. in file ./test/db.json to avoid passing them through cli.
  • node ./test/AtomicSwapTest.js verify <p2shAddress> - Alice should verify that p2shAdress have right params. Participant and Initiator public keys, secretHash, timeLock.
  • node ./test/AtomicSwapTest.js redeem <tx-id> <tx-vout> <tx-hex> - to redeem Atomic Swap you need to provide params of transaction, that was send with bitcoins to p2shAddress. You can use bitcoin-core to get it. This command returns hex of transaction that you need to send using sendrawtransaction in bitcoin-core. After this step Atomic Swap transfer is redeemed by Alice.
  • node ./test/AtomicSwapTest.js refund <tx-id> <tx-vout> <tx-hex> - to refund Atomic Swap you need to provide params of transaction, that was send with bitcoins to p2shAddress. You can use bitcoin-core to get it. This command returns hex of transaction that you need to send using sendrawtransaction in bitcoin-core. After this step Atomic Swap transfer is refunded by Dave.

Specification AtomicSwapContrcats.js

This contract implements Hashed TimeLock Contract. Lock bitcoins until lock time or redeem by secret. I’ve used in contract OP_CHECKLOCKTIMEVERIFY and OP_SHA256.

  • function createAtomicSwapScript(secretHash, initiatorPubKey, participantPubKey, lockTime) - creates an atomic swap contract using Bitcoin Script.
  • function createAtomicSwapRedeemScript(signature, participantPubKey, secret) - creates an atomic swap redeem script. Can be used together with #createAtomicSwapScript.
  • function createAtomicSwapRefundScript(signature, initiatorPubKey) - creates an atomic swap redeem script. Can be used together with #createAtomicSwapScript.

Ethereum Atomic Swap Smart Contract

Source code

./contracts/AtomicSwap.sol - Atomic Swap Smart Contract

Commands

npm test - run tests by truffle, require running ganache

npm run build - compile solidity smart contracts by truffle, require running ganache

npm run deploy - run migration smart contract to development network, require running ganache

npm run deploy-ropsten - run migration smart contract to ropsten network

Tests

Specification AtomicSwap.sol

  • contract AtomicSwap - implements Hashed TimeLock Contract. Lock native ethers or ERC20 tokens until lock time or redeem by secret. Everyone can deploy this contract or use already deployed contract by another person.
  • function createSwap(uint256 secretHash, address participant, uint256 value, uint256 timeLock) external payable - creates Atomic Swap transfer from sender to participant. Lock native ether value until timeLock or redeem. secretHash is unique identifier for Atomic Swap. Be careful while generating secret.
  • function createSwapErc20(uint256 secretHash, address participant, uint256 alue, uint256 timeLock, address tokenAddr) external - creates Atomic Swap transfer from sender to participant. Lock erc20 tokens value until timeLock or redeem. secretHash is unique identifier for Atomic Swap. Be careful while generating secret. tokenAddr is address of ERC20 compatible smart contract.
  • function redeem(bytes calldata secret) external - redeem Atomic Swap by participant before time lock. Emit Redeemed event to reveal secret. Sender must be participant.
  • function refund(uint256 secretHash) external - refund Atomic Swap by initiator after time lock. Sender must be initiator.
  • function params(uint256 secretHash) public view returns (address initiator, address participant, uint256 timeLock, uint256 currTime, uint256 value, address tokenAddr, SwapType swapType) - fetch params of Atomic Swap to verify it.

Demonstration of using Atomic Swap smart contracts

Prerequisites

Atomic-Swap cli interface ‘./app/app.js’:

  • Not for production usage, only for demonstration

FreeTon:

Ethereum:

Bitcoin:

Description

2 users participate in this example: 0-Alice and 1-Bob.
Alice has ton rubins and want to buy Ether.
Bob has Ether, want to buy ton rubins.
I will use Atomic Swap cli interface.

Atomic Swap cli help message:

$ node ./app/app.js -h
Usage: app [options] [command]

Options:
  -V, --version        output the version number
  -u, --user <number>  user id, can be used to specify user (default: 0)
  -h, --help           display help for command

Commands:
  ton                  command for freeton blockchain
  eth                  command for ethereum blockchain
  btc                  command for bitcoin blockchain
  reset                reset keys and wallets
  help [command]       display help for command

Preparation

Need to check users have working wallets and positive balances. Deploy wallet if need.

-u 0 - parameter for Alice
-u 1 - parameter for Bob

$ node ./app/app.js -u 0 ton wallet-address
Atomic Swap Wallet address:
0:290371955258087a35fdeae9fec0b5c69b310f39b90a4bf32dbfed26a5632296

Send ton rubins from Surf app and deploy wallet.

$ node ./app/app.js -u 0 ton deploy-wallet
Atomic Swap Wallet deployed

Alice’s balance:

$ node ./app/app.js -u 0 ton balance
Atomic Swap Wallet balance:
"4_971_068_999"
$ node ./app/app.js -u 1 ton wallet-address
Atomic Swap Wallet address:
0:c0bee8851ee87883a84fa3093eb0db5ccc46f25e7c92eb06d53a9ef18e840d24

Bob’s balance:

$ node ./app/app.js -u 1 ton balance
Atomic Swap Wallet balance:
"971_068_999"
$ node ./app/app.js -u 0 eth wallet-address
Wallet address:
0xBcb9eDA088910ACe1328185d286f1CD5f49aa649
$ node ./app/app.js -u 1 eth wallet-address
Wallet address:
0x3613452b0EA100724b071031B8Fe2DAb0097CEd5
$ node ./app/app.js -u 0 eth balance
Wallet balance:
"1_999_801_590_088_213_200"
$ node ./app/app.js -u 1 eth balance
Wallet balance:
"1_999_293_474_225_822_500"

Summary of preparation

Alice:

  • ton wallet address: 0:290371955258087a35fdeae9fec0b5c69b310f39b90a4bf32dbfed26a5632296
  • eth wallet address: 0xBcb9eDA088910ACe1328185d286f1CD5f49aa649

Bob:

  • ton wallet address: 0:c0bee8851ee87883a84fa3093eb0db5ccc46f25e7c92eb06d53a9ef18e840d24
  • eth wallet address: 0x3613452b0EA100724b071031B8Fe2DAb0097CEd5

Creating Atomic Swap

Alice created Atomic Swap transfer on FreeTon:


$ node ./app/app.js -u 0 ton initiate 0:c0bee8851ee87883a84fa3093eb0db5ccc46f25e7c92eb06d53a9ef18e840d24 1
Atomic Swap deployed, params:
{
  "atomicSwapAddress": "0:318481293577870246e85a66048f76775126de9b8015fd62ca777db7752e6c9a",
  "secret": "3c571ae637a65054c0dc63ab3b422532c54f02f7bf556e64fb9475793392f268",
  "secretHash": "e8fd86f1c857d7c82381db888c6e12221888883837aa79874442b1cbdbc61cfa"
}

Bob received address of Atomic Swap contract from Alice and verified it. Timelock in 2 days, balance of Atomic Swap is sufficient, code hash is correct.

$ node ./app/app.js -u 1 ton params 0:318481293577870246e85a66048f76775126de9b8015fd62ca777db7752e6c9a
Atomic Swap params:
{
  "initiator": "0:290371955258087a35fdeae9fec0b5c69b310f39b90a4bf32dbfed26a5632296",
  "participant": "0:c0bee8851ee87883a84fa3093eb0db5ccc46f25e7c92eb06d53a9ef18e840d24",
  "secretHash": "0xe8fd86f1c857d7c82381db888c6e12221888883837aa79874442b1cbdbc61cfa",
  "amount": "1_000_000_000",
  "atomicSwapBalance": "1_002_989_000",
  "now": "1_600_599_695",
  "timeLock": "1_600_772_416",
  "codeHash": "50b3b047a6ce66ca89f153f2d98432f7f99c950161d53627a269ae80c6d8748f"
}

All right, Bob decided to transfer Atomic Swap on ethereum using Alice’s secretHash.


$ node ./app/app.js -u 1 eth participate 0xBcb9eDA088910ACe1328185d286f1CD5f49aa649 1 e8fd86f1c857d7c82381db888c6e12221888883837aa79874442b1cbdbc61cfa
Atomic Swap created

Alice verified Atomic Swap at ethereum network. TimeLock in 1 day, addresses and amount are correct.

$ node ./app/app.js -u 0 eth params e8fd86f1c857d7c82381db888c6e12221888883837aa79874442b1cbdbc61cfa
Atomic Swap params:
{
  "0": "0x3613452b0EA100724b071031B8Fe2DAb0097CEd5",
  "1": "0xBcb9eDA088910ACe1328185d286f1CD5f49aa649",
  "2": "1600686693",
  "3": "1600600339",
  "4": "1000000000000000000",
  "5": "0x0000000000000000000000000000000000000000",
  "6": "0",
  "initiator": "0x3613452b0EA100724b071031B8Fe2DAb0097CEd5",
  "participant": "0xBcb9eDA088910ACe1328185d286f1CD5f49aa649",
  "timeLock": "1600686693",
  "currTime": "1600600339",
  "value": "1000000000000000000",
  "tokenAddr": "0x0000000000000000000000000000000000000000",
  "swapType": "0"
}

Redeem Atomic Swap

All right, Atomic Swaps were created, now Alice can redeem transfer and reveal secret.

$ node ./app/app.js -u 0 eth redeem 3c571ae637a65054c0dc63ab3b422532c54f02f7bf556e64fb9475793392f268
 Atomic Swap redeemed
$ node ./app/app.js -u 0 eth balance
Wallet balance:
"2_999_617_075_088_213_500"

Bob have to retrieve secret and redeem too.

$ node ./app/app.js -u 1 eth get-secret e8fd86f1c857d7c82381db888c6e12221888883837aa79874442b1cbdbc61cfa
Atomic Swap secret:
"0x3c571ae637a65054c0dc63ab3b422532c54f02f7bf556e64fb9475793392f268"
$ node ./app/app.js -u 1 ton redeem 0:318481293577870246e85a66048f76775126de9b8015fd62ca777db7752e6c9a 3c571ae637a65054c0dc63ab3b422532c54f02f7bf556e64fb9475793392f268
Redeem success, check balance
$ node ./app/app.js -u 1 ton balance
Atomic Swap Wallet balance:
"1_950_826_918"

References



6 Likes

Guys, @SergeyD, @pavlovdog, @roman.nguyen, @nailkhaf great works! :+1: :+1: :+1:

The only drawback, as it seems to me, is that there is little originality in this competition, everyone went the same way and uses HTLC. Perhaps the next competition will be for the implementation of Bitcoin SPV, as mentioned in the link above :grinning:. I have just worked out in this direction, the code turns out to be really more complex.

Tell me, is any of the works production-ready?
Personally, I make my own just so that I can use it myself later. If there are ready-made ones, I would use them for exchanges. And if not, what are the plans to bring the contest works to working condition?

4 Likes

@creator Thank you!

Is it possible to verify Ethereum’s Merkle tree with keccak256 and check ethash PoW in TON VM?
Or verify TON Ed25519 signature in Ethereum VM?
HTLC require only the presence of a sha256, which is found in many blockchains. In this sense it is much more versatile.

I can only say for our project. It is not production-ready, it will take several months to complete.
Improvement is required not only in the part of the UI, but also a number of problems need to be solved, for example, the possibility of loss of funds, which I wrote about in an article on Medium (only in Russian)

2 Likes

idk, to my shame. That’s why I didn’t plan to integrate with Ethereum at first. In any case, this would be too expensive for SPV due to more frequent transactions. So for a combined BTC-ETH contest, the HTLC seems the only right solution, agree.

2 Likes

@SergeyD @pavlovdog @roman.nguyen
Hello colleagues. One of the tough conditions for implementation was this:

Tell me, which of you added this functionality to your solution?
Please do not be angry if I was inconsiderate and did not see this in your submission. Just answer. Thank.

My second question is how long will it take for you to get a stable solution into production?

2 Likes

It is a pity that you did such a great job, but did not submit an official submission for the contest. Sorry, your forum post is not a submission. (

@bitjudge, Hello!

One of the tough conditions for implementation was this:

Tell me, which of you added this functionality to your solution?
Please do not be angry if I was inconsiderate and did not see this in your submission. Just answer. Thank.

Here I see some lack of specifics in the assignment. Who is a broker? The presence of the owner person, in the sense that he is the only one organizing the exchange, makes the solution partially centralized, and the owner - the main point of failure. This means that the service cannot be highly reliable. The arrest and shutdown of some centralized mixers and exchanges is a clear confirmation of this.

Therefore, we designed our solution with decentralization in mind. There is no “owner” here, only the “creator”. Which deploys a TON Orderbook smart contract and that’s it. He does not incur any operating costs and does not receive any fees. In our solution, the broker is a smart contract. It collects a constant fee when depositing (see the receive () function in tonorderbook.sol) to cover the smc storage fee (it is also constant).

This is the same approach as in uniswap and other contract-based exchanges. And it is very reliable.

Of course, we could make it possible to collect fees for the creator. However, it doesn’t make any sense. Since all sources are distributed under a free license, anyone can deploy the same smart contract except that it does not charge a fee. And users will prefer it.
If Satoshi charged his own fee in every Bitcoin transaction, how quickly would the fork appear without it?

My second question is how long will it take for you to get a stable solution into production?

approx. 3-5 months.
The most difficult tasks that need to be implemented for a production-ready solution are the ability to complete the last part of the transaction by a third party and the ability to buy crystals by a person who does not have them.

3 Likes

@pavlovdog @roman.nguyen
Will you answer the questions I asked above?

1 Like

Hello!

Yes, this feature is implemented. On the TON / Ethereum contracts you can see the contract parameters

  • Platform address
  • Fee amount

The platform address is the address of the “organizer of the trade”. In the case of a successful withdraw call, the (amount - fee amount) will be sent to the target address and the rest of the funds will be sent to the platform address.

To add the broker reward in case of Bitcoin, all you need is to implement the additional output on the withdraw transaction, which sends the reward to the broker Bitcoin address.

2 Likes

Good afternoon, thank you for being involved in the process. We are so sorry for late response.

Answering the first question about the broker’s commission, I would like to say about a number of points.

To begin with, I note that the main idea of ​​creating a service was open distribution and maximum decentralization. We deliberately did not add exchange features to contracts such as order books or ratings, simply because the technology itself requires the absence of any third parties, minimizing the cost of interacting with contracts and transparency in execution. The technology does not imply additional functions such as finding a deal partner and so on, and in our case, all the staff to help users find deal partners is carried out on the side of the final service. In general, the implementation of contracts directly is aimed at ensuring that everyone can create their own services with their own functions, features, etc. Isn’t that what decentralization is all about? From our point of view, ideologically, any extra features in addition to the main technology are implemented and lie on the shoulders of those who will implement it into their ready-made products.

If we deviate a little from our ideology and hit slightly into the technique, there are the following points:

  1. Atomic swap, as I already said, is a technology that does not imply third parties. The very architecture of the technology contradicts the charging of any additional payment in addition to transaction fees and a certain number of tokens to support the execution of the contract.

  2. From a technological point of view, the implementation of such a commission in the “when you take - pay the commission” format is extremely difficult to implement, if at all realizable, within the BTC framework. If we cannot make a polymorphic model for all currencies, it turns out that someone must always pay. Or you need to look for some other ways, the specification of which is a separate task. In fact, in any case, a person buying BTC will have additional profit relative to his opponent, since the exchange of TON in BTC can only pay to the broker with TON, and the exchange of TON - ETH can be paid by both parties.

  3. Commissions of networks are already high enough. If you look a little into the future, paying additional commissions will force people to either make a fork or simply not use the service at all, since an atomic swap without a broker’s commission is often more expensive than a regular centralized exchange exchange, where there are practically no commissions for transfers other than brokerage. Plus, the translation of the broker fee itself is also an expense that someone should incur.

On the other hand, the implementation of this requirement is literally 4-5 lines of code for each of the networks which support fee stuff, provided that a clear criterion of functionality is defined, for example

  1. at what moment the money is sent to the broker’s account

  2. who pays the commission for this transfer

  3. whether a commission is charged if the transaction did not take place

etc.

In any case, the architecture and implementation of our solution more than allows us to realize the broker’s commission. The question is solely about necessity, ideology and usability.

Answering the question about the production-ready solution. We are still working on the service, at the moment the design mentioned in the presentation is being implemented, automated tests are being added, and so on. The bottleneck, in our understanding, of any financial technology is security, therefore it is important to conduct a correct audit of contracts and their mandatory formal verification, which will take the most time. We estimate the work before the stable release as 2-3 months of work. We plan to carry out the first tests in combat networks not earlier than in 2-3 weeks.

3 Likes

Nail, could you please explain what happened? Why you weren’t able to push your proposal? Could you please elaborate.

1 Like

Hello, @Mitja @bitjudge

I discussed it in telegram chats.
https://t.me/freetondevru/45474.
https://t.me/tondefi/403

There was mistake with time period. At the forum submission period is 31 August 2020 - 20 September 2020. For me it means time period 3 weeks, 21 days. It was clearly for me that finish at the end of Sunday… But at Sunday I saw that contest’s contract already moved to the next stage and I couldn’t submit my proposal, because the end was 1 day before, at Saturday. So I publish work only at the forum, because I did it for FreeTon.

3 Likes

От имени своей команды хочу высказаться по поводу ситуации с @nailkhaf.

Я сам лично чуть не наступил на эти грабли – планировал подавать заявку 20-го числа. И спасла только паранойя «так конкурс до 20-го включительно или нет?». Если как минимум 2 человека ошиблись, это, вероятно, не случайность. Но я здесь не для поиска виновных.

Ознакомившись с работой @nailkhaf, могу сказать, что он в одиночку сделал довольно много. Вклад в общее дело внесён существенный, и этот вклад не может остаться без благодарности сообщества.

В связи с этим, наша команда единогласно поддержала идею направить 5% от выигрыша на компенсацию трудозатрат @nailkhaf. Если так поступят и остальные участники конкурса, наберётся на награду 4-го места. Надеюсь, они поддержат эту идею.

Я категорически не согласен с позицией – «это блокчейн, здесь строгие правила, терпите и привыкайте». Блокчейн запишет то, что мы туда запишем, и только от нас зависит, будет это безразличие или человечность.

6 Likes

From the Broxus team, I would like to officially support this initiative. Thank you @SergeyD for proposing.

4 Likes

@SergeyD @cryonyx

Thank you for your support! It’s valuable for me :slightly_smiling_face:

4 Likes

Hello Sergey,
I’m sorry for bothering you but I noticed that probably you missed the next part of the contest description:

It would be nice if you can fix this before others notice.
Thank you!

1 Like

Since this contest only had 3 submissions, the way to distribute rewards is to simply eliminate prizes 4 - 10 and distribute just the 1st 3 prizes to winners. That would normally be the case; however, in this instance, winners 1 and 2 are tied for 1st place, both with a score of 8.25. As a result. 1st and second prize should be added and divided by 2 to create an average amount of 150k tokens per winner. 3rd place is still 50k.