-
Notifications
You must be signed in to change notification settings - Fork 951
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1768 from Allez-xyz/master
Kamino lend interest and fee data
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 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
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; | ||
|
||
|