Skip to content

Conversation

itswisdomagain
Copy link
Member

@itswisdomagain itswisdomagain commented Jan 4, 2023

Resolves #1991.

Registration flow is largely maintained, except the /postbond API endpoint
is used instead of /register; and the confirm registration form allows users
to specify a bond strength.

Markets page shows confirmation counter for pending bonds which is only
displayed if the user's account tier is < 1 and there are pending bonds.

Also adds a Post Bond feature to the dexsettings page for manual bond posting.

@chappjc
Copy link
Member

chappjc commented Jan 4, 2023

Thanks! I'm rushing to resolve #1990 so we can iron out the UI elements of bond options, namely target tier and max bonded amount.

@itswisdomagain
Copy link
Member Author

The reg asset selector and other forms used in posting a bond still contain "registration fee" terminology. Variable, class, method names as well. I believe those need to be updated but want to put the core stuff out here first.

@chappjc chappjc added this to the 0.6 milestone Jan 4, 2023
@chappjc chappjc added the bonds fidelity bonds label Jan 4, 2023
@itswisdomagain itswisdomagain force-pushed the bonds-frontend branch 2 times, most recently from 356ccc3 to e2627e3 Compare February 2, 2023 07:51
@itswisdomagain itswisdomagain force-pushed the bonds-frontend branch 2 times, most recently from 4e6c703 to 6beff4a Compare February 13, 2023 21:37
Copy link
Collaborator

@martonp martonp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to post the bond because I kept getting the panic because pendingBondConfs was nil.

dc.acct.targetTier = form.Bond / bondAsset.Amt
dc.acct.maxBondedAmt = maxBondedAmt
dc.acct.authMtx.Unlock()
// maxBondedAmt and bondAsset were set by connectDEX
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer correct if view-only acct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer correct in all cases. They’re only set here now, if maintain is true and it’s a fresh registration attempt (!acctExists).

@ukane-philemon
Copy link
Contributor

ukane-philemon commented Feb 20, 2023

Thanks! I'm rushing to resolve #1990 so we can iron out the UI elements of bond options, namely target tier and max bonded amount.

About max bonded amount, assuming a user has zero trading tier(and maybe the expired tier has not been refunded) and then decides to set bond options to (target tier := 1, max bonded amount := target tier * bond amount, maintain tier := true) there would be an issue when maintaining bonds since the previous bond has not been refunded but we want to post a bond which would exceed the current maxBondAmt.

core.UpdateBondOptions and core.PostBond currently does not do any validations but considering the above scenario and ensuring the provided MaxBondAmount is sufficient to maintain the target tier, we might have to do some validation there so users are not stuck waiting for a new bond/tier increase and do not know they need to increase the max bond amount to current bonded amount if any (including expired but not refunded) + amtNeeded(target tier * bond amount) + amtNeeded * 4(or maybe more or less?). The last variable is excluded if maintainTier != true.

I guess since #1990 is merged, we can discuss this further.

@chappjc
Copy link
Member

chappjc commented Feb 20, 2023

Thanks! I'm rushing to resolve #1990 so we can iron out the UI elements of bond options, namely target tier and max bonded amount.

About max bonded amount, assuming a user has zero trading tier(and maybe the expired tier has not been refunded) and then decides to set bond options to (target tier := 1, max bonded amount := target tier * bond amount, maintain tier := true) there would be an issue when maintaining bonds since the previous bond has not been refunded but we want to post a bond which would exceed the current maxBondAmt.

That's not a usable amount. The default for maxBondAmt is 4x the bond amount times target tier.

core.UpdateBondOptions and core.PostBond currently does not do any validations but considering the above scenario and ensuring the provided MaxBondAmount is sufficient to maintain the target tier, we might have to do some validation there so users are not stuck waiting for a new bond/tier increase and do not know they need to increase the max bond amount to current bonded amount if any (including expired but not refunded) + amtNeeded(target tier * bond amount) + amtNeeded * 4(or maybe more or less?). The last variable is excluded if maintainTier != true.

The bond-reserves PR needs to go in. There are extensive changes to core.UpdateBondOptions there. That's the method where all the validation and automatic adjustments to these values need to be.

@chappjc
Copy link
Member

chappjc commented Feb 20, 2023

@chappjc
Copy link
Member

chappjc commented Feb 20, 2023

For UI, we generally do NOT want the user setting maxBondAmt. This setting should be an advanced option, and hidden from users. Info text should say the max bonded amount is automatically set as low as possible unless the user picks a larger value (to compensate for possible tier drops). The backend enforces the "floor" according to the code I linked.

On this topic though, you do make a point that if user tier drops and more bond is required, a clear backend notification should be emitted indicating why another bond cannot be posted (they need to raise their max bonded amount or accept that their account is penalized).

@ukane-philemon
Copy link
Contributor

Referring to https://github.com/decred/dcrdex/pull/2103/files#diff-6327e534faf5bc61df70b157ad5474582e26a4fd99bceb53316d758e9a5fe9bdR912

Right. I agree the bonds reserves PR might need to go in before finally resolving the UI elements regarding bonds, since it has extensive changes.

Regarding having an advance bonds settings section(esp. for maxBondAmount), that makes sense so regular users need not fret over settings they do not need to meddle with.

@chappjc
Copy link
Member

chappjc commented Feb 20, 2023

Right. I agree the bonds reserves PR might need to go in before finally resolving the UI elements regarding bonds, since it has extensive changes.

You may rebase on the bond-reserves branch. I think that would aid in testing both PRs. I do dexcctl bondopts all the time instead.

@chappjc
Copy link
Member

chappjc commented Feb 20, 2023

@ukane-philemon If you are taking this over, do you want to make a new PR or can you push on this branch?

@ukane-philemon
Copy link
Contributor

ukane-philemon commented Feb 20, 2023

@ukane-philemon If you are taking this over, do you want to make a new PR or can you push on this branch?

I think @itswisdomagain is still on this? (untill he says otherwise). However, I was testing this PR with some changes related to this.

@chappjc
Copy link
Member

chappjc commented Feb 20, 2023

@itswisdomagain Did you wanna do the rebase and a couple more tweaks before handing it over? Or did I misunderstand matrix chat?

@ukane-philemon
Copy link
Contributor

The reg asset selector and other forms used in posting a bond still contain "registration fee" terminology. Variable, class, method names as well. I believe those need to be updated but want to put the core stuff out here first.

While at it, we could update these too.

@chappjc
Copy link
Member

chappjc commented Feb 20, 2023

I want to keep the footprint of this PR minimal to get it in fast. If we update that stuff (for completeness, but unnecessary), we need to isolate it into a separate commit, but I still expect breakage doing it.

@itswisdomagain
Copy link
Member Author

@itswisdomagain Did you wanna do the rebase and a couple more tweaks before handing it over? Or did I misunderstand matrix chat?

I'll rebase and cherry-pick @ukane-philemon's commit for the bond maintenance option, so this can go in without further delay.

Copy link
Member

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working well. Just some UI nits.
I still see "Registration Fee" used everywhere. Is that still accurate? Not only here, but for example:
image

The bond amount inputs allow negatives and letters, can restrict to whole numbers? Examples:
This does error.
image

This one does not error.
image

@JoeGruffins
Copy link
Member

Some warnings and errors, not sure if related to these changes:

