-
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.
feat:Adapter,Euclid-finance,ethereum (#1398)
- Loading branch information
Showing
5 changed files
with
81 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 |
---|---|---|
|
@@ -205,6 +205,7 @@ | |
"ethena", | ||
"ether.fi", | ||
"ethos-reserve", | ||
"euclid-finance", | ||
"euler", | ||
"everrise", | ||
"exactly", | ||
|
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,37 @@ | ||
import type { Balance, BalancesContext, Contract } from '@lib/adapter' | ||
import { call } from '@lib/call' | ||
import { abi as erc20Abi } from '@lib/erc20' | ||
import { parseEther } from 'viem' | ||
const abi = { | ||
elETHPrice: { | ||
inputs: [], | ||
name: 'elETHPrice', | ||
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
} as const | ||
|
||
const oracle: `0x${string}` = '0x0d7fD234d543A04CADEDa3Fc58dF524656707faC' | ||
|
||
const WETH: Contract = { | ||
chain: 'ethereum', | ||
address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', | ||
decimals: 18, | ||
symbol: 'WETH', | ||
} | ||
|
||
export async function getEuclidBalance(ctx: BalancesContext, elETH: Contract): Promise<Balance> { | ||
const [userDeposit, exchangeRate] = await Promise.all([ | ||
call({ ctx, target: elETH.address, params: [ctx.address], abi: erc20Abi.balanceOf }), | ||
call({ ctx, target: oracle, abi: abi.elETHPrice }), | ||
]) | ||
|
||
return { | ||
...elETH, | ||
amount: userDeposit, | ||
underlyings: [{ ...WETH, amount: (userDeposit * exchangeRate) / parseEther('1.0') }], | ||
rewards: undefined, | ||
category: 'stake', | ||
} | ||
} |
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,31 @@ | ||
import { getEuclidBalance } from '@adapters/euclid-finance/ethereum/balance' | ||
import type { AdapterConfig, Contract, GetBalancesHandler } from '@lib/adapter' | ||
import { resolveBalances } from '@lib/balance' | ||
|
||
const elETH: Contract = { | ||
chain: 'ethereum', | ||
address: '0xa1aeea28896f18ba85715ce9367f3689925ed428', | ||
decimals: 18, | ||
symbol: 'elETH', | ||
underlyings: ['0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'], | ||
} | ||
|
||
export const getContracts = () => { | ||
return { | ||
contracts: { elETH }, | ||
} | ||
} | ||
|
||
export const getBalances: GetBalancesHandler<typeof getContracts> = async (ctx, contracts) => { | ||
const balances = await resolveBalances<typeof getContracts>(ctx, contracts, { | ||
elETH: getEuclidBalance, | ||
}) | ||
|
||
return { | ||
groups: [{ balances }], | ||
} | ||
} | ||
|
||
export const config: AdapterConfig = { | ||
startDate: 1707091200, | ||
} |
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: 'euclid-finance', | ||
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