Skip to content

Commit

Permalink
Merge pull request #39 from forbole/radix-update
Browse files Browse the repository at this point in the history
chore: update deps and TVL value
  • Loading branch information
icfor authored Jan 5, 2024
2 parents 37a9a1a + 6d84b5b commit ec81883
Show file tree
Hide file tree
Showing 3 changed files with 237 additions and 283 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@
"license": "ISC",
"dependencies": {
"@apollo/datasource-rest": "^6.2.2",
"@apollo/server": "^4.9.5",
"@apollo/server": "^4.10.0",
"@apollo/server-plugin-response-cache": "^4.1.3",
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.18.2"
},
"devDependencies": {
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@stylistic/eslint-plugin": "^1.5.1",
"@commitlint/cli": "^18.4.4",
"@commitlint/config-conventional": "^18.4.4",
"@stylistic/eslint-plugin": "^1.5.3",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/node": "^20.10.5",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"@types/node": "^20.10.6",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
Expand Down
21 changes: 4 additions & 17 deletions src/graphql/routes/radix-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,11 @@ export class RadixAPI extends RESTDataSource {
}

async getRadixTVL() {
const [radixResponse, coinPrice] = await Promise.all([
this.gateway.getValidator(),
this.gecko.getCoinPrice("radix"),
]);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const validator = radixResponse.validators.items.find((i: any) =>
(i.address as string).includes(radixValidatorAddress),
);

if (!validator) {
return {
status: "error",
};
}
// @hardcoded
const tokens = 57_164_450.3;
const coinPrice = await this.gecko.getCoinPrice("radix");

const lockedUnit = Number(validator.locked_owner_stake_unit_vault.balance);
const TVL = lockedUnit * Number(coinPrice);
const TVL = tokens * Number(coinPrice);

if (Number.isNaN(TVL)) {
return {
Expand Down
Loading

0 comments on commit ec81883

Please sign in to comment.