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

feat: gate provider implementation #611

Merged
merged 13 commits into from
Mar 8, 2022
Merged

feat: gate provider implementation #611

merged 13 commits into from
Mar 8, 2022

Conversation

adamewozniak
Copy link
Collaborator

@adamewozniak adamewozniak commented Mar 7, 2022

Description

Adds gate.io as a provider to support umee/usdt

closes: #604


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added appropriate labels to the PR
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Comment on lines 203 to 207
// subscribeCandles subscribes to the candle channels for all pairs one-by-one.
// The gate API currently only supports subscribing to one kline market at a time.
//
// REF: https://www.gate.io/docs/websocket/#kline-subscription
func (p *GateProvider) subscribeCandles(cps ...types.CurrencyPair) error {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just want to highlight this. Per gate's docs :

Can only subscribe to one market at the same time, market list is not supported currently. 
For multiple subscriptions, only the last one takes effect.

tldr; we can only use gate for one currency pair (which will have to be umee) until they support multiple.
We could do some strict config validation for this, but seems like we should just add a log warning. wdyt @alexanderbez ?

Copy link
Contributor

Choose a reason for hiding this comment

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

lol what a shitty API. My proposal to actually add a (temporary) error to the config validation where an error is thrown if gate is used for more than one pair. WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup! Agreed

@codecov-commenter
Copy link

codecov-commenter commented Mar 7, 2022

Codecov Report

Merging #611 (e2e1437) into main (c646ad7) will decrease coverage by 0.42%.
The diff coverage is 44.29%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #611      +/-   ##
==========================================
- Coverage   48.44%   48.02%   -0.43%     
==========================================
  Files          63       64       +1     
  Lines        7932     8810     +878     
==========================================
+ Hits         3843     4231     +388     
- Misses       3831     4321     +490     
  Partials      258      258              
Impacted Files Coverage Δ
x/leverage/client/cli/query.go 0.00% <0.00%> (ø)
x/leverage/keeper/exchange_rate.go 61.81% <0.00%> (-17.26%) ⬇️
x/leverage/keeper/grpc_query.go 7.33% <0.00%> (-3.38%) ⬇️
x/leverage/keeper/keeper.go 47.80% <ø> (ø)
x/leverage/keeper/loaned.go 0.00% <0.00%> (ø)
x/leverage/keeper/oracle.go 68.42% <0.00%> (ø)
x/leverage/simulation/operations.go 91.69% <ø> (ø)
x/leverage/types/genesis.go 8.00% <ø> (-0.83%) ⬇️
x/leverage/types/params.go 22.66% <0.00%> (-3.90%) ⬇️
x/leverage/types/query.pb.gw.go 0.00% <0.00%> (ø)
... and 2 more

cp := types.CurrencyPair{Base: "ATOM", Quote: "USDT"}
GateSymbol := currencyPairToGatePair(cp)
require.Equal(t, GateSymbol, "ATOM_USDT")
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should definitely add tests for GetCandlePrices in a separate pr

Copy link
Contributor

Choose a reason for hiding this comment

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

agreed

@adamewozniak adamewozniak marked this pull request as ready for review March 8, 2022 00:09
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

LGTM. Let's get that config change in.

@adamewozniak
Copy link
Collaborator Author

LGTM. Let's get that config change in.

Done at ed837f4

@RafilxTenfen do you want to check this out before it gets merged in?

Copy link
Contributor

@RafilxTenfen RafilxTenfen left a comment

Choose a reason for hiding this comment

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

  • The only change actually needed is the mutex lock and unlock at reconnect

price-feeder/oracle/provider/gate.go Outdated Show resolved Hide resolved
price-feeder/oracle/provider/gate.go Show resolved Hide resolved
price-feeder/oracle/provider/gate.go Outdated Show resolved Hide resolved
cp := types.CurrencyPair{Base: "ATOM", Quote: "USDT"}
GateSymbol := currencyPairToGatePair(cp)
require.Equal(t, GateSymbol, "ATOM_USDT")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

agreed

@mergify mergify bot merged commit 9e4b1aa into main Mar 8, 2022
@mergify mergify bot deleted the woz/gate branch March 8, 2022 18:17
mergify bot pushed a commit that referenced this pull request Mar 8, 2022
## Description

Adds gate.io as a provider to support [umee/usdt](https://www.gate.io/trade/UMEE_USDT)

closes: #604

----

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added appropriate labels to the PR
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/umee-network/umee/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

(cherry picked from commit 9e4b1aa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add gate as a provider for the price feeder
4 participants