Skip to content

Commit

Permalink
fix: tvl value
Browse files Browse the repository at this point in the history
  • Loading branch information
icfor committed Jan 5, 2024
1 parent ec81883 commit 4737129
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/graphql/routes/oasis-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class OasisAPI extends RESTDataSource {

async getOasisTVL() {
// @hardcoded
const base = 932608;
const base = 57_164_450.3;
const price = await this.gecko.getCoinPrice("rose");

return [
Expand Down
21 changes: 17 additions & 4 deletions src/graphql/routes/radix-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,24 @@ export class RadixAPI extends RESTDataSource {
}

async getRadixTVL() {
// @hardcoded
const tokens = 57_164_450.3;
const coinPrice = await this.gecko.getCoinPrice("radix");
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",
};
}

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

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

0 comments on commit 4737129

Please sign in to comment.