-
Notifications
You must be signed in to change notification settings - Fork 44
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
add pairs #495
add pairs #495
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #495 +/- ##
==========================================
- Coverage 61.02% 60.42% -0.61%
==========================================
Files 129 131 +2
Lines 12817 12952 +135
==========================================
+ Hits 7822 7826 +4
- Misses 4176 4303 +127
- Partials 819 823 +4
☔ View full report in Codecov by Sentry. |
Since this PR is not linked to a well documented issue, can you provide more documentation in the PR description. Describe:
There are lots of images that are imported. Can you mention where they came from and what their copyright is? |
The use case that the PR is trying to solveProviding a RPC endpoint, a swapcli command, and a UI to see Pairs. What a pair isA pair is simply an abstraction over offers (a summary), it doesn't contains any offers, just metadata about them, grouped by assets. Example output of swap-cli pairs:
Name: Name of the asset What follow-up work is needed to make this PR useful.None It sounds like it depends on a whitelist. Describe how you think we should solve that problem.It doesn't depend on it, it's just that for now it's always set to false unless it's ETH. There should be a verified-list somewhere, that is parsed by swapd. Asset Imageshttps://github.com/spothq/cryptocurrency-icons/blob/master/LICENSE.md |
Let's say someone makes the following absurd offer with a 2 million USDT to XMR exchange rate and half of a monero being offered up.
Would this PR then report that there is a million dollars of USDT liquidity in the network? |
Yes, and if you put something absurd for XMR you get something similar as there's no proof of funds for creating an offer. If you don't like it we could:
|
Let's see what @noot or someone else thinks. Are there any exchanges that print numbers like this or that have similar concept of what "liquidity" is? At least if end users are using our software, they can't offer up more XMR than they have. Offering up exchange rates that are extremely far from what anyone would take at the moment is 100% guaranteed to happen. I've never seen it not happen on any platform. I don't think having a single offer that is legit but absurd affect a network wide statistic is desirable behavior. |
@stubbrn sorry for the late response. overall, I like the idea and I think it helps give a nice snapshot view of the network. but yeah, false liquidity reporting would be an issue. we could change the definition for now to say "reported liquidity" or something like that? I've thought a bit about how to add proof of XMR liquidity (#75) but there are still issues, as the maker can just transfer their funds to another account or something after sending the proof. I think for now, potentially changing the definition/adding a specific definition would be good. |
Ok, so I'm probably going to:
If we're able to solve the problems with XMR proof-of-reserves, they could also maybe serve as part of heuristics for attempting to prevent false offers spam (you won't be able to just buy/borrow IP addresses for $10 or maybe less with tor exit nodes + generate PeerIds and cancel everything after step 1 of the protocol, as a taker could potentially see that N different makers have the same proof, so it would be more difficult to spam, although if you need to take the offer to be able to see it it wouldn't work), but that's outside of the scope of this discussion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks good, however I just noticed the hundreds of token icons added lol. can you change this to have just the tokens currently used + common ERC20 tokens?
rpc/net.go
Outdated
log.Debugf("Failed to query peer ID %s", p) | ||
continue | ||
} | ||
if len(msg.Offers) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit for readability, but can you change this to:
if len(msg.Offers) == 0 {
continue
}
// the code that's currently in this block here
rpc/net.go
Outdated
index, exists := addrs[address] | ||
pair := types.NewPair(o.EthAsset) | ||
if !exists { | ||
addrs[address] = index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the value does not exist in the map, isn't index
always 0? this seems off, can you simplify this logic to just have one map pairs := make(map[ethcommon.Address]*types.Pair)
where the key is the ETH-asset?
common/rpctypes/types.go
Outdated
@@ -147,3 +147,11 @@ type AddressesResponse struct { | |||
type PeersResponse struct { | |||
Addrs []string `json:"addresses" validate:"dive,required"` | |||
} | |||
|
|||
// PairsRequest ... | |||
type PairsRequest = DiscoverRequest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since the Provides
field of the request is always set to ""
, can you define this as a new type:
type PairsRequest struct {
SearchTime uint64 `json:"searchTime"` // in seconds
}
Ability to select Pairs
Just a mockup for now, as the logic of the future "getPairs" RPC endpoint requires to know whether there's a "hard" whitelist or not (as discussed in #491 and #178).