Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: replace Bancor integration with Uniswap network integration #382

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading