Skip to content

Commit

Permalink
Merge pull request DefiLlama#2 from sherlock-protocol/master
Browse files Browse the repository at this point in the history
feat: add Sherlock Protocol
  • Loading branch information
slasher125 authored May 6, 2022
2 parents 2f9b64f + 6913106 commit 856ed6d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/adaptors/sherlock/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const utils = require('../utils');
const Web3 = require('web3');

const sherlockV2ABI = require('./sherlockV2abi.json');

const SherlockV2Contract = '0x0865a889183039689034dA55c1Fd12aF5083eabF';

const apy = async () => {
// Fetch APY
const apyData = await utils.getData(
'https://mainnet.indexer.sherlock.xyz/staking'
);

const web3 = new Web3(process.env.INFURA_CONNECTION);

// Fetch V2 pool TVL
const sherlockContract = new web3.eth.Contract(
sherlockV2ABI.abi,
SherlockV2Contract
);
const v2TVL = web3.utils.toBN(
await sherlockContract.methods.totalTokenBalanceStakers().call()
);

const usdcPool = {
pool: 'sherlock-v2-usdc',
chain: utils.formatChain('ethereum'),
project: 'sherlock',
symbol: utils.formatSymbol('USDC'),
tvlUsd: v2TVL.toNumber() / 1e6,
apy: apyData.usdc_apy,
};

return [usdcPool];
};

module.exports = {
timetravel: false,
apy,
};
17 changes: 17 additions & 0 deletions src/adaptors/sherlock/sherlockV2abi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"abi": [
{
"inputs": [],
"name": "totalTokenBalanceStakers",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
]
}

0 comments on commit 856ed6d

Please sign in to comment.