Skip to content

Commit

Permalink
Merge pull request #9015 from DefiLlama/eclipse-patch
Browse files Browse the repository at this point in the history
sophon
  • Loading branch information
waynebruce0x authored Jan 9, 2025
2 parents 2d3d9f8 + bb2e648 commit 83502c7
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 40 deletions.
64 changes: 33 additions & 31 deletions coins/src/adapters/bridges/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import fuel from "./fuel";
import zircuit from "./zircuit";
import morph from "./morph";
import aptos from "./aptosFa";
import sophon from './sophon';

export type Token =
| {
Expand Down Expand Up @@ -77,37 +78,38 @@ function normalizeBridgeResults(bridge: Bridge) {
};
}
export const bridges = [
optimism,
// anyswap,
arbitrum,
avax,
// brc20,
//bsc,
fantom,
era,
gasTokens,
//harmony,
polygon,
// solana
//xdai
cosmos,
synapse,
base,
neon_evm,
arbitrum_nova,
mantle,
axelar,
linea,
manta,
astrzk,
zklink,
celer,
fraxtal,
symbiosis,
fuel,
zircuit,
morph,
aptos,
// optimism,
// // anyswap,
// arbitrum,
// avax,
// // brc20,
// //bsc,
// fantom,
// era,
// gasTokens,
// //harmony,
// polygon,
// // solana
// //xdai
// cosmos,
// synapse,
// base,
// neon_evm,
// arbitrum_nova,
// mantle,
// axelar,
// linea,
// manta,
// astrzk,
// zklink,
// celer,
// fraxtal,
// symbiosis,
// fuel,
// zircuit,
// morph,
// aptos,
sophon
].map(normalizeBridgeResults) as Bridge[];

import { batchGet, batchWrite } from "../../utils/shared/dynamodb";
Expand Down
40 changes: 40 additions & 0 deletions coins/src/adapters/bridges/sophon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import fetch from "node-fetch";
import { multiCall } from "@defillama/sdk/build/abi/abi2";
import { Token } from "./index";
import { nullAddress } from "../../utils/shared/constants";

const chain = "sophon";

export default async function (): Promise<Token[]> {
const {
data: { items },
} = await fetch(
`https://api.covalenthq.com/v1/1/address/0xD7f9f54194C633F36CCD5F3da84ad4a1c38cB2cB/balances_v2/?&key=${process.env.COVALENT_KEY}`,
).then((r) => r.json());

let l1Assets: Token[] = items.map((i: any) => ({
to: `ethereum:${i.contract_address}`,
decimals: i.contract_decimals,
symbol: i.contract_ticker_symbol,
}));

const l2Assets = await multiCall({
calls: l1Assets.map(({ to }) => ({
target: "0x954ba8223a6BFEC1Cc3867139243A02BA0Bc66e4",
params: to.substring(to.indexOf(":") + 1),
})),
abi: "function l2TokenAddress(address _l1Token) external view returns (address)",
chain,
permitFailure: true,
});

l2Assets.map((a: any, i: number) => {
if (a == nullAddress) {
l1Assets.splice(i, 1);
return;
}
l1Assets[i].from = `sophon:${a}`;
});

return l1Assets;
}
2 changes: 1 addition & 1 deletion coins/src/adapters/markets/balancer/balancer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import abi from "./abi.json";
import { getTokenInfo } from "../../utils/erc20";
import { Result } from "../../utils/sdkInterfaces";
import { DbTokenInfos } from "../../utils/dbInterfaces";
import { nullAddress } from "../../../utils/shared/constants";

const vault: string = "0xBA12222222228d8Ba445958a75a0704d566BF2C8";
const nullAddress: string = "0x0000000000000000000000000000000000000000";
const subgraphNames: { [chain: string]: string } = {
ethereum: sdk.graph.modifyEndpoint("C4ayEZP2yTXRAB8vSaTrgN4m9anTe9Mdm2ViyiAuV9TV",),
xdai: sdk.graph.modifyEndpoint("EJezH1Cp31QkKPaBDerhVPRWsKVZLrDfzjrLqpmv6cGg",),
Expand Down
2 changes: 1 addition & 1 deletion coins/src/adapters/markets/balancer/balancerV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { getApi } from "../../utils/sdk";
import { getPoolValues } from "../../utils";
import getWrites from "../../utils/getWrites";
import { getLogs } from "../../../utils/cache/getLogs";
import { nullAddress } from "../../../utils/shared/constants";

const vault: string = "0xBA12222222228d8Ba445958a75a0704d566BF2C8";
const nullAddress: string = "0x0000000000000000000000000000000000000000";

const gaugeFactories: { [chain: string]: string } = {
ethereum: "0x4e7bbd911cf1efa442bc1b2e9ea01ffe785412ec",
Expand Down
3 changes: 1 addition & 2 deletions coins/src/adapters/markets/curve/curve2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { ChainApi } from "@defillama/sdk";
import { getCache, setCache } from "../../../utils/cache";
import { PromisePool } from "@supercharge/promise-pool";
import * as sdk from '@defillama/sdk'

const nullAddress = "0x0000000000000000000000000000000000000000"
import { nullAddress } from "../../../utils/shared/constants";

async function getPools(
api: ChainApi,
Expand Down
3 changes: 1 addition & 2 deletions coins/src/adapters/markets/pancakeStable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {
} from "../utils/database";
import { Write } from "../utils/dbInterfaces";
import { getApi } from "../utils/sdk";

const nullAddress = "0x0000000000000000000000000000000000000000";
import { nullAddress } from '../../utils/shared/constants'

const factories: {
[chain: string]: {
Expand Down
2 changes: 1 addition & 1 deletion coins/src/adapters/markets/phux/phux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import abi from "./abi.json";
import { getTokenInfo } from "../../utils/erc20";
import { Result } from "../../utils/sdkInterfaces";
import { DbTokenInfos } from "../../utils/dbInterfaces";
import { nullAddress } from "../../../utils/shared/constants";

const vault: string = "0x7F51AC3df6A034273FB09BB29e383FCF655e473c";
const nullAddress: string = "0x0000000000000000000000000000000000000000";

type GqlResult = {
id: string;
Expand Down
2 changes: 1 addition & 1 deletion coins/src/adapters/other/others2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import getWrites from "../utils/getWrites";
import { getTokenSupplies, getTokenAccountBalances, } from "../solana/utils";
import { getApi } from "../utils/sdk";
import { nullAddress } from "../../utils/shared/constants";


async function solanaAVS(timestamp: number = 0) {
Expand Down Expand Up @@ -29,7 +30,6 @@ async function wstBFC(timestamp: number = 0) {
const chain = "bfc";
const api = await getApi(chain, timestamp);
const pricesObject: any = {};
const nullAddress = "0x0000000000000000000000000000000000000000";
const wstBFC = "0x386f2F5d9A97659C86f3cA9B8B11fc3F76eFDdaE";
const bal = await api.call({ abi: "erc20:balanceOf", target: '0xEff8378C6419b50C9D87f749f6852d96D4Cc5aE4', params: wstBFC, });
const supply = await api.call({ abi: "erc20:totalSupply", target: wstBFC });
Expand Down
2 changes: 1 addition & 1 deletion coins/src/adapters/yield/pendle/pendle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from "../../utils/database";
import PromisePool from "@supercharge/promise-pool";
import { wrappedGasTokens } from "../../utils/gasTokens";
import { nullAddress } from "../../../utils/shared/constants";

const customMapping: { [chain: string]: { [from: string]: string } } = {
arbitrum: {
Expand Down Expand Up @@ -73,7 +74,6 @@ const gasMapping: { [chain: string]: string[] } = {
};

const blacklist = ["0x1d83fdf6f019d0a6b2babc3c6c208224952e42fc"];
const nullAddress = "0x0000000000000000000000000000000000000000";

export default async function getTokenPrices(
timestamp: number,
Expand Down
2 changes: 2 additions & 0 deletions defi/src/utils/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export const searchWidth = DAY;
export const chainsThatShouldNotBeLowerCased = ["solana", "bitcoin", "eclipse"];

export const bridgedTvlMixedCaseChains: string[] = ["solana", "tron", "sui", "aptos", "eclipse"];

export const nullAddress = "0x0000000000000000000000000000000000000000";

0 comments on commit 83502c7

Please sign in to comment.