generated from bennycode/ts-node-starter
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import nock from 'nock'; | ||
|
||
describe('FeeAPI', () => { | ||
describe('getCurrentFees', () => { | ||
it('returns maker & taker fee rates', async () => { | ||
const response = { | ||
maker_fee_rate: '0.0050', | ||
taker_fee_rate: '0.0050', | ||
usd_volume: null, | ||
}; | ||
nock(global.REST_URL).get('/fees').reply(200, response); | ||
const canceledOrderIds = await global.client.rest.fee.getCurrentFees(); | ||
expect(canceledOrderIds).toEqual(response); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {AxiosInstance} from 'axios'; | ||
|
||
export interface Fee { | ||
/** A maker fee is paid when you create ("make") liquidity on the order book, i.e. you create an order which is not matched immediately. */ | ||
maker_fee_rate: string; | ||
/** A taker fee is paid when you remove ("take") liquidity from the order book, i.e. you create an order which matches an existing order (this includes all market orders). */ | ||
taker_fee_rate: string; | ||
/** Your 30-day trailing volume which impacts your fee rates. */ | ||
usd_volume: string | null; | ||
} | ||
|
||
export class FeeAPI { | ||
static readonly URL = { | ||
FEES: `/fees`, | ||
}; | ||
|
||
constructor(private readonly apiClient: AxiosInstance) {} | ||
|
||
/** | ||
* Get your current maker & taker fee rates, as well as your 30-day trailing volume. Quoted rates are subject to | ||
* change. | ||
* | ||
* @see https://docs.pro.coinbase.com/#fees | ||
* @see https://help.coinbase.com/en/pro/trading-and-funding/trading-rules-and-fees/fees.html | ||
*/ | ||
async getCurrentFees(): Promise<Fee> { | ||
const resource = FeeAPI.URL.FEES; | ||
const response = await this.apiClient.get(resource); | ||
return response.data; | ||
} | ||
} |