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

feat: cleanup contract address #961

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ tests/local
.env.development
bun.lockb

test/addresses.json
test/coverage/*
test/reports
test/fixtures/*.json
Expand All @@ -58,4 +59,4 @@ docs/swagger/*.json
docs/swagger/*.html

_
swagger.json
swagger.json
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
"tonpound",
"tornado-cash",
"tprotocol",
"traderjoe",
"trader-joe",
"truefi",
"trufin-protocol",
"trustswap",
Expand All @@ -312,7 +312,7 @@
"unsheth",
"uwu-lend",
"valas-finance",
"vector",
"vector-finance",
"velodrome-v1",
"velodrome-v2",
"venus",
Expand Down
10 changes: 5 additions & 5 deletions src/adapters/alchemix/fantom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ const USDT: Token = {

const daiTransmuter: Contract = {
chain: 'fantom',
address: '0x486FCC9385dCd16fE9ac21a959B072dcB58912e0',
address: '0x486fcc9385dcd16fe9ac21a959b072dcb58912e0',
underlyings: [DAI],
}

const usdcTransmuter: Contract = {
chain: 'fantom',
address: '0xaE653176d1AF6A68B5ce57481427a065E1baC49f',
address: '0xae653176d1af6a68b5ce57481427a065e1bac49f',
underlyings: [USDC],
}

const usdtTransmuter: Contract = {
chain: 'fantom',
address: '0x53F05426D48E667c6a131F17db1b6f7AC535aBC6',
address: '0x53f05426d48e667c6a131f17db1b6f7ac535abc6',
underlyings: [USDT],
}

Expand Down Expand Up @@ -69,7 +69,7 @@ const alUSD: Token = {

const alUSDtransmuter: Contract = {
chain: 'fantom',
address: '0x76b2E3c5a183970AAAD2A48cF6Ae79E3e16D3A0E',
address: '0x76b2e3c5a183970aaad2a48cf6ae79e3e16d3a0e',
underlyings: [alUSD],
}

Expand All @@ -79,7 +79,7 @@ const transmutersV2 = [alUSDtransmuter]

export const getContracts = () => {
return {
contracts: { transmutersV2, reactivesV2 },
contracts: { transmutersV2 },
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/adapters/alpaca-finance/bsc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getPoolsContracts } from './pools'
const fairLaunch: Contract = {
name: 'fairlaunchContractAddress',
chain: 'bsc',
address: '0xA625AB01B08ce023B2a342Dbb12a16f2C8489A8F',
address: '0xa625ab01b08ce023b2a342dbb12a16f2c8489a8f',
}

const ALPACA: Contract = {
Expand Down
14 changes: 5 additions & 9 deletions src/adapters/alpaca-finance/bsc/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ const abi = {
export async function getPoolsContracts(ctx: BaseContext, fairLaunch: Contract) {
const contracts: Contract[] = []

const poolsLength = await call({
ctx,
target: fairLaunch.address,
abi: abi.poolLength,
})
const poolsLength = await call({ ctx, target: fairLaunch.address, abi: abi.poolLength })

const poolsInfoRes = await multicall({
ctx,
Expand All @@ -64,18 +60,18 @@ export async function getPoolsContracts(ctx: BaseContext, fairLaunch: Contract)

const underlyingsAddressesRes = await multicall({
ctx,
calls: poolsAddresses.map((token) => ({
target: token,
})),
calls: poolsAddresses.map((token) => ({ target: token })),
abi: abi.token,
})

for (let poolIdx = 0; poolIdx < poolsAddresses.length; poolIdx++) {
const underlyingRes = underlyingsAddressesRes[poolIdx]

contracts.push({
name: fairLaunch.name,
chain: ctx.chain,
address: poolsAddresses[poolIdx],
address: fairLaunch.address,
token: poolsAddresses[poolIdx],
pid: poolIdx,
underlyings: underlyingRes.success ? [underlyingRes.output] : undefined,
})
Expand Down
6 changes: 2 additions & 4 deletions src/adapters/alpaca-finance/common/balances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ export async function getPoolsBalances(
params: [pool.pid, ctx.address],
}))

const supplyCalls: Call<typeof abi.totalSupply>[] = pools.map((pool) => ({
target: pool.address,
}))
const supplyCalls: Call<typeof abi.totalSupply>[] = pools.map((pool) => ({ target: pool.token! }))

const balanceOfCalls: Call<typeof erc20Abi.balanceOf>[] = pools.map((pool) => ({
target: pool.address,
target: pool.token!,
params: [ctx.address],
}))

Expand Down
6 changes: 3 additions & 3 deletions src/adapters/aura/common/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export async function getAuraBalancesInternal(
}),
multicall({
ctx,
calls: fmtPools.map((pool) => ({ target: pool.address }) as const),
calls: fmtPools.map((pool) => ({ target: pool.token }) as const),
abi: erc20Abi.totalSupply,
}),
])
Expand Down Expand Up @@ -210,7 +210,7 @@ export async function getAuraBalancesInternal(
})

const lpTokenBalance = underlyings.find(
(underlying) => underlying.address.toLowerCase() === pool.address.toLowerCase(),
(underlying) => underlying.address.toLowerCase() === pool.token!.toLowerCase(),
)

const fmtUnderlyings = underlyings
Expand All @@ -223,7 +223,7 @@ export async function getAuraBalancesInternal(
amount,
}
})
.filter((underlying) => underlying.address.toLowerCase() !== pool.address.toLowerCase())
.filter((underlying) => underlying.address.toLowerCase() !== pool.token!.toLowerCase())

balances.push({ ...pool, amount: poolBalanceRes.output, underlyings: fmtUnderlyings, rewards, category: 'farm' })
}
Expand Down
11 changes: 5 additions & 6 deletions src/adapters/aura/common/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ export async function getAuraPools(ctx: BaseContext, booster: Contract, vault: C

return {
chain: ctx.chain,
address: lptoken,
pool: lptoken,
lpToken: lptoken,
address: booster.address,
token: lptoken,
gauge: [crvRewards],
rewards: [BAL],
}
Expand All @@ -139,7 +138,7 @@ export async function getAuraPools(ctx: BaseContext, booster: Contract, vault: C
const getAuraPoolsId = async (ctx: BaseContext, pools: Contract[], vault: Contract): Promise<Contract[]> => {
const poolIdsRes = await multicall({
ctx,
calls: pools.map((pool) => ({ target: pool.address })),
calls: pools.map((pool) => ({ target: pool.token! })),
abi: abi.getPoolId,
})

Expand Down Expand Up @@ -173,15 +172,15 @@ const getAuraPoolsUnderlyings = async (ctx: BaseContext, pools: Contract[], vaul
const unwrapPoolsAsUnderlyings = (pools: Contract[]) => {
const unwrappedPools: Contract[] = []

const poolByAddress = keyBy(pools, 'address', { lowercase: true })
const poolByToken = keyBy(pools, 'token', { lowercase: true })

for (const pool of pools) {
const underlyings = pool.underlyings as Contract[]
if (!underlyings) {
continue
}

const unwrappedUnderlyings = underlyings.map((address) => poolByAddress[address.toLowerCase()] || address)
const unwrappedUnderlyings = underlyings.map((address) => poolByToken[address.toLowerCase()] || address)

unwrappedPools.push({
...pool,
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/aura/optimism/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { resolveBalances } from '@lib/balance'

const booster: Contract = {
chain: 'optimism',
address: '0x98Ef32edd24e2c92525E59afc4475C1242a30184',
address: '0x98ef32edd24e2c92525e59afc4475c1242a30184',
}

const vaultBAL: Contract = {
Expand Down
3 changes: 3 additions & 0 deletions src/adapters/belt-finance/bsc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@
}

const masterChef: Contract = {
name: 'MasterBelt',
chain: 'bsc',
address: '0xd4bbc80b9b102b77b21a06cb77e954049605e6c1',
}

const deployers = ['0x7111d0f651a331bc2b9eefcfe56d8a03f92601a1']

Check warning on line 50 in src/adapters/belt-finance/bsc/index.ts

View workflow job for this annotation

GitHub Actions / Lint, Build, Test (lts/*, latest, ubuntu-latest)

'deployers' is assigned a value but never used. Allowed unused vars must match /^_/u

export const getContracts = async (ctx: BaseContext) => {
const pools = await getBeltContracts(ctx, masterChef, [fourBelt, fourBeltV2])

Expand Down
6 changes: 3 additions & 3 deletions src/adapters/compound-v3/base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ const WETH: Token = {

const cUSDbCv3: Contract = {
chain: 'base',
address: '0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf',
address: '0x9c4ec768c28520b50860ea7a15bd7213a9ff58bf',
underlyings: [USDbC],
}

const cWETHv3: Contract = {
chain: 'base',
address: '0x46e6b214b524310239732D51387075E0e70970bf',
address: '0x46e6b214b524310239732d51387075e0e70970bf',
underlyings: [WETH],
}

const rewarder: Contract = {
chain: 'base',
address: '0x123964802e6ABabBE1Bc9547D72Ef1B69B00A6b1',
address: '0x123964802e6ababbe1bc9547d72ef1b69b00a6b1',
}

export const getContracts = async (ctx: BaseContext) => {
Expand Down
7 changes: 3 additions & 4 deletions src/adapters/compound-v3/common/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,16 @@ export async function getAssetsContracts(ctx: BaseContext, compounders: Contract

const assetsInfoRes = await multicall({
ctx,
//@ts-expect-error
calls: mapSuccessFilter(numberOfAssets, (responses) =>
range(0, responses.output).map((res) => ({ target: responses.input.target, params: [res] })),
range(0, responses.output).map((res) => ({ target: responses.input.target, params: [res] }) as const),
).flat(),
abi: abi.getAssetInfo,
})

return mapSuccessFilter(assetsInfoRes, (res) => ({
chain: ctx.chain,
address: res.output.asset,
compounder: res.input.target,
address: res.input.target,
token: res.output.asset,
collateralFactor: res.output.borrowCollateralFactor,
}))
}
10 changes: 5 additions & 5 deletions src/adapters/compound-v3/common/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ const abi = {
} as const

const COMP: { [key: string]: `0x${string}` } = {
arbitrum: '0x354A6dA3fcde098F8389cad84b0182725c6C91dE',
base: '0x9e1028F5F1D5eDE59748FFceE5532509976840E0',
arbitrum: '0x354a6da3fcde098f8389cad84b0182725c6c91de',
base: '0x9e1028f5f1d5ede59748ffcee5532509976840e0',
ethereum: '0xc00e94cb662c3520282e6f5717214004a7f26888',
polygon: '0x8505b9d2254A7Ae468c0E9dd10Ccea3A837aef5c',
polygon: '0x8505b9d2254a7ae468c0e9dd10ccea3a837aef5c',
}

export async function getCompLendBalances(
Expand All @@ -61,7 +61,7 @@ export async function getCompLendBalances(
const [userLendBalances, userBorrowBalances] = await Promise.all([
multicall({
ctx,
calls: assets.map((asset) => ({ target: asset.compounder, params: [ctx.address, asset.address] }) as const),
calls: assets.map((asset) => ({ target: asset.address, params: [ctx.address, asset.token!] }) as const),
abi: abi.userCollateral,
}),
multicall({
Expand All @@ -78,7 +78,7 @@ export async function getCompLendBalances(
chain: ctx.chain,
decimals: assets[index].decimals,
symbol: assets[index].symbol,
address: assets[index].address,
address: assets[index].token!,
amount: balance,
collateralFactor: assets[index].collateralFactor,
category: 'lend',
Expand Down
8 changes: 4 additions & 4 deletions src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ import tokenlon from '@adapters/tokenlon'
import tonpound from '@adapters/tonpound'
import tornadoCash from '@adapters/tornado-cash'
import tprotocol from '@adapters/tprotocol'
import traderjoe from '@adapters/traderjoe'
import traderJoe from '@adapters/trader-joe'
import truefi from '@adapters/truefi'
import trufinProtocol from '@adapters/trufin-protocol'
import trustswap from '@adapters/trustswap'
Expand All @@ -239,7 +239,7 @@ import uniswapV3 from '@adapters/uniswap-v3'
import unsheth from '@adapters/unsheth'
import uwuLend from '@adapters/uwu-lend'
import valasFinance from '@adapters/valas-finance'
import vector from '@adapters/vector'
import vectorFinance from '@adapters/vector-finance'
import velodromeV1 from '@adapters/velodrome-v1'
import velodromeV2 from '@adapters/velodrome-v2'
import venus from '@adapters/venus'
Expand Down Expand Up @@ -491,7 +491,7 @@ export const adapters: Adapter[] = [
tonpound,
tornadoCash,
tprotocol,
traderjoe,
traderJoe,
truefi,
trufinProtocol,
trustswap,
Expand All @@ -500,7 +500,7 @@ export const adapters: Adapter[] = [
unsheth,
uwuLend,
valasFinance,
vector,
vectorFinance,
velodromeV1,
velodromeV2,
venus,
Expand Down
25 changes: 14 additions & 11 deletions src/adapters/magpie/bsc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { resolveBalances } from '@lib/balance'

const masterChef: Contract = {
name: 'MasterMagpie',
chain: 'bsc',
address: '0xa3b615667cbd33cfc69843bf11fbb2a1d926bd46',
rewards: ['0xd06716e1ff2e492cc5034c2e81805562dd3b45fa'],
Expand All @@ -12,21 +13,23 @@
const MGPContract: Contract = {
chain: 'bsc',
address: '0x9b69b06272980fa6bad9d88680a71e3c3beb32c6',
staker: '0x94Eb0E6800F10E22550e104EC04f98F043B6b3ad',
underlyings: ['0xD06716E1Ff2E492Cc5034c2E81805562dd3b45fa'],
staker: '0x94eb0e6800f10e22550e104ec04f98f043b6b3ad',
underlyings: ['0xd06716e1ff2e492cc5034c2e81805562dd3b45fa'],
rewards: [
'0xD06716E1Ff2E492Cc5034c2E81805562dd3b45fa',
'0xAD6742A35fB341A9Cc6ad674738Dd8da98b94Fb1',
'0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
'0x3BC5AC0dFdC871B365d159f728dd1B9A0B5481E8',
'0xf307910A4c7bbc79691fD374889b36d8531B08e3',
'0x4C882ec256823eE773B25b414d36F92ef58a7c0C',
'0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56',
'0x0782b6d8c4551B9760e74c0545a9bCD90bdc41E5',
'0x027a9d301FB747cd972CFB29A63f3BDA551DFc5c',
'0xd06716e1ff2e492cc5034c2e81805562dd3b45fa',
'0xad6742a35fb341a9cc6ad674738dd8da98b94fb1',
'0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c',
'0x3bc5ac0dfdc871b365d159f728dd1b9a0b5481e8',
'0xf307910a4c7bbc79691fd374889b36d8531b08e3',
'0x4c882ec256823ee773b25b414d36f92ef58a7c0c',
'0xe9e7cea3dedca5984780bafc599bd69add087d56',
'0x0782b6d8c4551b9760e74c0545a9bcd90bdc41e5',
'0x027a9d301fb747cd972cfb29a63f3bda551dfc5c',
],
}

const deployers = ['0x0cdb34e6a4d635142bb92fe403d38f636bbb77b8']

Check warning on line 31 in src/adapters/magpie/bsc/index.ts

View workflow job for this annotation

GitHub Actions / Lint, Build, Test (lts/*, latest, ubuntu-latest)

'deployers' is assigned a value but never used. Allowed unused vars must match /^_/u

export const getContracts = async (ctx: BaseContext) => {
const pools = await getMagpieContracts(ctx, masterChef)

Expand Down
10 changes: 6 additions & 4 deletions src/adapters/magpie/common/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,17 @@ export async function getMagpieBalances(
const [userBalancesRes, pendingRewardsRes] = await Promise.all([
multicall({
ctx,
calls: pools.map((pool) =>
pool.staker ? ({ target: masterchef.address, params: [pool.staker, ctx.address] } as const) : null,
calls: pools.map(
(pool) =>
({ target: masterchef.address, params: [pool.staker, ctx.address], enabled: pool.staker != null }) as const,
),
abi: abi.stakingInfo,
}),
multicall({
ctx,
calls: pools.map((pool) =>
pool.staker ? ({ target: masterchef.address, params: [pool.staker, ctx.address] } as const) : null,
calls: pools.map(
(pool) =>
({ target: masterchef.address, params: [pool.staker, ctx.address], enabled: pool.staker != null }) as const,
),
abi: abi.allPendingTokens,
}),
Expand Down
Loading
Loading