Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
e298e04
add build scripts, add work-around for poor order-book sync between c…
Nov 24, 2024
e8dc615
fix typos (introduced when removing depth-chart)
Nov 24, 2024
bc14ff9
improve order placement (add safety, adjust logs)
Nov 26, 2024
9fe3d37
allow to configure profit threshold between 0.1 and 4% (from 2% max a…
Nov 26, 2024
b6a7fda
mm bot improvements, rework previous solution for displaying own orde…
Nov 26, 2024
fdabb48
mm bot should make 1-sided placements only, skew mm bot algo to resit…
Nov 28, 2024
b162d7a
mm bot adjustments
Nov 29, 2024
4825741
mm bot adjustments
Nov 30, 2024
e254530
perform Bison mid-gap rate sanity check only when mid-gap rate is ava…
Dec 6, 2024
86ef801
work-around for annoying bug that Bison wallet doesn't recover from
Dec 8, 2024
518cde5
makefile: make a by default
Dec 8, 2024
336243c
update fiat rates more frequently
Dec 9, 2024
6a3f746
only check for slippage when we can get mid-gap rate
Dec 9, 2024
4eb1ca6
better checks for bad prices from fiat oracles
Dec 10, 2024
83c567c
remove locale artifacts
Dec 10, 2024
7172790
better validation for oracle volume
Dec 10, 2024
ad6de4d
revert: update fiat rates more frequently (we can't fetch fiat rates …
Dec 10, 2024
51dd494
disable server-enforced max-fee limit restriction
Dec 21, 2024
7e535c1
add Binance as fiat-rate source, disable other fiat-rate sources for now
Dec 21, 2024
1b50a4a
enforce user-configured max-fee-rate value properly
Dec 21, 2024
427fdef
revert inconsistent change
Dec 21, 2024
2c68073
improve trade validation (keep it powerful, but not intrusive)
Dec 22, 2024
932b819
have pprof on by default
Dec 24, 2024
7278546
fix MM bot panic (see https://github.com/decred/dcrdex/issues/3130 fo…
Dec 24, 2024
f1c2859
refuse to use any other rate than wallet-provided
Dec 27, 2024
bb05d9b
(refactor) refuse to use any other rate than wallet-provided
Dec 27, 2024
53d2d68
revert last commit since not every wallet is a FeeRater we still have…
Dec 27, 2024
9f03c87
update fiat rates more frequently (note, this works with Binance rate…
Dec 27, 2024
247d7f1
btc: better differentiate between transaction types when identifying …
Dec 27, 2024
3ea139b
align btc implementation with zec
Dec 27, 2024
5342588
rework slippage warning
Dec 27, 2024
2f6ad34
mm bot shouldn't rely on Bison book being present (use oracle/fiat ra…
Dec 28, 2024
9be987e
fix typo in trade-validation code that results into panic
Dec 30, 2024
24e4ffc
ui: markets page rework (#25)
norwnd Jan 1, 2025
0405bc6
mm: enforce oracle/fiat price confluence, add USDT-derived oracle mar…
Jan 1, 2025
fa518c8
fix 1d on completed history view, don't show active orders in complet…
Jan 1, 2025
3eaf104
make duration labels on Candle chart less distracting (by setting opa…
Jan 2, 2025
567cd28
improve the way immediate-match warning works, prevent MM bot from pl…
Jan 5, 2025
f077b36
mics improvements (mostly adding await & adjusting font sizes), adjus…
Jan 5, 2025
9f79940
put completed orders section right below open orders section
Jan 6, 2025
e75e6e4
instrument a.sh with pprof everywhere
Jan 6, 2025
a55751a
refund workaround
Jan 6, 2025
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
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
a:
make build
./a.sh

l:
./a.sh

build:
./build.sh

server_build:
./build_server.sh

server_run:
./run_server.sh

build_linux:
./build_linux.sh

test:
./run_tests.sh

format:
gofmt -w -s $$(find . -type f -name '*.go' -not -path "./pkg/proto/*" -not -name "*.gen.go" -not -path "*/mock/*")
goimports -w $$(find . -type f -name '*.go' -not -path "./pkg/proto/*" -not -name "*.gen.go" -not -path "*/mock/*")

#comment:
# $GOPATH/bin/commentwrap -fix -docflow_limit=90 /Users/norwnd/crypto-integrations/applications/outgoing-transactions/domain/outgoing_transaction.go
# $GOPATH/bin/commentwrap -fix -docflow_limit=90 TODO

server_deps_up:
docker-compose -f server/docker/deps-compose.yml up -d --build

server_deps_down:
docker-compose -f server/docker/deps-compose.yml down
16 changes: 16 additions & 0 deletions a.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set -e

#!/usr/bin/env bash

## mainnet
# pprof is available at:
# http://127.0.0.1:3333/debug/pprof/goroutine?debug=1
(./client/cmd/bisonw/bisonw --webaddr=127.0.0.1:3333 --log=trace --httpprof)

## mainnet with dedicated DB:
#(./client/cmd/bisonw/bisonw --db=/Users/norwnd/d-e-x-c-db/db_mainnet --webaddr=127.0.0.1:3333 --log=trace --httpprof)
## testnet
#(./client/cmd/bisonw/bisonw --db=/Users/norwnd/d-e-x-c-db/db_mainnet --webaddr=127.0.0.1:3333 --log=trace --testnet --httpprof)

## mainnet with disaster backups:
#(./client/cmd/bisonw/bisonw --webaddr=127.0.0.1:3333 --log=trace --skynetapikey=I8JMMBPUNMEHGCV056IG1V8OEEIB0CJUTG97S0J3IQNJJ4CSGH0G --skynetapiurl='https://web3portal.com' --testnet --httpprof)
21 changes: 21 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
set -e

#!/usr/bin/env bash

pushd client/webserver/site
rm -rf dist
npm clean-install
npm run build
popd

(cd client/cmd/bisonw/ && CGO_ENABLED=1 GO111MODULE=on go build -tags lgpl)
#
# Mac-specific issue with older Golang versions (resolved with `codesign`), see discussions
# here for details: https://github.com/golang/go/issues/63997
#(cd client/cmd/bisonw/ && CGO_ENABLED=1 GO111MODULE=on go build -tags lgpl && codesign -s - -f ./bisonw)
#
# to specify OS and Architecture
#(cd client/cmd/bisonw/ && CGO_ENABLED=1 GO111MODULE=on GOOS=darwin GOARCH=arm64 go build -tags lgpl)
#
# -race build
#(cd client/cmd/bisonw/ && CGO_ENABLED=1 GO111MODULE=on go build -race -tags lgpl)
19 changes: 19 additions & 0 deletions build_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set -e

#!/usr/bin/env bash

pushd client/webserver/site
npm clean-install
npm run build
popd

#(cd client/cmd/bisonw/ && CGO_ENABLED=1 GO111MODULE=on GOOS=linux GOARCH=amd64 go build -tags lgpl)
(cd client/cmd/bisonw/ && CGO_ENABLED=1 GO111MODULE=on go build -tags lgpl)
#
# Note, this is -race build, to be used for testing only!
#(cd client/cmd/bisonw/ && CGO_ENABLED=1 GO111MODULE=on go build -race -tags lgpl)
# TODO, previously was CGO_ENABLED=0 ?

# Run Bison binary with:
# - (./client/cmd/bisonw/bisonw --db=/home/t/dcrdex-old-decrediton/db --webaddr=127.0.0.1:5758 --log=trace)
# - (./client/cmd/bisonw/bisonw --db=/home/t/dcrdex-anon/db --webaddr=127.0.0.1:5758 --log=trace)
6 changes: 6 additions & 0 deletions build_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set -e

#!/usr/bin/env bash

#(cd server/cmd/dcrdex/ && CGO_ENABLED=0 GO111MODULE=on go build -tags lgpl -race)
(cd server/cmd/dcrdex/ && CGO_ENABLED=0 GO111MODULE=on go build -tags lgpl)
50 changes: 31 additions & 19 deletions client/asset/btc/btc.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ const (

// The default fee is passed to the user as part of the asset.WalletInfo
// structure.
defaultFee = 100
defaultFee = 5
// defaultFeeRateLimit is the default value for the feeratelimit.
defaultFeeRateLimit = 1400
defaultFeeRateLimit = 5
// defaultRedeemConfTarget is the default redeem transaction confirmation
// target in blocks used by estimatesmartfee to get the optimal fee for a
// redeem transaction.
Expand Down Expand Up @@ -1879,10 +1879,16 @@ func (btc *baseWallet) feeRate(confTarget uint64) (feeRate uint64, err error) {
btc.log.Meter("feeRate.rate.fail", time.Hour).Errorf("Failed to get fee rate from external API: %v", err)
return 0, nil
}
if feeRate <= 0 || feeRate > btc.feeRateLimit() { // but fetcher shouldn't return <= 0 without error
return 0, fmt.Errorf("external fee rate %v exceeds configured limit", feeRate)
if feeRate <= 0 { // but fetcher shouldn't return <= 0 without error
return 0, fmt.Errorf("external fee rate value %v doesn't make sense", feeRate)
}

btc.log.Tracef("Retrieved fee rate from external API: %v", feeRate)
if feeRate > btc.feeRateLimit() {
btc.log.Tracef("capping fee rate %v retrieved from external API at user-configured limit of %v", feeRate, btc.feeRateLimit())
feeRate = btc.feeRateLimit()
}

return feeRate, nil
}

Expand Down Expand Up @@ -1964,7 +1970,7 @@ func (btc *baseWallet) feeRateWithFallback(feeSuggestion uint64) uint64 {
feeSuggestion)
return feeSuggestion
}
btc.log.Warnf("Unable to get optimal fee rate, using fallback of %d", btc.fallbackFeeRate)
btc.log.Warnf("Unable to get optimal fee rate, using fallback of %d", btc.fallbackFeeRate())
return btc.fallbackFeeRate()
}

Expand Down Expand Up @@ -2421,12 +2427,15 @@ func (btc *baseWallet) FundOrder(ord *asset.Order) (asset.Coins, []dex.Bytes, ui
if ord.FeeSuggestion > ord.MaxFeeRate {
return nil, nil, 0, fmt.Errorf("fee suggestion %d > max fee rate %d", ord.FeeSuggestion, ord.MaxFeeRate)
}
// Check wallets fee rate limit against server's max fee rate
if btc.feeRateLimit() < ord.MaxFeeRate {
return nil, nil, 0, fmt.Errorf(
"%v: server's max fee rate %v higher than configued fee rate limit %v",
dex.BipIDSymbol(BipID), ord.MaxFeeRate, btc.feeRateLimit())
}
// This is just a sanity check that doesn't allow Bison wallet to configure lower fees
// on client side (server doesn't enforce/check this really), we know better than whatever
// server suggests.
//// Check wallets fee rate limit against server's max fee rate
//if btc.feeRateLimit() < ord.MaxFeeRate {
// return nil, nil, 0, fmt.Errorf(
// "%v: server's max fee rate %v higher than configued fee rate limit %v",
// dex.BipIDSymbol(BipID), ord.MaxFeeRate, btc.feeRateLimit())
//}

customCfg := new(swapOptions)
err := config.Unmapify(ord.Options, customCfg)
Expand Down Expand Up @@ -5501,12 +5510,15 @@ func (btc *baseWallet) FundMultiOrder(mo *asset.MultiOrder, maxLock uint64) ([]a
if mo.FeeSuggestion > mo.MaxFeeRate {
return nil, nil, 0, fmt.Errorf("fee suggestion %d > max fee rate %d", mo.FeeSuggestion, mo.MaxFeeRate)
}
// Check wallets fee rate limit against server's max fee rate
if btc.feeRateLimit() < mo.MaxFeeRate {
return nil, nil, 0, fmt.Errorf(
"%v: server's max fee rate %v higher than configued fee rate limit %v",
dex.BipIDSymbol(BipID), mo.MaxFeeRate, btc.feeRateLimit())
}
// This is just a sanity check that doesn't allow Bison wallet to configure lower fees
// on client side (server doesn't enforce/check this really), we know better than whatever
// server suggests.
//// Check wallets fee rate limit against server's max fee rate
//if btc.feeRateLimit() < mo.MaxFeeRate {
// return nil, nil, 0, fmt.Errorf(
// "%v: server's max fee rate %v higher than configued fee rate limit %v",
// dex.BipIDSymbol(BipID), mo.MaxFeeRate, btc.feeRateLimit())
//}

bal, err := btc.Balance()
if err != nil {
Expand Down Expand Up @@ -5623,7 +5635,7 @@ func (btc *baseWallet) idUnknownTx(tx *ListTransactionsResult) (*asset.WalletTra
}
return
}
if v := txPaysToScriptHash(msgTx); tx.Send && v > 0 {
if v := txPaysToScriptHash(msgTx); v > 0 {
return &asset.WalletTransaction{
ID: tx.TxID,
Type: asset.SwapOrSend,
Expand All @@ -5649,7 +5661,7 @@ func (btc *baseWallet) idUnknownTx(tx *ListTransactionsResult) (*asset.WalletTra
// not segwit
const scriptVer = 0
tokenizer := txscript.MakeScriptTokenizer(scriptVer, txIn.SignatureScript)
for i := 0; i <= idx; i++ { // contract is 5th item item in redemption and 4th in refund
for i := 0; i <= idx; i++ { // contract is 5th item in redemption and 4th in refund
if !tokenizer.Next() {
continue txinloop
}
Expand Down
45 changes: 30 additions & 15 deletions client/asset/dcr/dcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -1870,12 +1870,15 @@ func (dcr *ExchangeWallet) FundOrder(ord *asset.Order) (asset.Coins, []dex.Bytes
if ord.FeeSuggestion > cfg.feeRateLimit {
return nil, nil, 0, fmt.Errorf("suggested fee > configured limit. %d > %d", ord.FeeSuggestion, cfg.feeRateLimit)
}
// Check wallet's fee rate limit against server's max fee rate
if cfg.feeRateLimit < ord.MaxFeeRate {
return nil, nil, 0, fmt.Errorf(
"%v: server's max fee rate %v higher than configured fee rate limit %v",
dex.BipIDSymbol(BipID), ord.MaxFeeRate, cfg.feeRateLimit)
}
// This is just a sanity check that doesn't allow Bison wallet to configure lower fees
// on client side (server doesn't enforce/check this really), we know better than whatever
// server suggests.
//// Check wallet's fee rate limit against server's max fee rate
//if cfg.feeRateLimit < ord.MaxFeeRate {
// return nil, nil, 0, fmt.Errorf(
// "%v: server's max fee rate %v higher than configured fee rate limit %v",
// dex.BipIDSymbol(BipID), ord.MaxFeeRate, cfg.feeRateLimit)
//}

customCfg := new(swapOptions)
err := config.Unmapify(ord.Options, customCfg)
Expand Down Expand Up @@ -2260,7 +2263,10 @@ func (dcr *ExchangeWallet) submitMultiSplitTx(fundingCoins asset.Coins, _ /* spe
addr: outputAddresses[i].String(),
}
}
dcr.lockFundingCoins(fcs)
err = dcr.lockFundingCoins(fcs)
if err != nil {
return nil, 0, fmt.Errorf("lockFundingCoins: %w", err)
}

var totalOut uint64
for _, txOut := range tx.TxOut {
Expand Down Expand Up @@ -2410,7 +2416,10 @@ func (dcr *ExchangeWallet) fundMultiWithSplit(keep, maxLock uint64, values []*as
}
}

dcr.lockFundingCoins(spents)
err = dcr.lockFundingCoins(spents)
if err != nil {
return nil, nil, 0, fmt.Errorf("lockFundingCoins: %w", err)
}

return coins, redeemScripts, splitFees, nil
}
Expand All @@ -2430,7 +2439,10 @@ func (dcr *ExchangeWallet) fundMulti(maxLock uint64, values []*asset.MultiOrderV
return nil, nil, 0, err
}
if len(coins) == len(values) || !allowSplit {
dcr.lockFundingCoins(fundingCoins)
err = dcr.lockFundingCoins(fundingCoins)
if err != nil {
return nil, nil, 0, fmt.Errorf("lockFundingCoins: %w", err)
}
return coins, redeemScripts, 0, nil
}

Expand Down Expand Up @@ -2459,12 +2471,15 @@ func (dcr *ExchangeWallet) FundMultiOrder(mo *asset.MultiOrder, maxLock uint64)
return nil, nil, 0, fmt.Errorf("fee suggestion %d > max fee rate %d", mo.FeeSuggestion, mo.MaxFeeRate)
}

cfg := dcr.config()
if cfg.feeRateLimit < mo.MaxFeeRate {
return nil, nil, 0, fmt.Errorf(
"%v: server's max fee rate %v higher than configured fee rate limit %v",
dex.BipIDSymbol(BipID), mo.MaxFeeRate, cfg.feeRateLimit)
}
// This is just a sanity check that doesn't allow Bison wallet to configure lower fees
// on client side (server doesn't enforce/check this really), we know better than whatever
// server suggests.
//cfg := dcr.config()
//if cfg.feeRateLimit < mo.MaxFeeRate {
// return nil, nil, 0, fmt.Errorf(
// "%v: server's max fee rate %v higher than configured fee rate limit %v",
// dex.BipIDSymbol(BipID), mo.MaxFeeRate, cfg.feeRateLimit)
//}

bal, err := dcr.Balance()
if err != nil {
Expand Down
Loading
Loading