Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Balancer #376

Merged
merged 7 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified arb.db
Binary file not shown.
Binary file modified base.db
Binary file not shown.
Binary file modified ethereum.db
Binary file not shown.
Binary file modified matic.db
Binary file not shown.
Binary file modified op.db
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { VotingEscrow } from '../../../../core/adapters/votingEscrow'
import { NotImplementedError } from '../../../../core/errors/errors'
import {
GetPositionsInput,
PositionType,
ProtocolDetails,
} from '../../../../types/adapter'
import {
FeeDistributor__factory,
VotingEscrow__factory,
} from '../../../stargate/contracts'

export class BalancerV2VestingAdapter extends VotingEscrow {
productId = 'vesting'

getProtocolDetails(): ProtocolDetails {
return {
protocolId: this.protocolId,
name: 'BalancerV2',
description: 'BalancerV2 defi adapter',
siteUrl: '',
iconUrl: '',
positionType: PositionType.Staked,
chainId: this.chainId,
productId: this.productId,
}
}

addresses = {
veToken: '0xC128a9954e6c874eA3d62ce62B468bA073093F25',
underlyingToken: '0x5c6Ee304399DBdB9C8Ef030aB642B10820DB8F56',
rewardToken: '0xa13a9247ea42d743238089903570127dda72fe44',
feeDistributor: '0xD3cf852898b21fc233251427c2DC93d3d604F3BB',
}

async getRewardBalance({
userAddress,
blockNumber,
}: GetPositionsInput): Promise<bigint> {
const contract = FeeDistributor__factory.connect(
this.addresses.feeDistributor,
this.provider,
)

return contract.claimToken.staticCall(
userAddress,
this.addresses.rewardToken,
{ blockTag: blockNumber },
)
}

async getLockedDetails({
userAddress,
blockNumber,
}: GetPositionsInput): Promise<{ amount: bigint; end: bigint }> {
const votingEscrow = VotingEscrow__factory.connect(
this.addresses.veToken,
this.provider,
)

const [amount, end] = await votingEscrow.locked(userAddress, {
blockTag: blockNumber,
})

return { amount, end }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"blockNumber": 21194060,
"latency": "Latency: 1.406 seconds",
"aggregatedValues": ["USD0.00"],
"snapshot": [
{
"protocolId": "balancer-v2",
"name": "BalancerV2",
"description": "BalancerV2 defi adapter",
"siteUrl": "",
"iconUrl": "",
"positionType": "stake",
"chainId": 1,
"productId": "vesting",
"chainName": "ethereum",
"success": true,
"tokens": [
{
"type": "protocol",
"balanceRaw": "1701982822546843636967n",
"address": "0xC128a9954e6c874eA3d62ce62B468bA073093F25",
"symbol": "veBAL",
"name": "Vote Escrowed Balancer BPT - Unlock time 06/11/2025",
"decimals": 18,
"tokens": [
{
"address": "0x5c6Ee304399DBdB9C8Ef030aB642B10820DB8F56",
"name": "Balancer 80 BAL 20 WETH",
"symbol": "B-80BAL-20WETH",
"decimals": 18,
"type": "underlying",
"balanceRaw": "1701982822546843636967n",
"balance": 1701.9828225468436,
"iconUrl": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x5c6Ee304399DBdB9C8Ef030aB642B10820DB8F56/logo.png"
},
{
"address": "0xA13a9247ea42D743238089903570127DdA72fE44",
"name": "Balancer Aave Boosted StablePool",
"symbol": "bb-a-USD",
"decimals": 18,
"balanceRaw": "38777247945780920724n",
"type": "underlying-claimable",
"balance": 38.77724794578092,
"iconUrl": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA13a9247ea42D743238089903570127DdA72fE44/logo.png"
}
],
"balance": 1701.9828225468436
}
]
}
],
"rpcResponses": {
"a8ba6f41343842b48531f8605a78eaed": {
"result": "0x00000000000000000000000000000000000000000000005c43c1a79d695014e700000000000000000000000000000000000000000000000000000000690be500"
},
"bf6836bbd7b90f8f17a9d3c202ae8672": {
"result": "0x0000000000000000000000000000000000000000000000021a24758e57848194"
},
"c6443e715cde299579704a591e917756": {
"result": "0x000000000000000000000000000000000000000000000007000000000000091b000000000000000000000000000000000000000000000000000000468eb5f48000000000000000000000000000000000000000000000000000000000673766e100000000000000000000000000000000000000000000000000000000673766f3000000000000000000000000000000000000000000000007000000000000091b"
},
"66d35b4400a89c2cfef0d0d7d3a4aaf0": {
"result": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
"2b4dbedeed86ea18cd4013d4b65e9ce5": {
"result": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"blockNumber": 21194060,
"latency": "Latency: 1.553 seconds",
"aggregatedValues": ["USD0.00"],
"snapshot": [
{
"protocolId": "balancer-v2",
"name": "BalancerV2",
"description": "BalancerV2 defi adapter",
"siteUrl": "",
"iconUrl": "",
"positionType": "stake",
"chainId": 1,
"productId": "vesting",
"chainName": "ethereum",
"success": true,
"tokens": [
{
"type": "protocol",
"balanceRaw": "20041064328708344065n",
"address": "0xC128a9954e6c874eA3d62ce62B468bA073093F25",
"symbol": "veBAL",
"name": "Vote Escrowed Balancer BPT - Unlock time 19/06/2025",
"decimals": 18,
"tokens": [
{
"address": "0x5c6Ee304399DBdB9C8Ef030aB642B10820DB8F56",
"name": "Balancer 80 BAL 20 WETH",
"symbol": "B-80BAL-20WETH",
"decimals": 18,
"type": "underlying",
"balanceRaw": "20041064328708344065n",
"balance": 20.041064328708345,
"iconUrl": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x5c6Ee304399DBdB9C8Ef030aB642B10820DB8F56/logo.png"
}
],
"balance": 20.041064328708345
}
]
}
],
"rpcResponses": {
"98221183723d41ecda5fc6e317dbdf39": {
"result": "0x000000000000000000000000000000000000000000000001162029d32969c9010000000000000000000000000000000000000000000000000000000068535300"
},
"f650ec4156b455b0389ef7ed03c3c305": {
"result": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
"c6443e715cde299579704a591e917756": {
"result": "0x000000000000000000000000000000000000000000000007000000000000091b000000000000000000000000000000000000000000000000000000468eb5f48000000000000000000000000000000000000000000000000000000000673766e100000000000000000000000000000000000000000000000000000000673766f3000000000000000000000000000000000000000000000007000000000000091b"
},
"66d35b4400a89c2cfef0d0d7d3a4aaf0": {
"result": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Chain } from '../../../../../core/constants/chains'
import { TimePeriod } from '../../../../../core/constants/timePeriod'
import type { TestCase } from '../../../../../types/testCase'

export const testCases: TestCase[] = [
{
chainId: Chain.Ethereum,
method: 'positions',
input: {
userAddress: '0x278a8453ECf2f477a5Ab3Cd9b0Ea410b7B2C4182',
filterProtocolTokens: ['0xC128a9954e6c874eA3d62ce62B468bA073093F25'],
},
blockNumber: 21194060,
},
{
chainId: Chain.Ethereum,
method: 'positions',
key: '2',
input: {
userAddress: '0x891ca7e61d3868B9eDbF20dDd045Fc7D579E77d5',
filterProtocolTokens: ['0xC128a9954e6c874eA3d62ce62B468bA073093F25'],
},
blockNumber: 21194060,
},
]
Loading