Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions src/tokens/apy/avantprotocol/apy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ import { cachedAxios } from "../../../core/axios";
import type { APYHandler, APYResult } from "../constants";
import { PROTOCOL, TOKENS } from "./constants";

interface Response {
interface SavUSDResponse {
savusdApy: string;
lastUpdated: string;
}

const getUrl = () => "https://app.avantprotocol.com/api/savusdApy";
interface SavETHResponse {
apy: string;
lastUpdated: string;
}

const getSavUSDUrl = () => "https://app.avantprotocol.com/api/savusdApy";
const getSavETHUrl = () => "https://app.avantprotocol.com/api/apy/saveth";

const getAPYAvantprotocol: APYHandler = async network => {
const tokens = TOKENS[network] || {};
Expand All @@ -16,17 +22,15 @@ const getAPYAvantprotocol: APYHandler = async network => {
);
if (tokenEntries.length === 0) return {};

const { data } = await cachedAxios.get<Response>(getUrl());

const rate = data?.savusdApy || 0;

const result: APYResult = {};

if (tokens?.savUSD) {
const { data } = await cachedAxios.get<SavUSDResponse>(getSavUSDUrl());
const rate = data?.savusdApy || 0;

result[tokens.savUSD] = {
address: tokens.savUSD,
symbol: "savUSD",

apys: [
{
address: tokens.savUSD,
Expand All @@ -38,6 +42,24 @@ const getAPYAvantprotocol: APYHandler = async network => {
};
}

if (tokens?.savETH) {
const { data } = await cachedAxios.get<SavETHResponse>(getSavETHUrl());
const rate = data?.apy || 0;

result[tokens.savETH] = {
address: tokens.savETH,
symbol: "savETH",
apys: [
{
address: tokens.savETH,
symbol: "savETH",
protocol: PROTOCOL,
value: Number(rate),
},
],
};
}

return result;
};

Expand Down
6 changes: 5 additions & 1 deletion src/tokens/apy/avantprotocol/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import type { NetworkType } from "@gearbox-protocol/sdk";
import type { Address } from "viem";
import type { PartialRecord } from "../../../core/utils";

export const TOKENS: PartialRecord<NetworkType, { savUSD?: Address }> = {
export const TOKENS: PartialRecord<
NetworkType,
{ savUSD?: Address; savETH?: Address }
> = {
Plasma: {
savUSD: "0xa29420057f3e3b9512d4786df135da1674bd74d4",
},
Mainnet: {
savUSD: "0xb8d89678e75a973e74698c976716308abb8a46a4",
savETH: "0xda06ee2dacf9245aa80072a4407debdea0d7e341",
},
};

Expand Down
Loading