2023-02-23 20:35:26.112 [INF] CORE: Connected to DEX server at 127.0.0.1:17273 but NOT listening for messages.
2023-02-23 20:35:26.124 [INF] CORE: Authenticated connection to 127.0.0.1:17273, acct ca230ff6a2c6cae19902cd5dd8cc4a7505b0ecb36a85611d45d779ce379bba86, 1 active bonds, 0 active orders, 0 active matches, score -1, tier 6
2023-02-23 20:35:26.124 [WRN] CORE: Unknown bond reported by server: 6c1194ccea72666667de5590d575ae164b833a9fabd5792c3508d89f103ddfe5:0 (dcr)
2023/02/23 20:35:26 "POST http://127.0.0.3:5758/api/discoveracct HTTP/1.1" from 127.0.0.1:46216 - 200 2340B in 58.78178ms
2023/02/23 20:35:26 "GET http://127.0.0.3:5758/api/user HTTP/1.1" from 127.0.0.1:46216 - 200 49550B in 492.624µs
2023/02/23 20:35:26 "GET http://127.0.0.3:5758/markets HTTP/1.1" from 127.0.0.1:46216 - 200 49175B in 236.284µs
2023-02-23 20:35:26.176 [TRC] WEB[WS]: message of type 1 received for route loadmarket
2023-02-23 20:35:26.176 [DBG] CORE: Subscribing to the dcr_btc order book for 127.0.0.1:17273
2023-02-23 20:35:26.176 [DBG] CORE[dcr_btc][book]: Processing 0 cached order notes
2023-02-23 20:35:26.176 [TRC] WEB[WS]: message of type 1 received for route loadcandles
2023/02/23 20:35:26 "GET http://127.0.0.3:5758/img/coins/btc.png HTTP/1.1" from 127.0.0.1:46216 - 200 3636B in 123.582µs
2023/02/23 20:35:26 "GET http://127.0.0.3:5758/img/coins/dextt.eth.png HTTP/1.1" from 127.0.0.1:46216 - 200 7041B in 99.156µs
2023/02/23 20:35:26 "GET http://127.0.0.3:5758/img/coins/eth.png HTTP/1.1" from 127.0.0.1:46216 - 200 2593B in 80.24µs
2023-02-23 20:35:29.352 [INF] CORE: Newly expired bond found: 6c1194ccea72666667de5590d575ae164b833a9fabd5792c3508d89f103ddfe5:0 (dcr)
2023-02-23 20:40:09.352 [ERR] CORE: Failed to broadcast bond refund txn []: EOF
2023-02-23 20:40:15.012 [TRC] CORE[dcr_btc][book]: Validating match proof note for epoch 111810160 (dcr_btc) with 6 preimages and 0 misses.
2023-02-23 20:40:17.532 [DBG] CORE[dcr]: tip change: 658 (0d8c1715d1d8e4164fa7d92eb6008ecea5d9376c1518b2609b5c4f72b0ff6286) => 659 (2168d66c145e3f9fbe93d2200f7e71a91d44ff3e9e813e3839f0c79a2cf3d320)
2023-02-23 20:40:17.532 [TRC] CORE: Processing tip change for dcr
2023-02-23 20:40:22.903 [DBG] CORE[btc]: tip change: 466 (71585b7a4adc898afdb79d57bb511f32259c39b3f3ee82cf7c6545412c1ae836) => 467 (677c638a3201f6ac8fb1aa8e8fb53f0198e6417c5c532b55d2a37e92c89f3653)
2023-02-23 20:40:22.903 [TRC] CORE: Processing tip change for btc
2023-02-23 20:40:22.903 [TRC] CORE[btc][SPV]: Bals: spendable = 0.0086014 BTC (0.0086014 BTC trusted, 0 BTC untrusted, 0 BTC assumed locked), immature = 0 BTC
2023-02-23 20:40:29.352 [ERR] CORE: Failed to broadcast bond refund txn []: EOF
2023-02-23 20:40:30.017 [TRC] CORE[dcr_btc][book]: Validating match proof note for epoch 111810161 (dcr_btc) with 7 preimages and 0 misses.
2023-02-23 20:40:39.189 [DBG] CORE[dcr]: tip change: 659 (2168d66c145e3f9fbe93d2200f7e71a91d44ff3e9e813e3839f0c79a2cf3d320) => 660 (1666c692efd31650091a7d7c39aa9f5a9bdcc0f41f9bd0220c1c61f662c56666)
2023-02-23 20:40:39.189 [TRC] CORE: Processing tip change for dcr
2023-02-23 20:40:45.018 [TRC] CORE[dcr_btc][book]: Validating match proof note for epoch 111810162 (dcr_btc) with 7 preimages and 0 misses.
2023-02-23 20:40:49.272 [DBG] CORE[btc]: tip change: 467 (677c638a3201f6ac8fb1aa8e8fb53f0198e6417c5c532b55d2a37e92c89f3653) => 468 (646fef046fdb89e3bd30362c3b5efeca9aecaac8885340950677c2162015237e)
2023-02-23 20:40:49.272 [TRC] CORE: Processing tip change for btc
2023-02-23 20:40:49.272 [TRC] CORE[btc][SPV]: Bals: spendable = 0.0086014 BTC (0.0086014 BTC trusted, 0 BTC untrusted, 0 BTC assumed locked), immature = 0 BTC
2023-02-23 20:40:49.352 [ERR] CORE: Failed to broadcast bond refund txn []: EOF

I was deleting the account in options and then connecting again. Maybe related...

@JoeGruffins
Copy link
Member

JoeGruffins commented Feb 23, 2023

Oh, yeah, maybe unrelated, but issue a bond to a dex, then "Disable Account" in Settings then connect to the dex again and you get those logs. It appears to brick the refund.

@chappjc
Copy link
Member

chappjc commented Feb 23, 2023

Oh, yeah, maybe unrelated, but issue a bond to a dex, then "Disable Account" in Settings then connect to the dex again and you get those logs. It appears to brick the refund.

Looks like we should block Disable Account if there are active bonds!

@chappjc
Copy link
Member

chappjc commented Feb 23, 2023

The reg asset selector and other forms used in posting a bond still contain "registration fee" terminology. Variable, class, method names as well. I believe those need to be updated but want to put the core stuff out here first.

While at it, we could update these too.

To clarify, we still need to update the UI. I just meant let's not churn on "Variable, class, method names as well".

"How will you post the registration fee?" => "What asset would you like to use for fidelity bonds?"

"...funds will be spent from your wallet to play the registration fee." => "...funds will be locked in time-locked fidelity bonds, which you may redeem in the future."

etc.

@chappjc
Copy link
Member

chappjc commented Feb 23, 2023

Looks like we should block Disable Account if there are active bonds!

Just did this in #2103

I think this PR should rebase on that one.

@chappjc
Copy link
Member

chappjc commented Feb 24, 2023

Rebased and force pushed on the remote. If there are more than a couple iterations, we may reopen this PR from my remote (still including the commit from you guys of course).

@itswisdomagain
Copy link
Member Author

Rebased and force pushed on the remote.

Thanks @chappjc. Sorry for the delays.

@itswisdomagain
Copy link
Member Author

My last force push is a minimal change to how the Update Bond Options button is hidden for view-only connections.

@chappjc chappjc merged commit 622fe7d into decred:master Feb 26, 2023
@itswisdomagain itswisdomagain deleted the bonds-frontend branch February 28, 2023 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bonds fidelity bonds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch client browser frontend to postbond instead of legacy fee register
6 participants