-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: export some missing types + more data queries (#64)
* export missing data types * add snxHolders({addresses}) option * add accountsFlaggedForLiquidation data query * add synthHolders data query * fix SnxHolderParams#addresses type * fix SnxHoldersParams.addresses option * more missing exports
- Loading branch information
Showing
28 changed files
with
1,657 additions
and
12,420 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,17 @@ | ||
export const accountsFlaggedForLiquidationMock = { | ||
response: { | ||
account: '0x3239f49d5298613eb4dbf99b37ce795f3159dcd3', | ||
collateral: '21719769773274085136404', | ||
collateralRatio: '502838404148398413', | ||
deadline: '1604580918', | ||
id: '1604580918-0x3239f49d5298613eb4dbf99b37ce795f3159dcd3', | ||
liquidatableNonEscrowSNX: '1738257073391178186056', | ||
}, | ||
formatted: { | ||
account: '0x3239f49d5298613eb4dbf99b37ce795f3159dcd3', | ||
collateral: 21719.769773274085, | ||
collateralRatio: 0.5028384041483984, | ||
deadline: 1604580918000, | ||
liquidatableNonEscrowSNX: 1738.2570733911782, | ||
}, | ||
}; |
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,12 @@ | ||
export const synthHoldersMock = { | ||
response: { | ||
balanceOf: '90038854631941946067435170', | ||
id: '0x6c5024cd4f8a59110119c56f8933403a539555eb-sUSD', | ||
synth: 'sUSD', | ||
}, | ||
formatted: { | ||
balanceOf: 90038854.63194194, | ||
address: '0x6c5024cd4f8a59110119c56f8933403a539555eb', | ||
synth: 'sUSD', | ||
}, | ||
}; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,2 @@ | ||
export * from './query'; | ||
export * from './parse'; |
17 changes: 17 additions & 0 deletions
17
packages/data/queries/accountsFlaggedForLiquidation/parse.ts
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,17 @@ | ||
import { AccountFlaggedForLiquidation as UnformattedAccountFlaggedForLiquidation } from '../../generated/graphql'; | ||
import { AccountFlaggedForLiquidation } from '../../src/types'; | ||
import { formatEther, formatTimestamp } from '../../src/utils'; | ||
|
||
export const parseAccountsFlaggedForLiquidation = ({ | ||
deadline, | ||
account, | ||
collateralRatio, | ||
liquidatableNonEscrowSNX, | ||
collateral, | ||
}: UnformattedAccountFlaggedForLiquidation): AccountFlaggedForLiquidation => ({ | ||
deadline: formatTimestamp(deadline), | ||
account, | ||
collateral: Number(formatEther(collateral)), | ||
collateralRatio: Number(formatEther(collateralRatio)), | ||
liquidatableNonEscrowSNX: Number(formatEther(liquidatableNonEscrowSNX)), | ||
}); |
32 changes: 32 additions & 0 deletions
32
packages/data/queries/accountsFlaggedForLiquidation/query.ts
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,32 @@ | ||
import { gql } from 'graphql-request'; | ||
import { AccountsFlaggedForLiquidationParams } from '../../src/types'; | ||
import { createGQLWhereString, createGQLBlockNumberString } from '../../src/utils'; | ||
|
||
export const createAccountsFlaggedForLiquidationQuery = ( | ||
params?: AccountsFlaggedForLiquidationParams | ||
): string => { | ||
const whereString = createGQLWhereString( | ||
Object.entries({ | ||
account: (params?.account ?? null) != null ? 'account' : null, | ||
deadline_gte: (params?.minTimestamp ?? null) != null ? 'minTimestamp' : null, | ||
deadline_lte: (params?.maxTimestamp ?? null) != null ? 'maxTimestamp' : null, | ||
}) | ||
); | ||
|
||
return gql` | ||
query accountFlaggedForLiquidations($max: Int, $account: String, $minTimestamp: Int, $maxTimestamp: Int) { | ||
accountFlaggedForLiquidations( | ||
first: $max${createGQLBlockNumberString(params?.blockNumber ?? null)} | ||
where: ${whereString} | ||
orderBy: deadline | ||
orderDirection: asc | ||
) { | ||
deadline | ||
account | ||
collateralRatio | ||
liquidatableNonEscrowSNX | ||
collateral | ||
} | ||
} | ||
`; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './query'; | ||
export * from './parse'; |
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,13 @@ | ||
import { SynthHolder as UnformattedSynthHolder } from '../../generated/graphql'; | ||
import { SynthHolder } from '../../src/types'; | ||
import { formatEther } from '../../src/utils'; | ||
|
||
export const parseSynthHolders = ({ | ||
id, | ||
synth, | ||
balanceOf, | ||
}: UnformattedSynthHolder): SynthHolder => ({ | ||
address: id.split('-')[0], | ||
synth, | ||
balanceOf: Number(formatEther(balanceOf)), | ||
}); |
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,27 @@ | ||
import { gql } from 'graphql-request'; | ||
import { SynthHolderParams } from '../../src/types'; | ||
import { createGQLWhereString, createGQLBlockNumberString } from '../../src/utils'; | ||
|
||
export const createSynthHoldersQuery = (params?: SynthHolderParams): string => { | ||
const whereString = createGQLWhereString( | ||
Object.entries({ | ||
id: (params?.id ?? null) != null ? 'id' : null, | ||
synth: (params?.synth ?? null) != null ? 'synth' : null, | ||
}) | ||
); | ||
|
||
return gql` | ||
query synthHolders($max: Int, $id: String, $synth: String) { | ||
synthHolders( | ||
first: $max${createGQLBlockNumberString(params?.blockNumber ?? null)} | ||
where: ${whereString} | ||
orderBy: balanceOf | ||
orderDirection: desc | ||
) { | ||
id | ||
synth | ||
balanceOf | ||
} | ||
} | ||
`; | ||
}; |
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
Oops, something went wrong.