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

Increase trade limit. Make trade limit a DAO parameter #2413

Merged
merged 5 commits into from
Feb 15, 2019

Conversation

ManfredKarrer
Copy link
Contributor

@ManfredKarrer ManfredKarrer commented Feb 12, 2019

  • Set max trade limit to 2 BTC (for altcoins)
  • Add MAX_TRADE_LIMIT to Param
  • Round first month trade limit to ensure we stick with precision 4 for
    the btc amount
  • Use risk factors to derive trade limits for different payment method
    risk categories

Implements bisq-network/proposals#71

- Set max trade limit to 2 BTC (for altcoins)
- Add MAX_TRADE_LIMIT to Param
- Round first month trade limit to ensure we stick with precision 4 for
the btc amount
- Use risk factors to derive trade limits for different payment method
risk categories
@ripcurlx
Copy link
Contributor

Starting with an existing client throws following error in the background:

Feb.-13 10:23:08.431 [JavaFX Application Thread] ERROR b.common.storage.FileManager: Exception at proto read: tradeLimits must not be null file:/Users/christoph/Library/Application Support/bisq-BTC_REGTEST_Bob_dao/btc_regtest/db/UserPayload java.lang.NullPointerException: tradeLimits must not be null
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:787)
	at bisq.core.payment.payload.PaymentMethod.getAllValues(PaymentMethod.java:161)
	at bisq.core.payment.payload.PaymentMethod.getPaymentMethodById(PaymentMethod.java:272)
	at bisq.core.payment.PaymentAccount.fromProto(PaymentAccount.java:102)
	at bisq.core.user.UserPayload.lambda$fromProto$15(UserPayload.java:117)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1492)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at bisq.core.user.UserPayload.fromProto(UserPayload.java:118)
	at bisq.core.proto.persistable.CorePersistenceProtoResolver.fromProto(CorePersistenceProtoResolver.java:105)
	at bisq.common.storage.FileManager.read(FileManager.java:126)
	at bisq.common.storage.Storage.getPersisted(Storage.java:153)
	at bisq.common.storage.Storage.initAndGetPersistedWithFileName(Storage.java:85)
	at bisq.core.user.User.readPersisted(User.java:91)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1378)
	at bisq.common.proto.persistable.PersistedDataHost.apply(PersistedDataHost.java:26)
	at bisq.core.app.BisqExecutable.setupPersistedDataHosts(BisqExecutable.java:253)
	at bisq.desktop.app.BisqAppMain.setupPersistedDataHosts(BisqAppMain.java:122)
	at bisq.core.app.BisqExecutable.applyInjector(BisqExecutable.java:238)
	at bisq.desktop.app.BisqAppMain.applyInjector(BisqAppMain.java:114)
	at bisq.core.app.BisqExecutable.setupGuice(BisqExecutable.java:224)
	at bisq.core.app.BisqExecutable.onApplicationLaunched(BisqExecutable.java:212)
	at bisq.desktop.app.BisqAppMain.onApplicationLaunched(BisqAppMain.java:99)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)

java.lang.NullPointerException: tradeLimits must not be null
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:787)
	at bisq.core.payment.payload.PaymentMethod.getAllValues(PaymentMethod.java:161)
	at bisq.core.payment.payload.PaymentMethod.getPaymentMethodById(PaymentMethod.java:272)
	at bisq.core.payment.PaymentAccount.fromProto(PaymentAccount.java:102)
	at bisq.core.user.UserPayload.lambda$fromProto$15(UserPayload.java:117)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1492)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at bisq.core.user.UserPayload.fromProto(UserPayload.java:118)
	at bisq.core.proto.persistable.CorePersistenceProtoResolver.fromProto(CorePersistenceProtoResolver.java:105)
	at bisq.common.storage.FileManager.read(FileManager.java:126)
	at bisq.common.storage.Storage.getPersisted(Storage.java:153)
	at bisq.common.storage.Storage.initAndGetPersistedWithFileName(Storage.java:85)
	at bisq.core.user.User.readPersisted(User.java:91)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1378)
	at bisq.common.proto.persistable.PersistedDataHost.apply(PersistedDataHost.java:26)
	at bisq.core.app.BisqExecutable.setupPersistedDataHosts(BisqExecutable.java:253)
	at bisq.desktop.app.BisqAppMain.setupPersistedDataHosts(BisqAppMain.java:122)
	at bisq.core.app.BisqExecutable.applyInjector(BisqExecutable.java:238)
	at bisq.desktop.app.BisqAppMain.applyInjector(BisqAppMain.java:114)
	at bisq.core.app.BisqExecutable.setupGuice(BisqExecutable.java:224)
	at bisq.core.app.BisqExecutable.onApplicationLaunched(BisqExecutable.java:212)
	at bisq.desktop.app.BisqAppMain.onApplicationLaunched(BisqAppMain.java:99)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)

Copy link
Contributor

@ripcurlx ripcurlx left a comment

Choose a reason for hiding this comment

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

NACK - the initial loading of existing payment methods without the trade limits property causes an error.

- Assign paymentMethods in static final field
- Add static fields for default trade limits
- Remove deprecated payment methods
- Remove onAllServicesInitialized and use static initializer instead
- Re-purpose maxTradeLimit for indicating risk factor
- Calculate real trade limit in the getMaxTradeLimitAsCoin method
- Rename getActivePaymentMethods to getPaymentMethods
- We had an automate remove accounts for those payment methods for long
time, so we can assume that no traders have any of those accounts still
in their persisted user objects and it is safe to completely remove them.
Only part where we cannot remove it is the PB definitions (actually I
think we could remove those as well, but not 100% sure and it seems to
be more safe to mark those as deprecated and leave the entries).
@ripcurlx
Copy link
Contributor

ripcurlx commented Feb 14, 2019

I just tried to do a trade on Regtest and it failed because it was applying the wrong max trade limit. See my comment below of the problematic part of the code that causes this issue.
bildschirmfoto 2019-02-14 um 15 25 52

java.lang.IllegalArgumentException: Amount is larger then 0.25 BTC
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)
	at bisq.core.offer.placeoffer.tasks.ValidateOffer.run(ValidateOffer.java:75)
	at bisq.common.taskrunner.TaskRunner.next(TaskRunner.java:69)
	at bisq.common.taskrunner.TaskRunner.run(TaskRunner.java:60)
	at bisq.core.offer.placeoffer.PlaceOfferProtocol.placeOffer(PlaceOfferProtocol.java:83)
	at bisq.core.offer.OpenOfferManager.placeOffer(OpenOfferManager.java:357)
	at bisq.desktop.main.offer.MutableOfferDataModel.onPlaceOffer(MutableOfferDataModel.java:415)
	at bisq.desktop.main.offer.MutableOfferViewModel.onPlaceOffer(MutableOfferViewModel.java:641)
	at bisq.desktop.main.offer.MutableOfferView.lambda$onPlaceOffer$2(MutableOfferView.java:358)
	at bisq.desktop.main.overlays.windows.OfferDetailsWindow.lambda$addConfirmAndCancelButtons$2(OfferDetailsWindow.java:401)
	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
	at javafx.event.Event.fireEvent(Event.java:198)
	at javafx.scene.Node.fireEvent(Node.java:8879)
	at javafx.scene.control.Button.fire(Button.java:200)
	at com.sun.javafx.scene.control.behavior.ButtonBehavior.keyReleased(ButtonBehavior.java:161)
	at com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
	at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
	at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
	at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
	at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
	at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
	at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
	at javafx.event.Event.fireEvent(Event.java:198)
	at javafx.scene.Scene$KeyHandler.process(Scene.java:4058)
	at javafx.scene.Scene$KeyHandler.access$1500(Scene.java:4004)
	at javafx.scene.Scene.processKeyEvent(Scene.java:2121)
	at javafx.scene.Scene$ScenePeerListener.keyEvent(Scene.java:2595)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:217)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(GlassViewEventHandler.java:149)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent$1(GlassViewEventHandler.java:248)
	at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:390)
	at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(GlassViewEventHandler.java:247)
	at com.sun.glass.ui.View.handleKeyEvent(View.java:547)
	at com.sun.glass.ui.View.notifyKey(View.java:971)

- Make all PaymentMethod constructors private
- Use PaymentMethod.getPaymentMethodById in Offer for getting the
PaymentMethod. This change a bit the context as now we always create the
PaymentMethod from the actual code base in contrast to the data which
have been used when creating the offer. As our fields as final and must
not change in software updates it should have no issues but we have to
keep that in mind to not alter the default values.
- Added a runtimeException in case the maxTradeLimit does not match one
of our default values.
- Use PaymentMethod.getDummyPaymentMethod(GUIUtil.SHOW_ALL_FLAG)
instead of new PaymentMethod(GUIUtil.SHOW_ALL_FLAG))
@ripcurlx
Copy link
Contributor

ACK - works now for me 👍

@ripcurlx ripcurlx merged commit e5dd9a2 into bisq-network:master Feb 15, 2019
@ManfredKarrer ManfredKarrer deleted the increase-trade-limits branch February 15, 2019 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants