Skip to content

Commit

Permalink
Merge pull request #1661 from Sharpelabs/main
Browse files Browse the repository at this point in the history
add sharpe perp, sharpe bridge. sharpe-dex
  • Loading branch information
dtmkeng committed Sep 22, 2024
2 parents d1892cc + 0dd41ee commit 4acc5b8
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
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;

0 comments on commit 4acc5b8

Please sign in to comment.