Skip to content

Commit e34a31c

Browse files
jankjrkjr
authored andcommitted
add support for the get account volumes query
Signed-off-by: kjr <mig@jankjr.dk> Signed-off-by: kjr <jan.k@nash.io>
1 parent 0afaf3f commit e34a31c

File tree

4 files changed

+105
-4
lines changed

4 files changed

+105
-4
lines changed

integration-tests/queries.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ async function run() {
4141
await test('getAccountAddress', [Nash.CryptoCurrency.NEO])
4242
await test('getAccountAddress', [Nash.CryptoCurrency.ETH])
4343
await test('getAccountAddress', [Nash.CryptoCurrency.BTC])
44+
await test('getAccountVolumes', [])
4445
await test('listAccountOrders', [])
4546
await test('getOrderBook', ['eth_neo'])
4647
await test('listAccountOrders', [

src/client/client.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
GetAccountAddressResult
3939
} from '../queries/account/getAccountAddress'
4040
import { LIST_ACCOUNT_BALANCES } from '../queries/account/listAccountBalances'
41+
import { GET_ACCOUNT_VOLUMES } from '../queries/account/getAccountVolumes'
4142
import {
4243
LIST_MOVEMENTS,
4344
ListMovementsParams
@@ -169,6 +170,7 @@ import {
169170
AccountTransaction,
170171
OrderPlaced,
171172
Market,
173+
AccountVolume,
172174
Order,
173175
DateTime,
174176
AccountOrder,
@@ -1178,6 +1180,28 @@ export class Client {
11781180
return result.data.listAssets
11791181
}
11801182

1183+
/**
1184+
* Fetches the current account volumes for the current periods
1185+
*
1186+
* @returns
1187+
*
1188+
* Example
1189+
* ```
1190+
* const volumes = await nash.getAccountVolumes()
1191+
* console.log(volumes.makerFeeRate)
1192+
* console.log(volumes.takerFeeRate)
1193+
* ```
1194+
*/
1195+
public async getAccountVolumes(): Promise<AccountVolume> {
1196+
const result = await this.gql.query<{ getAccountVolumes: AccountVolume }>({
1197+
query: GET_ACCOUNT_VOLUMES,
1198+
variables: {
1199+
payload: {}
1200+
}
1201+
})
1202+
return result.data.getAccountVolumes
1203+
}
1204+
11811205
/**
11821206
* List a [[CandleRange]] for the given market.
11831207
*
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import gql from 'graphql-tag'
2+
3+
export const GET_ACCOUNT_VOLUMES = gql`
4+
query GetAccountVolumes($payload: GetAccountVolumesParams!) {
5+
getAccountVolumes(payload: $payload) {
6+
daily {
7+
accountLimit {
8+
amount
9+
currency
10+
}
11+
12+
accountSpend {
13+
amount
14+
currency
15+
}
16+
17+
accountVolume {
18+
amount
19+
currency
20+
}
21+
22+
exchangeVolume {
23+
amount
24+
currency
25+
}
26+
}
27+
makerFeeRate
28+
monthly {
29+
accountLimit {
30+
amount
31+
currency
32+
}
33+
34+
accountSpend {
35+
amount
36+
currency
37+
}
38+
39+
accountVolume {
40+
amount
41+
currency
42+
}
43+
44+
exchangeVolume {
45+
amount
46+
currency
47+
}
48+
}
49+
takerFeeRate
50+
yearly {
51+
accountLimit {
52+
amount
53+
currency
54+
}
55+
56+
accountSpend {
57+
amount
58+
currency
59+
}
60+
61+
accountVolume {
62+
amount
63+
currency
64+
}
65+
66+
exchangeVolume {
67+
amount
68+
currency
69+
}
70+
}
71+
}
72+
}
73+
`

src/types/account.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Asset, CurrencyAccountVolume } from '../types'
2-
1+
import { Asset } from '../types'
2+
import { CurrencyAmount } from '../types'
33
export interface AccountWallet {
44
address: string
55
blockchain: string
@@ -47,8 +47,11 @@ export interface AccountPortfolio {
4747
}
4848

4949
export interface AccountVolume {
50-
thirtyDayTotalVolumePercent: number
51-
volumes: CurrencyAccountVolume[]
50+
daily: CurrencyAmount
51+
makerFeeRate: number
52+
monthly: CurrencyAmount
53+
takerFeeRate: number
54+
yearly: CurrencyAmount
5255
}
5356

5457
export interface AccountPortfolioTotal {

0 commit comments

Comments
 (0)