-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config check script, stone vaults and manta chain
- Loading branch information
Showing
15 changed files
with
661 additions
and
466 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 |
---|---|---|
|
@@ -8,5 +8,7 @@ node_modules | |
|
||
subgraph.yaml | ||
src/config.ts | ||
random.json | ||
src/random.ts | ||
|
||
tests/.latest.json |
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,49 @@ | ||
import { VaultConfig, _getChainVaults } from "../src/vault-config" | ||
|
||
const checkConfig = async () => { | ||
// fetch vault config from https://api.beefy.com/vaults | ||
|
||
type ApiVault = { | ||
id: string | ||
earnContractAddress: string | ||
earningPoints?: boolean | ||
} | ||
|
||
const apiVaults: ApiVault[] = await fetch("https://api.beefy.finance/vaults").then((res) => res.json()) | ||
const configVaults = _getChainVaults("all") | ||
|
||
const configVaultsByAddress = configVaults.reduce( | ||
(acc, v) => { | ||
acc[v.address.toLocaleLowerCase()] = v | ||
return acc | ||
}, | ||
{} as Record<string, VaultConfig>, | ||
) | ||
|
||
const configVaultById = configVaults.reduce( | ||
(acc, v) => { | ||
acc[v.vaultKey] = v | ||
return acc | ||
}, | ||
{} as Record<string, VaultConfig>, | ||
) | ||
|
||
const apiVaultsEarningPoints = apiVaults.filter((v) => v.earningPoints) | ||
|
||
for (const apiVault of apiVaultsEarningPoints) { | ||
const configVaultFoundById = configVaultById[apiVault.id] | ||
const configVaultFoundByAddress = configVaultsByAddress[apiVault.earnContractAddress.toLocaleLowerCase()] | ||
|
||
if (!configVaultFoundByAddress) { | ||
console.log(`Vault ${apiVault.id} not found in config by address: ${apiVault.earnContractAddress}`) | ||
} else if (!configVaultFoundById) { | ||
console.log( | ||
`Vault with address ${apiVault.earnContractAddress} has incorrect id ${configVaultFoundByAddress.vaultKey} instead of ${apiVault.id}`, | ||
) | ||
} else { | ||
// OK | ||
} | ||
} | ||
} | ||
|
||
checkConfig() |
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,10 @@ | ||
{ | ||
"network": "manta-pacific-mainnet", | ||
"indexerHintPrune": 700000, | ||
"shareTokenMintAddress": "0x0000000000000000000000000000000000000000", | ||
"bindConfigAddress": "0xfc69704cC3cAac545cC7577009Ea4AA04F1a61Eb", | ||
"bindConfigBlock": 2501033, | ||
"bindConfigEvent": "ProxyCreated(address)", | ||
"vaultInitializedEvent": "Initialized(uint8)", | ||
"clockTickBlocks": 50 | ||
} |
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
"test": "yarn run --silent test:lint && yarn run --silent test:unit", | ||
"test:unit": "graph test", | ||
"test:lint": "prettier . --check", | ||
"check-config": "ts-node --project tsconfig.scripts.json ./bin/check-config.ts", | ||
"infra:start": "docker compose up -d", | ||
"infra:stop": "docker compose down", | ||
"create-local": "graph create beefyfinance/lrt --node http://127.0.0.1:8020", | ||
|
@@ -19,6 +20,7 @@ | |
"prepare:bsc": "./bin/prepare.sh bsc", | ||
"prepare:ethereum": "./bin/prepare.sh ethereum", | ||
"prepare:linea": "./bin/prepare.sh linea", | ||
"prepare:manta": "./bin/prepare.sh manta", | ||
"prepare:mode": "./bin/prepare.sh mode", | ||
"prepare:optimism": "./bin/prepare.sh optimism", | ||
"prepare:kava": "./bin/prepare.sh kava" | ||
|
@@ -44,4 +46,4 @@ | |
"*.--check": "prettier --write" | ||
}, | ||
"packageManager": "[email protected]" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { Address } from "@graphprotocol/graph-ts" | ||
|
||
export const NETWORK_NAME = "{{network}}" | ||
export const SHARE_TOKEN_MINT_ADDRESS = Address.fromString("{{shareTokenMintAddress}}") | ||
export const SHARE_TOKEN_MINT_ADDRESS = Address.fromString("{{shareTokenMintAddress}}") |
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,2 @@ | ||
// force the subgraph has to be different to make sure we don't fail on redeploy | ||
export const RANDOM = "{{random}}" |
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,101 @@ | ||
import { Address, DataSourceContext, log, dataSource } from "@graphprotocol/graph-ts" | ||
import { NETWORK_NAME } from "./config" | ||
import { VaultConfig, _getChainVaults } from "./vault-config" | ||
import { RANDOM } from "./random" | ||
|
||
export const PLATFORM_AAVE = "AAVE" | ||
export const PLATFORM_BALANCER_AURA = "BALANCER_AURA" | ||
export const PLATFORM_CURVE = "CURVE" | ||
export const PLATFORM_GAMMA = "GAMMA" | ||
export const PLATFORM_ICHI_LYNEX = "ICHI_LYNEX" | ||
export const PLATFORM_LYNEX = "LYNEX" | ||
export const PLATFORM_MENDI_LENDING = "MENDI_LENDING" | ||
export const PLATFORM_MENDI_LEVERAGE = "MENDI_LEVERAGE" | ||
export const PLATFORM_NILE = "NILE" | ||
export const PLATFORM_PENDLE_EQUILIBRIA = "PENDLE_EQUILIBRIA" | ||
export const PLATFORM_SOLIDLY = "SOLIDLY" | ||
export const PLATFORM_BEEFY_CLM = "BEEFY_CLM" | ||
export const TRACK_ONLY_SHARE_TOKEN_BALANCE = "TRACK_ONLY_SHARE_TOKEN_BALANCE" | ||
export const TRACK_ONLY_SHARE_AND_UNDERLYING_TOKEN_BALANCE = "TRACK_ONLY_SHARE_AND_UNDERLYING_TOKEN_BALANCE" | ||
|
||
export function getChainVaults(): Array<VaultConfigAsm> { | ||
const network = NETWORK_NAME as string | ||
log.debug("getChainVaults: network={} rng={}", [network, RANDOM]) | ||
|
||
const configs = _getChainVaults(network) | ||
|
||
const vaults = new Array<VaultConfigAsm>() | ||
for (let i = 0; i < configs.length; i++) { | ||
vaults.push(new VaultConfigAsm(configs[i])) | ||
} | ||
|
||
return vaults | ||
} | ||
|
||
export function isBoostAddress(address: Address): boolean { | ||
const vaults = getChainVaults() | ||
for (let i = 0; i < vaults.length; i++) { | ||
for (let j = 0; j < vaults[i].boostAddresses.length; j++) { | ||
if (vaults[i].boostAddresses[j].equals(address)) { | ||
return true | ||
} | ||
} | ||
} | ||
|
||
return false | ||
} | ||
export function isRewardPoolAddress(address: Address): boolean { | ||
const vaults = getChainVaults() | ||
for (let i = 0; i < vaults.length; i++) { | ||
for (let j = 0; j < vaults[i].rewardPoolsAddresses.length; j++) { | ||
if (vaults[i].rewardPoolsAddresses[j].equals(address)) { | ||
return true | ||
} | ||
} | ||
} | ||
|
||
return false | ||
} | ||
|
||
const CONTEXT_KEY_UNDERLYING_PLATFORM = "underlyingPlatform" | ||
const CONTEXT_KEY_VAULT_KEY = "vaultKey" | ||
|
||
export function buildVaultDataSourceContext(vault: VaultConfigAsm): DataSourceContext { | ||
let context = new DataSourceContext() | ||
context.setString(CONTEXT_KEY_UNDERLYING_PLATFORM, vault.underlyingPlatform) | ||
context.setString(CONTEXT_KEY_VAULT_KEY, vault.vaultKey) | ||
return context | ||
} | ||
|
||
export function getContextUnderlyingPlatform(): string { | ||
let context = dataSource.context() | ||
return context.getString(CONTEXT_KEY_UNDERLYING_PLATFORM) | ||
} | ||
|
||
export function getContextVaultKey(): string { | ||
let context = dataSource.context() | ||
return context.getString(CONTEXT_KEY_VAULT_KEY) | ||
} | ||
|
||
class VaultConfigAsm { | ||
public vaultKey: string | ||
public underlyingPlatform: string | ||
public address: Address | ||
public boostAddresses: Array<Address> | ||
public rewardPoolsAddresses: Array<Address> | ||
|
||
constructor(config: VaultConfig) { | ||
this.vaultKey = config.vaultKey | ||
this.underlyingPlatform = config.underlyingPlatform | ||
this.address = Address.fromString(config.address) | ||
this.boostAddresses = new Array<Address>() | ||
this.rewardPoolsAddresses = new Array<Address>() | ||
|
||
for (let i = 0; i < config.rewardPoolsAddresses.length; i++) { | ||
this.rewardPoolsAddresses.push(Address.fromString(config.rewardPoolsAddresses[i])) | ||
} | ||
for (let i = 0; i < config.boostAddresses.length; i++) { | ||
this.boostAddresses.push(Address.fromString(config.boostAddresses[i])) | ||
} | ||
} | ||
} |
Oops, something went wrong.