diff --git a/client/asset/eth/eth.go b/client/asset/eth/eth.go index 6c74078569..7fbed41352 100644 --- a/client/asset/eth/eth.go +++ b/client/asset/eth/eth.go @@ -3737,6 +3737,8 @@ func (w *assetWallet) resubmitRedemption(tx *types.Transaction, contractVersion var replacementHash common.Hash copy(replacementHash[:], txs[0]) + w.log.Infof("Redemption transaction %s was broadcast to replace transaction %s (original tx: %s)", replacementHash, monitoredTx.tx.Hash(), tx.Hash()) + if monitoredTx != nil { err = w.recordReplacementTx(monitoredTx, replacementHash) if err != nil { @@ -4535,7 +4537,11 @@ func getFileCredentials(chain, path string, net dex.Network) (seed []byte, provi return nil, nil, fmt.Errorf("must provide both seeds in credentials file") } seed = p.Seed - providers = p.Providers[chain][net.String()] + for _, uri := range p.Providers[chain][net.String()] { + if !strings.HasPrefix(uri, "#") && !strings.HasPrefix(uri, ";") { + providers = append(providers, uri) + } + } if net == dex.Simnet && len(providers) == 0 { u, _ := user.Current() switch chain { @@ -5213,7 +5219,7 @@ func getGasEstimates(ctx context.Context, cl, acl ethFetcher, c contractor, ac t copy(randomAddr[:], encode.RandomBytes(20)) transferTx, err := tc.transfer(txOpts, randomAddr, big.NewInt(1)) if err != nil { - return fmt.Errorf("error estimating transfer gas: %w", err) + return fmt.Errorf("transfer error: %w", err) } if err = waitForConfirmation(ctx, cl, transferTx.Hash()); err != nil { return fmt.Errorf("error waiting for transfer tx: %w", err) diff --git a/client/asset/polygon/polygon.go b/client/asset/polygon/polygon.go index d3a7c9b246..7e584198bc 100644 --- a/client/asset/polygon/polygon.go +++ b/client/asset/polygon/polygon.go @@ -30,6 +30,8 @@ func init() { asset.Register(BipID, &Driver{}) registerToken(simnetTokenID, "A token wallet for the DEX test token. Used for testing DEX software.", dex.Simnet) registerToken(usdcTokenID, "The USDC Ethereum ERC20 token.", dex.Mainnet, dex.Testnet) + registerToken(wbtcTokenID, "Wrapped BTC.", dex.Mainnet) + registerToken(wethTokenID, "Wrapped ETH.", dex.Mainnet) } const ( @@ -43,6 +45,8 @@ const ( var ( simnetTokenID, _ = dex.BipSymbolID("dextt.polygon") usdcTokenID, _ = dex.BipSymbolID("usdc.polygon") + wethTokenID, _ = dex.BipSymbolID("weth.polygon") + wbtcTokenID, _ = dex.BipSymbolID("wbtc.polygon") // WalletInfo defines some general information about a Polygon Wallet(EVM // Compatible). diff --git a/client/webserver/site/src/html/bodybuilder.tmpl b/client/webserver/site/src/html/bodybuilder.tmpl index ea413e7cc6..4f1f6dca67 100644 --- a/client/webserver/site/src/html/bodybuilder.tmpl +++ b/client/webserver/site/src/html/bodybuilder.tmpl @@ -103,7 +103,7 @@ {{end}} {{define "bottom"}} - + {{end}} diff --git a/client/webserver/site/src/img/coins/wbtc.png b/client/webserver/site/src/img/coins/wbtc.png new file mode 100644 index 0000000000..e89565a932 Binary files /dev/null and b/client/webserver/site/src/img/coins/wbtc.png differ diff --git a/client/webserver/site/src/img/coins/wbtc.svg b/client/webserver/site/src/img/coins/wbtc.svg new file mode 100644 index 0000000000..aaa637fcff --- /dev/null +++ b/client/webserver/site/src/img/coins/wbtc.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/webserver/site/src/img/coins/weth.png b/client/webserver/site/src/img/coins/weth.png new file mode 100644 index 0000000000..1824b08123 Binary files /dev/null and b/client/webserver/site/src/img/coins/weth.png differ diff --git a/client/webserver/site/src/img/coins/weth.svg b/client/webserver/site/src/img/coins/weth.svg new file mode 100644 index 0000000000..2f2b3c084d --- /dev/null +++ b/client/webserver/site/src/img/coins/weth.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/webserver/site/src/js/doc.ts b/client/webserver/site/src/js/doc.ts index 9dbcb37006..c83f3b3102 100644 --- a/client/webserver/site/src/js/doc.ts +++ b/client/webserver/site/src/js/doc.ts @@ -29,7 +29,9 @@ const BipIDs: Record = { 60000: 'dextt.eth', 60001: 'usdc.eth', 966000: 'dextt.polygon', - 966001: 'usdc.polygon' + 966001: 'usdc.polygon', + 966002: 'weth.polygon', + 966003: 'wbtc.polygon' } const BipSymbols = Object.values(BipIDs) diff --git a/dex/bip-id.go b/dex/bip-id.go index de8cb2e83e..e4e411406d 100644 --- a/dex/bip-id.go +++ b/dex/bip-id.go @@ -617,6 +617,8 @@ var bipIDs = map[uint32]string{ // Polygon reserved token range 966000-966999 966000: "dextt.polygon", 966001: "usdc.polygon", + 966002: "weth.polygon", + 966003: "wbtc.polygon", // END Polygon reserved token range 1171337: "ilt", 1313114: "etho", diff --git a/dex/networks/polygon/params.go b/dex/networks/polygon/params.go index 714968bc50..82ad4251db 100644 --- a/dex/networks/polygon/params.go +++ b/dex/networks/polygon/params.go @@ -52,6 +52,8 @@ var ( testTokenID, _ = dex.BipSymbolID("dextt.polygon") usdcTokenID, _ = dex.BipSymbolID("usdc.polygon") + wethTokenID, _ = dex.BipSymbolID("weth.polygon") + wbtcTokenID, _ = dex.BipSymbolID("wbtc.polygon") Tokens = map[uint32]*dexeth.Token{ testTokenID: { @@ -179,6 +181,105 @@ var ( }, }, }, + wethTokenID: TokenWETH, + wbtcTokenID: TokenWBTC, + } + + // Wrapped ETH + TokenWETH = &dexeth.Token{ + Token: &dex.Token{ + ParentID: PolygonBipID, + Name: "WETH", + UnitInfo: dex.UnitInfo{ + AtomicUnit: "gwei", + Conventional: dex.Denomination{ + Unit: "WETH", + ConversionFactor: 1e9, + }, + }, + }, + NetTokens: map[dex.Network]*dexeth.NetToken{ + dex.Mainnet: { + Address: common.HexToAddress("0x7ceb23fd6bc0add59e62ac25578270cff1b9f619"), // https://polygonscan.com/token/0x7ceb23fd6bc0add59e62ac25578270cff1b9f619 + SwapContracts: map[uint32]*dexeth.SwapContract{ + 0: { + // deploy tx: https://polygonscan.com/tx/0xc569774add0a9f41eace3ff6289eafd4c17fbcaafcf8b7758e0a5c4d74dcf307 + // swap contract: https://polygonscan.com/address/0x878dF60d47Afa9C665dFaDCB6BF4e303C080032f + Address: common.HexToAddress("0x878dF60d47Afa9C665dFaDCB6BF4e303C080032f"), + Gas: dexeth.Gases{ + // First swap used 158846 gas Recommended Gases.Swap = 206499 + // 4 additional swaps averaged 112618 gas each. Recommended Gases.SwapAdd = 146403 + // [158846 271461 384064 496691 609318] + Swap: 206_499, + SwapAdd: 146_403, + // First redeem used 70222 gas. Recommended Gases.Redeem = 91288 + // 4 additional redeems averaged 31629 gas each. recommended Gases.RedeemAdd = 41117 + // [70222 101851 133468 165110 196739] + Redeem: 91_288, + RedeemAdd: 41_117, + // Average of 5 refunds: 50354. Recommended Gases.Refund = 65460 + // [50350 50362 50338 50362 50362] + Refund: 65_460, + // Average of 2 approvals: 36762. Recommended Gases.Approve = 47790 + // [46712 26812] + Approve: 47_790, + // Average of 1 transfers: 51910. Recommended Gases.Transfer = 67483 + // [51910] + Transfer: 67_483, + }, + }, + }, + }, + }, + } + + // Wrapped BTC + TokenWBTC = &dexeth.Token{ + EVMFactor: new(int64), + Token: &dex.Token{ + ParentID: PolygonBipID, + Name: "Wrapped Bitcoin", + UnitInfo: dex.UnitInfo{ + AtomicUnit: "Sats", + Conventional: dex.Denomination{ + Unit: "WBTC", + ConversionFactor: 1e8, + }, + }, + }, + NetTokens: map[dex.Network]*dexeth.NetToken{ + dex.Mainnet: { + Address: common.HexToAddress("0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6"), // https://polygonscan.com/token/0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6 + SwapContracts: map[uint32]*dexeth.SwapContract{ + 0: { + // deploy tx: https://polygonscan.com/tx/0xcd84a1fa2f890d5fc1fcb0dde6c5a3bb50d9b25927ec5666b96b5ad3d6902b0a + // swap contract: https://polygonscan.com/address/0x625B7Ecd21B25b0808c4221dA281CD3A82f8b797 + Address: common.HexToAddress("0x625B7Ecd21B25b0808c4221dA281CD3A82f8b797"), + Gas: dexeth.Gases{ + // First swap used 181278 gas Recommended Gases.Swap = 235661 + // 4 additional swaps averaged 112591 gas each. Recommended Gases.SwapAdd = 146368 + // [181278 293857 406460 519039 631642] + Swap: 235_661, + SwapAdd: 146_368, + // First redeem used 70794 gas. Recommended Gases.Redeem = 92032 + // 4 additional redeems averaged 31629 gas each. recommended Gases.RedeemAdd = 41117 + // [70794 102399 134052 165646 197311] + Redeem: 92_032, + RedeemAdd: 41_117, + // Average of 5 refunds: 63126. Recommended Gases.Refund = 82063 + // [63126 63126 63126 63126 63126] + Refund: 82_063, + // Average of 2 approvals: 52072. Recommended Gases.Approve = 67693 + // [52072 52072] + Approve: 67_693, + // Average of 1 transfers: 57270. Recommended Gases.Transfer = 74451 + // [57270] + Transfer: 74_451, + }, + }, + }, + }, + }, } ) diff --git a/server/asset/polygon/polygon.go b/server/asset/polygon/polygon.go index 183ba79271..46cf78f298 100644 --- a/server/asset/polygon/polygon.go +++ b/server/asset/polygon/polygon.go @@ -43,6 +43,8 @@ func init() { registerToken(testTokenID, 0) registerToken(usdcID, 0) + registerToken(wethTokenID, 0) + registerToken(wbtcTokenID, 0) if blockPollIntervalStr != "" { blockPollInterval, _ = time.ParseDuration(blockPollIntervalStr) @@ -61,6 +63,8 @@ const ( var ( testTokenID, _ = dex.BipSymbolID("dextt.polygon") usdcID, _ = dex.BipSymbolID("usdc.polygon") + wethTokenID, _ = dex.BipSymbolID("weth.polygon") + wbtcTokenID, _ = dex.BipSymbolID("wbtc.polygon") // blockPollInterval is the delay between calls to bestBlockHash to check // for new blocks. Modify at compile time via blockPollIntervalStr: