Skip to content

Commit

Permalink
feat:Adapter,Euclid-finance,ethereum (#1398)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpeluche authored Apr 9, 2024
1 parent 585484b commit 25842f5
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
"ethena",
"ether.fi",
"ethos-reserve",
"euclid-finance",
"euler",
"everrise",
"exactly",
Expand Down
37 changes: 37 additions & 0 deletions src/adapters/euclid-finance/ethereum/balance.ts
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',
}
}
31 changes: 31 additions & 0 deletions src/adapters/euclid-finance/ethereum/index.ts
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,
}
10 changes: 10 additions & 0 deletions src/adapters/euclid-finance/index.ts
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
2 changes: 2 additions & 0 deletions src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ import equilibria from '@adapters/equilibria'
import ethena from '@adapters/ethena'
import etherFi from '@adapters/ether.fi'
import ethosReserve from '@adapters/ethos-reserve'
import euclidFinance from '@adapters/euclid-finance'
import euler from '@adapters/euler'
import everrise from '@adapters/everrise'
import exactly from '@adapters/exactly'
Expand Down Expand Up @@ -544,6 +545,7 @@ export const adapters: Adapter[] = [
ethena,
etherFi,
ethosReserve,
euclidFinance,
euler,
everrise,
exactly,
Expand Down

0 comments on commit 25842f5

Please sign in to comment.