Skip to content

Commit

Permalink
Merge pull request #1786 from 4Cast-Studio/master
Browse files Browse the repository at this point in the history
add 4Cast fees adaptor
  • Loading branch information
dtmkeng committed Aug 21, 2024
2 parents f6546af + 13bb540 commit aec3a3b
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions fees/4cast/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Adapter, FetchOptions, FetchV2 } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { postURL } from "../../utils/fetchURL";

interface IData {
dailyFees: string;
}

const endpoint = "https://www.4cast.win/api/api/platformFees";

function createSolBalances(options: FetchOptions, value: string) {
const balances = options.createBalances();

balances.add('So11111111111111111111111111111111111111112', Number(value) * 1e9);

return balances;
}

const fetch: FetchV2 = async (options) => {
const data: IData = await postURL(endpoint, {
startTimestamp: options.startTimestamp,
endTimestamp: options.endTimestamp,
});

return {
dailyFees: createSolBalances(options, data.dailyFees),
};
};

const adapter: Adapter = {
version: 2,
adapter: {
[CHAIN.SOLANA]: {
fetch,
runAtCurrTime: false,
start: 1721174400,
},
},
};

export default adapter;

0 comments on commit aec3a3b

Please sign in to comment.