forked from DefiLlama/dimension-adapters
-
Notifications
You must be signed in to change notification settings - Fork 0
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 DefiLlama#1398 from DefiLlama/synthetix-v3-volume
add synthetix-v3 volume
- Loading branch information
Showing
1 changed file
with
33 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,33 @@ | ||
import { ChainBlocks, FetchOptions, SimpleAdapter } from "../../adapters/types"; | ||
import { CHAIN } from "../../helpers/chains"; | ||
|
||
const contract_address = '0x0a2af931effd34b81ebcc57e3d3c9b1e1de1c9ce'; | ||
const usdt = 'tether' | ||
const event_order_settled = 'event OrderSettled(uint128 indexed marketId,uint128 indexed accountId,uint256 fillPrice,int256 pnl,int256 accruedFunding,int128 sizeDelta,int128 newSize,uint256 totalFees,uint256 referralFees,uint256 collectedFees,uint256 settlementReward,bytes32 indexed trackingCode,address settler)' | ||
const fetchFees = async (timestamp: number, _: ChainBlocks, options: FetchOptions) => { | ||
const dailyVolume = options.createBalances(); | ||
const logs = await options.getLogs({ | ||
target: contract_address, | ||
eventAbi: event_order_settled | ||
}); | ||
|
||
logs.forEach((log: any) => { | ||
const volume = Math.abs(Number(log.fillPrice)/1e18 * Number(log.sizeDelta)/1e18) | ||
dailyVolume.addCGToken(usdt, volume) | ||
}); | ||
|
||
return { | ||
dailyVolume: dailyVolume, | ||
timestamp | ||
} | ||
} | ||
|
||
const adapters: SimpleAdapter = { | ||
adapter: { | ||
[CHAIN.BASE]: { | ||
fetch: fetchFees, | ||
start: 1705104000, | ||
}, | ||
} | ||
} | ||
export default adapters |