Skip to content

Commit

Permalink
feat: colony (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpeluche authored Aug 16, 2023
1 parent 29cdd25 commit e7aba23
Show file tree
Hide file tree
Showing 5 changed files with 99 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 @@ -112,6 +112,7 @@
"charm-finance",
"coinbase-wrapped-staked-eth",
"coinwind",
"colony",
"compound",
"compound-v3",
"concentrator",
Expand Down
53 changes: 53 additions & 0 deletions src/adapters/colony/avalanche/balance.ts
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',
}
}
33 changes: 33 additions & 0 deletions src/adapters/colony/avalanche/index.ts
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 }],
}
}
10 changes: 10 additions & 0 deletions src/adapters/colony/index.ts
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
2 changes: 2 additions & 0 deletions src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import chainlink from '@adapters/chainlink'
import charmFinance from '@adapters/charm-finance'
import coinbaseWrappedStakedEth from '@adapters/coinbase-wrapped-staked-eth'
import coinwind from '@adapters/coinwind'
import colony from '@adapters/colony'
import compound from '@adapters/compound'
import compoundV3 from '@adapters/compound-v3'
import concentrator from '@adapters/concentrator'
Expand Down Expand Up @@ -274,6 +275,7 @@ export const adapters: Adapter[] = [
charmFinance,
coinbaseWrappedStakedEth,
coinwind,
colony,
compound,
compoundV3,
concentrator,
Expand Down

0 comments on commit e7aba23

Please sign in to comment.