-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
107 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
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,40 @@ | ||
import { getBlackRockFundMasterChefPoolBalances } from '@adapters/blackrockfund/ethereum/masterChef' | ||
import type { AdapterConfig, BaseContext, Contract, GetBalancesHandler } from '@lib/adapter' | ||
import { resolveBalances } from '@lib/balance' | ||
import { getMasterChefPoolsContracts } from '@lib/masterchef/masterChefContract' | ||
|
||
const masterChef: Contract = { | ||
chain: 'ethereum', | ||
address: '0x1fde0d2f44539789256d94d1784a86bf77d66dd0', | ||
} | ||
|
||
const masterChef2: Contract = { | ||
chain: 'ethereum', | ||
address: '0x1e4a10d18698e4450e13b4e8ef361a5841850611', | ||
} | ||
|
||
export const getContracts = async (ctx: BaseContext) => { | ||
const [pools, pools2] = await Promise.all([ | ||
getMasterChefPoolsContracts(ctx, { masterChefAddress: masterChef.address }), | ||
getMasterChefPoolsContracts(ctx, { masterChefAddress: masterChef2.address }), | ||
]) | ||
|
||
return { | ||
contracts: { pools, pools2 }, | ||
} | ||
} | ||
|
||
export const getBalances: GetBalancesHandler<typeof getContracts> = async (ctx, contracts) => { | ||
const balances = await resolveBalances<typeof getContracts>(ctx, contracts, { | ||
pools: (...args) => getBlackRockFundMasterChefPoolBalances(...args, masterChef), | ||
pools2: (...args) => getBlackRockFundMasterChefPoolBalances(...args, masterChef2), | ||
}) | ||
|
||
return { | ||
groups: [{ balances }], | ||
} | ||
} | ||
|
||
export const config: AdapterConfig = { | ||
startDate: 1708560000, | ||
} |
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,54 @@ | ||
import type { Balance, BalancesContext, Contract } from '@lib/adapter' | ||
import { mapSuccessFilter } from '@lib/array' | ||
import { getMasterChefPoolsBalances, type GetUsersInfosParams } from '@lib/masterchef/masterChefBalance' | ||
import { multicall } from '@lib/multicall' | ||
|
||
const abi = { | ||
pendingBTC: { | ||
inputs: [ | ||
{ internalType: 'uint256', name: '_pid', type: 'uint256' }, | ||
{ internalType: 'address', name: '_user', type: 'address' }, | ||
], | ||
name: 'pendingBTC', | ||
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
} as const | ||
|
||
const BTC: Contract = { | ||
chain: 'ethereum', | ||
address: '0xbD6323A83b613F668687014E8A5852079494fB68', | ||
decimals: 18, | ||
symbol: 'BTC', | ||
} | ||
|
||
export async function getBlackRockFundMasterChefPoolBalances( | ||
ctx: BalancesContext, | ||
pools: Contract[], | ||
masterChef: Contract, | ||
): Promise<Balance[]> { | ||
return getMasterChefPoolsBalances(ctx, pools, { | ||
masterChefAddress: masterChef.address, | ||
rewardToken: BTC, | ||
getUserPendingRewards: getUserPendingBTC, | ||
}) | ||
} | ||
|
||
export async function getUserPendingBTC( | ||
ctx: BalancesContext, | ||
{ masterChefAddress, pools, rewardToken }: GetUsersInfosParams, | ||
) { | ||
const userPendingRewards = await multicall({ | ||
ctx, | ||
calls: pools.map((pool) => ({ target: masterChefAddress, params: [pool.pid, ctx.address] }) as const), | ||
abi: abi.pendingBTC, | ||
}) | ||
|
||
return mapSuccessFilter(userPendingRewards, (res: any, index) => { | ||
const pool = pools[index] | ||
const reward = rewardToken || (pool.rewards?.[0] as Contract) | ||
|
||
return [{ ...reward, amount: res.output }] | ||
}) | ||
} |
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,10 @@ | ||
import type { Adapter } from '@lib/adapter' | ||
|
||
import * as ethereum from './ethereum' | ||
|
||
const adapter: Adapter = { | ||
id: 'blackrockfund', | ||
ethereum: ethereum, | ||
} | ||
|
||
export default adapter |
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