-
Notifications
You must be signed in to change notification settings - Fork 15
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
10 changed files
with
89 additions
and
87 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 was deleted.
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,29 @@ | ||
import { CHAIN_IDs } from "../../constants"; | ||
import { Coingecko } from "../../coingecko/Coingecko"; | ||
import { QueryBase } from "./baseQuery"; | ||
|
||
type QueryBaseArgs = ConstructorParameters<typeof QueryBase>; | ||
|
||
export class CustomGasTokenQueries extends QueryBase { | ||
readonly customGasTokenSymbol: string; | ||
|
||
constructor(args: { queryBaseArgs: QueryBaseArgs; customGasTokenSymbol: string }) { | ||
super(...args.queryBaseArgs); | ||
this.customGasTokenSymbol = args.customGasTokenSymbol; | ||
} | ||
|
||
override async getTokenPrice(tokenSymbol: string): Promise<number> { | ||
if (!this.symbolMapping[tokenSymbol]) throw new Error(`${tokenSymbol} does not exist in mapping`); | ||
const coingeckoInstance = Coingecko.get(this.logger, this.coingeckoProApiKey); | ||
const [, tokenPrice] = await coingeckoInstance.getCurrentPriceByContract( | ||
this.symbolMapping[tokenSymbol].addresses[CHAIN_IDs.MAINNET], | ||
"usd" | ||
); | ||
|
||
const [, customGasTokenPrice] = await coingeckoInstance.getCurrentPriceByContract( | ||
this.symbolMapping[this.customGasTokenSymbol].addresses[CHAIN_IDs.MAINNET], | ||
"usd" | ||
); | ||
return Number((tokenPrice / customGasTokenPrice).toFixed(this.symbolMapping[this.customGasTokenSymbol].decimals)); | ||
} | ||
} |
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,3 +1,3 @@ | ||
export * from "./baseQuery"; | ||
export * from "./polygon"; | ||
export * from "./factory"; | ||
export * from "./customGasToken"; |
This file was deleted.
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
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