Skip to content

Commit

Permalink
Merge pull request #383 from 0chain/sprint-1.15
Browse files Browse the repository at this point in the history
Feature: replace Bancor integration with Uniswap network integration …
  • Loading branch information
dabasov authored May 30, 2024
2 parents e628567 + e90f344 commit f687bd5
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 342 deletions.
137 changes: 0 additions & 137 deletions cmd/bridge-burn-bnt.go

This file was deleted.

46 changes: 31 additions & 15 deletions cmd/bridge-burn-eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"context"
"fmt"
"math/big"
"time"

"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -34,26 +35,41 @@ func commandBurnEth(b *zcnbridge.BridgeClient, args ...*Arg) {
status int
)

maxAmount, err := b.GetMaxBancorTargetAmount(zcnbridge.SourceTokenETHAddress, amount)
if err != nil {
ExitWithError(err, "failed to execute GetMaxBancorTargetAmount")
}
var balanceRaw *big.Int

transaction, err = b.Swap(context.Background(), zcnbridge.SourceTokenETHAddress, amount, maxAmount, time.Now().Add(time.Minute*3))
balanceRaw, err = b.GetTokenBalance()
if err != nil {
ExitWithError(err, "failed to execute Swap")
ExitWithError(err, "failed to GetTokenBalance")
}

hash = transaction.Hash().Hex()
status, err = zcnbridge.ConfirmEthereumTransaction(hash, retries, time.Second)
if err != nil {
ExitWithError(fmt.Sprintf("Failed to confirm Swap: hash = %s, error = %v", hash, err))
}
balance := balanceRaw.Uint64()

if status == 1 {
fmt.Printf("Verification: Swap [OK]: %s\n", hash)
} else {
ExitWithError(fmt.Sprintf("Verification: Swap [FAILED]: %s\n", hash))
if balance < amount {
target := amount - balance

var estimated *big.Int

estimated, err = b.GetETHSwapAmount(context.Background(), target)
if err != nil {
ExitWithError(err, "failed to GetETHSwapAmount")
}

transaction, err = b.SwapETH(context.Background(), estimated.Uint64(), target)
if err != nil {
ExitWithError(err, "failed to execute SwapETH")
}

hash = transaction.Hash().Hex()
status, err = zcnbridge.ConfirmEthereumTransaction(hash, retries, time.Second)
if err != nil {
ExitWithError(fmt.Sprintf("Failed to confirm SwapETH: hash = %s, error = %v", hash, err))
}

if status == 1 {
fmt.Printf("Verification: SwapETH [OK]: %s\n", hash)
} else {
ExitWithError(fmt.Sprintf("Verification: SwapETH [FAILED]: %s\n", hash))
}
}

fmt.Println("Starting IncreaseBurnerAllowance transaction")
Expand Down
137 changes: 0 additions & 137 deletions cmd/bridge-burn-eurc.go

This file was deleted.

Loading

0 comments on commit f687bd5

Please sign in to comment.