-
Notifications
You must be signed in to change notification settings - Fork 11
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
1 parent
fc039c5
commit 5572a51
Showing
11 changed files
with
143 additions
and
40 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
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 |
---|---|---|
@@ -1,23 +1,45 @@ | ||
import { | ||
DerivativeMarket, | ||
AllChronosDerivativeMarketSummary | ||
AllChronosDerivativeMarketSummary, | ||
PerpetualMarket, | ||
ExpiryFuturesMarket | ||
} from '@injectivelabs/sdk-ts' | ||
import { BaseCacheApi } from './base' | ||
import { | ||
indexerDerivativesApi, | ||
indexerRestDerivativeChronosApi | ||
} from '@/Service' | ||
|
||
export class DerivativeCacheApi extends BaseCacheApi { | ||
async fetchMarkets(props?: { marketStatus?: string }) { | ||
const response = await this.client.get<DerivativeMarket[]>( | ||
'/derivatives/markets', | ||
{ params: { marketStatus: props?.marketStatus } } | ||
) | ||
return response.data | ||
try { | ||
const response = await this.client.get<DerivativeMarket[]>( | ||
'/derivatives/markets', | ||
{ params: { marketStatus: props?.marketStatus } } | ||
) | ||
|
||
return response.data | ||
} catch (e) { | ||
const markets = (await indexerDerivativesApi.fetchMarkets()) as Array< | ||
PerpetualMarket | ExpiryFuturesMarket | ||
> | ||
|
||
return markets | ||
} | ||
} | ||
|
||
async fetchMarketsSummary() { | ||
const response = await this.client.get<AllChronosDerivativeMarketSummary[]>( | ||
'/derivatives/summary' | ||
) | ||
try { | ||
const response = await this.client.get< | ||
AllChronosDerivativeMarketSummary[] | ||
>('/derivatives/summary') | ||
|
||
return response.data | ||
} catch (e) { | ||
const response = | ||
await indexerRestDerivativeChronosApi.fetchMarketsSummary() | ||
|
||
return response.data | ||
return 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 |
---|---|---|
@@ -1,18 +1,31 @@ | ||
import { SpotMarket, AllChronosSpotMarketSummary } from '@injectivelabs/sdk-ts' | ||
import { BaseCacheApi } from './base' | ||
import { indexerRestSpotChronosApi, indexerSpotApi } from '@/Service' | ||
|
||
export class SpotCacheApi extends BaseCacheApi { | ||
async fetchMarkets() { | ||
const response = await this.client.get<SpotMarket[]>('/spot/markets') | ||
try { | ||
const response = await this.client.get<SpotMarket[]>('/spot/markets') | ||
|
||
return response.data | ||
return response.data | ||
} catch (e) { | ||
const response = await indexerSpotApi.fetchMarkets() | ||
|
||
return response | ||
} | ||
} | ||
|
||
async fetchMarketsSummary() { | ||
const response = await this.client.get<AllChronosSpotMarketSummary[]>( | ||
'/spot/summary' | ||
) | ||
try { | ||
const response = await this.client.get<AllChronosSpotMarketSummary[]>( | ||
'/spot/summary' | ||
) | ||
|
||
return response.data | ||
} catch (e) { | ||
const response = await indexerRestSpotChronosApi.fetchMarketsSummary() | ||
|
||
return response.data | ||
return 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,22 @@ | ||
import { Pagination, Validator } from '@injectivelabs/sdk-ts' | ||
import { BaseCacheApi } from './base' | ||
import { stakingApi } from '@/Service' | ||
|
||
export class StakingCacheApi extends BaseCacheApi { | ||
async fetchValidators(_params?: any) { | ||
try { | ||
const response = await this.client.get<{ | ||
validators: Validator[] | ||
pagination: Pagination | ||
}>('/validators') | ||
|
||
return response.data | ||
} catch (e) { | ||
const { validators, pagination } = await stakingApi.fetchValidators({ | ||
limit: 200 | ||
}) | ||
|
||
return { validators, pagination } | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,13 +1,22 @@ | ||
import { Pagination, TotalSupply } from '@injectivelabs/sdk-ts' | ||
import { BaseCacheApi } from './base' | ||
import { bankApi } from '@/Service' | ||
|
||
export class TokenCacheApi extends BaseCacheApi { | ||
async fetchTotalSupply() { | ||
const response = await this.client.get<{ | ||
supply: TotalSupply | ||
pagination: Pagination | ||
}>('/tokens') | ||
async fetchTotalSupply(_params: any) { | ||
try { | ||
const response = await this.client.get<{ | ||
supply: TotalSupply | ||
pagination: Pagination | ||
}>('/tokens') | ||
|
||
return response.data | ||
return response.data | ||
} catch (e) { | ||
const { supply, pagination } = await bankApi.fetchTotalSupply({ | ||
limit: 2000 | ||
}) | ||
|
||
return { supply, pagination } | ||
} | ||
} | ||
} |
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
Empty file.
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