-
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,Bank-ai,ethereum (#1397)
- Loading branch information
Showing
5 changed files
with
75 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 |
---|---|---|
|
@@ -134,6 +134,7 @@ | |
"badger-dao", | ||
"balancer", | ||
"bancor-v3", | ||
"bank-ai", | ||
"basedmarkets", | ||
"baseswap", | ||
"bedrock-unieth", | ||
|
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 type { Balance, BalancesContext, Contract } from '@lib/adapter' | ||
import { call } from '@lib/call' | ||
import { abi as erc20Abi } from '@lib/erc20' | ||
|
||
const abi = { | ||
getLockPeriodEnd: { | ||
inputs: [{ internalType: 'address', name: '_address', type: 'address' }], | ||
name: 'getLockPeriodEnd', | ||
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
} as const | ||
|
||
export async function getBankAiLockBalance(ctx: BalancesContext, locker: Contract): Promise<Balance> { | ||
const [userBalance, userLockEnd] = await Promise.all([ | ||
call({ ctx, target: locker.address, params: [ctx.address], abi: erc20Abi.balanceOf }), | ||
call({ ctx, target: locker.address, params: [ctx.address], abi: abi.getLockPeriodEnd }), | ||
]) | ||
|
||
const now = Date.now() / 1000 | ||
const unlockAt = Number(userLockEnd) | ||
|
||
return { | ||
...locker, | ||
amount: userBalance, | ||
underlyings: undefined, | ||
claimable: now > unlockAt ? userLockEnd : 0n, | ||
unlockAt, | ||
rewards: undefined, | ||
category: 'lock', | ||
} | ||
} |
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,29 @@ | ||
import { getBankAiLockBalance } from '@adapters/bank-ai/ethereum/balance' | ||
import type { AdapterConfig, Contract, GetBalancesHandler } from '@lib/adapter' | ||
import { resolveBalances } from '@lib/balance' | ||
|
||
const locker: Contract = { | ||
chain: 'ethereum', | ||
address: '0x140fae0a43190a3d0cbf8dbdb347200eb84e81d1', | ||
token: '0xf19693068120185664E211F619c4F0530cE07088', | ||
} | ||
|
||
export const getContracts = () => { | ||
return { | ||
contracts: { locker }, | ||
} | ||
} | ||
|
||
export const getBalances: GetBalancesHandler<typeof getContracts> = async (ctx, contracts) => { | ||
const balances = await resolveBalances<typeof getContracts>(ctx, contracts, { | ||
locker: getBankAiLockBalance, | ||
}) | ||
|
||
return { | ||
groups: [{ balances }], | ||
} | ||
} | ||
|
||
export const config: AdapterConfig = { | ||
startDate: 1711152000, | ||
} |
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: 'bank-ai', | ||
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