Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sharpe perp, sharpe bridge. sharpe-dex #1661

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
27 changes: 27 additions & 0 deletions aggregator-derivatives/sharpe-perp/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import fetchURL from "../../utils/fetchURL";
import { FetchResultV2 } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";

const fetch = async (options: any): Promise<FetchResultV2> => {
let timestamp = options.toTimestamp

const fetchOptions:any = {method: 'GET'};

const data:any = await fetchURL('https://api-evm.orderly.network/v1/public/volume/stats?broker_id=sharpe_ai')
const dailyData:any = await fetchURL('https://base-api.sharpe.ai/api/dailySharpePerpVolume')

return {
totalVolume: data?.data?.perp_volume_ltd,
dailyVolume: dailyData?.dailyVolume
};
};
// CHAIN.ARBITRUM, CHAIN.MANTLE, CHAIN.OPTIMISM, CHAIN.BASE,
export default {
adapter: {
[CHAIN.ETHEREUM]: {
fetch: fetch,
start: 1711963031
},
},
version: 2
}
54 changes: 54 additions & 0 deletions bridge-aggregator/sharpe-bridge/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Chain } from "@defillama/sdk/build/general";
import { FetchOptions, FetchResultVolume, SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";

type IContract = {
[c: string | Chain]: string;
}

const contract: IContract = {
[CHAIN.AURORA]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.ARBITRUM]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.OPTIMISM]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.BASE]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.ETHEREUM]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.AVAX]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.BSC]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.LINEA]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.MANTA]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.POLYGON]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.POLYGON_ZKEVM]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.FANTOM]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.MODE]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.SCROLL]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.ZKSYNC]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.METIS]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
[CHAIN.XDAI]: '0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae',
}

const fetch: any = async (timestamp: number, _, { chain, getLogs, createBalances, }: FetchOptions): Promise<FetchResultVolume> => {
const dailyVolume = createBalances();
const data: any[] = await getLogs({
target: contract[chain],
eventAbi: 'event LiFiTransferStarted(bytes32 indexed transactionId, string bridge, string integrator, address referrer, address sendingAssetId, address receiver, uint256 minAmount, uint256 destinationChainId,bool hasSourceSwaps,bool hasDestinationCall )'
});
data.forEach((e: any) => {
if (e.integrator === 'sharpe.ai') {
dailyVolume.add(e.sendingAssetId, e.minAmount);
}
});

return { dailyBridgeVolume: dailyVolume, timestamp, } as any;
};

const adapter: SimpleAdapter = {
version: 2,
adapter: Object.keys(contract).reduce((acc, chain) => {
return {
...acc,
[chain]: { fetch, start: 1711963031, }
}
}, {})
};

export default adapter;
30 changes: 30 additions & 0 deletions dexs/sharpe-dex/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { ChainBlocks, FetchOptions, SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume";
import { getPrices } from "../../utils/prices";
import fetchURL from "../../utils/fetchURL";


const fetch = async () => {

const data:any = await fetchURL('https://base-api.sharpe.ai/api/dexVolume')
const dailyData:any = await fetchURL('https://base-api.sharpe.ai/api/dailySharpeDexVolume')

return {
totalVolume: data?.totalVolume,
dailyVolume: dailyData?.dailyVolume
};
};


const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.ETHEREUM]: {
fetch,
start: 1711963031,
},
},
};

export default adapter;
Loading