-
Notifications
You must be signed in to change notification settings - Fork 813
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9015 from DefiLlama/eclipse-patch
sophon
- Loading branch information
Showing
10 changed files
with
82 additions
and
40 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 |
---|---|---|
@@ -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; | ||
} |
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
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
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
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