Skip to content

Commit

Permalink
Merge pull request #1768 from Allez-xyz/master
Browse files Browse the repository at this point in the history
Kamino lend interest and fee data
  • Loading branch information
dtmkeng committed Aug 14, 2024
2 parents 027985e + 7cfcd7e commit 99dd015
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions fees/kamino-lending/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Adapter, FetchV2 } from "../../adapters/types";
import fetchURL from "../../utils/fetchURL";
import { CHAIN } from "../../helpers/chains";
import { getTimestampAtStartOfPreviousDayUTC } from "../../utils/date";

// Define the URL of the endpoint
const AllezLabsKaminoFeeEndpoint = 'https://allez-xyz--kamino-fees-api-get-fees-lifetime-kamino.modal.run';
const KaminoStartTimestamp = 1697068700;

// Function to make the GET request
const fetch: FetchV2 = async ({ endTimestamp }) => {
const dayTimestamp = getTimestampAtStartOfPreviousDayUTC(endTimestamp);
const historicalFeesRes = (await fetchURL(AllezLabsKaminoFeeEndpoint));

const totalFee = historicalFeesRes['data']
.filter(row => row.timestamp <= dayTimestamp)
.reduce((acc, {KlendFeesUsd}) => acc + KlendFeesUsd, 0);

const totalRevenue = historicalFeesRes['data']
.filter(row => row.timestamp <= dayTimestamp)
.reduce((acc, {KlendRevenueUsd}) => acc + KlendRevenueUsd, 0);


const dailyFee = historicalFeesRes['data']
.find(row => Math.abs(row.timestamp - dayTimestamp) < 3600*24 - 1)?.KlendFeesUsd;

const dailyRevenue = historicalFeesRes['data']
.find(row => Math.abs(row.timestamp - dayTimestamp) < 3600*24 - 1)?.KlendRevenueUsd;

return {
timestamp: dayTimestamp,
totalFees: `${totalFee}`,
dailyFees: `${dailyFee}`,
totalRevenue: `${totalRevenue}`,
dailyRevenue: `${dailyRevenue}`
};
};
const methodology = {
Fees: "Fees are aggregated by Allez Labs using the Kamino API"
}

const adapter: Adapter = {
version: 2,
adapter: {
[CHAIN.SOLANA]: {
fetch,
runAtCurrTime: true,
start: 1697068700,
meta: {
methodology
}
}
}
}
export default adapter;


0 comments on commit 99dd015

Please sign in to comment.