-
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
99 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,53 @@ | ||
import type { Balance, BalancesContext, Contract } from '@lib/adapter' | ||
import { call } from '@lib/call' | ||
|
||
const abi = { | ||
stakeBalanceOfv1: { | ||
inputs: [{ internalType: 'address', name: 'account', type: 'address' }], | ||
name: 'stakedBalanceOf', | ||
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
stakeBalanceOfv2: { | ||
inputs: [{ internalType: 'address', name: 'account', type: 'address' }], | ||
name: 'stakeBalanceOf', | ||
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
} as const | ||
|
||
export async function getCLYv1StakeBalances(ctx: BalancesContext, staker: Contract): Promise<Balance> { | ||
const amount = await call({ | ||
ctx, | ||
target: staker.address, | ||
params: [ctx.address], | ||
abi: abi.stakeBalanceOfv1, | ||
}) | ||
|
||
return { | ||
...staker, | ||
amount, | ||
underlyings: undefined, | ||
rewards: undefined, | ||
category: 'stake', | ||
} | ||
} | ||
|
||
export async function getCLYv2StakeBalances(ctx: BalancesContext, staker: Contract): Promise<Balance> { | ||
const amount = await call({ | ||
ctx, | ||
target: staker.address, | ||
params: [ctx.address], | ||
abi: abi.stakeBalanceOfv2, | ||
}) | ||
|
||
return { | ||
...staker, | ||
amount, | ||
underlyings: undefined, | ||
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,33 @@ | ||
import { getCLYv1StakeBalances, getCLYv2StakeBalances } from '@adapters/colony/avalanche/balance' | ||
import type { Contract, GetBalancesHandler } from '@lib/adapter' | ||
import { resolveBalances } from '@lib/balance' | ||
|
||
const CLY_v1: Contract = { | ||
chain: 'avalanche', | ||
address: '0x5b0d74c78f2588b3c5c49857edb856cc731dc557', | ||
token: '0xec3492a2508ddf4fdc0cd76f31f340b30d1793e6', | ||
} | ||
|
||
const CLY_v2: Contract = { | ||
chain: 'avalanche', | ||
address: '0x7ccda6e26dced1ba275c67cd20235790ed615a8d', | ||
token: '0xec3492a2508ddf4fdc0cd76f31f340b30d1793e6', | ||
version: 2, | ||
} | ||
|
||
export const getContracts = () => { | ||
return { | ||
contracts: { CLY_v1, CLY_v2 }, | ||
} | ||
} | ||
|
||
export const getBalances: GetBalancesHandler<typeof getContracts> = async (ctx, contracts) => { | ||
const balances = await resolveBalances<typeof getContracts>(ctx, contracts, { | ||
CLY_v1: getCLYv1StakeBalances, | ||
CLY_v2: getCLYv2StakeBalances, | ||
}) | ||
|
||
return { | ||
groups: [{ balances }], | ||
} | ||
} |
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 avalanche from './avalanche' | ||
|
||
const adapter: Adapter = { | ||
id: 'colony', | ||
avalanche, | ||
} | ||
|
||
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