Skip to content

Commit

Permalink
feat: add new abis (#372)
Browse files Browse the repository at this point in the history
* feat: add new abis

* fix: regenerate with new foundry

* fix: add exports

* fix: use pool address not name

fix: update tokenlist

fix: use proper type

fix: use proper type

fix: patch list
  • Loading branch information
sakulstra authored Feb 21, 2024
1 parent a9b0568 commit 6e89a60
Show file tree
Hide file tree
Showing 9 changed files with 2,124 additions and 423 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"generate:addresses": "tsx scripts/generateAddresses.ts && npm run prettier",
"start": "tsx scripts/generateABIs.ts &&tsx scripts/generateAddresses.ts && npm run prettier",
"build": "tsup",
"ci:publish": "npm run build && npm publish --access=public",
"ci:publish": "npm run build && cp tokenlist.json dist/tokenlist.json && npm publish --access=public",
"test": "echo 'no tests exist yet'"
},
"repository": {
Expand Down
5 changes: 5 additions & 0 deletions scripts/configs/abis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@ export const DOWNLOAD_ABI_INTERFACES = [
address: '0x366AE337897223AEa70e3EBe1862219386f20593',
name: 'IATokenWithDelegation',
},
{
address: '0x79b5e91037AE441dE0d9e6fd3Fd85b96B83d4E93',
name: 'IStaticATokenFactory',
},
{address: '0xc026f5dd7869e0ddc44a759ea3dec6d5cd8d996b', name: 'IStaticATokenLM'},
];
9 changes: 5 additions & 4 deletions scripts/generator/generateTokenList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {readFileSync, existsSync, writeFileSync} from 'fs';
import {cwd} from 'process';
import {join} from 'path';
import prettier from 'prettier';
import {Address, getContract, zeroAddress} from 'viem';
import {Address, getContract, Hex, zeroAddress} from 'viem';
import {IERC20Detailed_ABI} from '../../src/ts/abis/IERC20Detailed';
import {CHAIN_ID_CLIENT_MAP} from '@bgd-labs/js-utils';
import {fixSymbol} from './assetsLibraryGenerator';
Expand All @@ -22,6 +22,7 @@ const TAGS = {

type TokenListParams = {
name: string;
pool: Hex;
chainId: number;
reservesData: ReserveData[];
}[];
Expand All @@ -37,7 +38,7 @@ export async function generateTokenList(pools: TokenListParams) {
: {tokens: []};

const tokens: TokenInfo[] = [];
for (const {reservesData, chainId, name: poolName} of pools) {
for (const {reservesData, chainId, name: poolName, pool} of pools) {
for (const reserve of reservesData) {
async function addToken(token: Address, tags: string[], extensions?: Record<string, string>) {
const alreadyInList = findInList(tokens, token, chainId);
Expand Down Expand Up @@ -69,14 +70,14 @@ export async function generateTokenList(pools: TokenListParams) {
await addToken(
reserve.A_TOKEN,
/V2/.test(poolName) ? [TAGS.aTokenV2, TAGS.aaveV2] : [TAGS.aTokenV3, TAGS.aaveV3],
{pool: poolName, underlying: reserve.UNDERLYING},
{pool: pool, underlying: reserve.UNDERLYING},
);
if (reserve.STATA_TOKEN && reserve.STATA_TOKEN != zeroAddress)
await addToken(
reserve.STATA_TOKEN,
[/V2/.test(poolName) ? TAGS.aaveV3 : TAGS.aaveV3, TAGS.stataToken],
{
pool: poolName,
pool: pool,
underlying: reserve.UNDERLYING,
underlyingAToken: reserve.A_TOKEN,
},
Expand Down
6 changes: 1 addition & 5 deletions scripts/generator/protocolV2Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,8 @@ export async function generateProtocolV2Library(config: PoolConfig) {
const assetsLibrary = generateAssetsLibrary(config.chainId, reservesData, assetsLibraryName);
appendFileSync(`./src/${name}.sol`, assetsLibrary.solidity);
appendFileSync(`./src/ts/${name}.ts`, assetsLibrary.js);
// appendFileSync(`./src/ts/AaveAddressBook.ts`, `export {${name}} from './${name}';\r\n`);
// appendFileSync(
// `./src/ts/AaveAddressBook.ts`,
// `export {${assetsLibraryName}} from './${assetsLibraryName}';\r\n`,
// );
return {
pool: (addresses.POOL as any).value,
name,
reservesData,
chainId: config.chainId,
Expand Down
1 change: 1 addition & 0 deletions scripts/generator/protocolV3Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ export async function generateProtocolV3Library(config: PoolConfig) {
appendFileSync(`./src/ts/${name}.ts`, eModesLibrary.js);

return {
pool: (addresses.POOL as any).value,
name,
reservesData,
chainId: config.chainId,
Expand Down
2 changes: 2 additions & 0 deletions src/ts/AaveAddressBook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,6 @@ export {IStakeToken_ABI} from './abis/IStakeToken';
export {IAaveToken_ABI} from './abis/IAaveToken';
export {IStkAaveToken_ABI} from './abis/IStkAaveToken';
export {IATokenWithDelegation_ABI} from './abis/IATokenWithDelegation';
export {IStaticATokenFactory_ABI} from './abis/IStaticATokenFactory';
export {IStaticATokenLM_ABI} from './abis/IStaticATokenLM';
export * as AaveV3Harmony from './AaveV3Harmony';
190 changes: 190 additions & 0 deletions src/ts/abis/IStaticATokenFactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
// AUTOGENERATED - MANUALLY CHANGES WILL BE REVERTED BY THE GENERATOR
export const IStaticATokenFactory_ABI = [
{
inputs: [
{
internalType: 'contract IPool',
name: 'pool',
type: 'address',
components: [],
},
{
internalType: 'address',
name: 'proxyAdmin',
type: 'address',
components: [],
},
{
internalType: 'contract ITransparentProxyFactory',
name: 'transparentProxyFactory',
type: 'address',
components: [],
},
{
internalType: 'address',
name: 'staticATokenImpl',
type: 'address',
components: [],
},
],
stateMutability: 'nonpayable',
type: 'constructor',
outputs: [],
},
{
inputs: [
{
internalType: 'uint8',
name: 'version',
type: 'uint8',
components: [],
indexed: false,
},
],
type: 'event',
name: 'Initialized',
outputs: [],
anonymous: false,
},
{
inputs: [
{
internalType: 'address',
name: 'staticAToken',
type: 'address',
components: [],
indexed: true,
},
{
internalType: 'address',
name: 'underlying',
type: 'address',
components: [],
indexed: true,
},
],
type: 'event',
name: 'StaticTokenCreated',
outputs: [],
anonymous: false,
},
{
inputs: [],
stateMutability: 'view',
type: 'function',
name: 'ADMIN',
outputs: [
{
internalType: 'address',
name: '',
type: 'address',
components: [],
},
],
},
{
inputs: [],
stateMutability: 'view',
type: 'function',
name: 'POOL',
outputs: [
{
internalType: 'contract IPool',
name: '',
type: 'address',
components: [],
},
],
},
{
inputs: [],
stateMutability: 'view',
type: 'function',
name: 'STATIC_A_TOKEN_IMPL',
outputs: [
{
internalType: 'address',
name: '',
type: 'address',
components: [],
},
],
},
{
inputs: [],
stateMutability: 'view',
type: 'function',
name: 'TRANSPARENT_PROXY_FACTORY',
outputs: [
{
internalType: 'contract ITransparentProxyFactory',
name: '',
type: 'address',
components: [],
},
],
},
{
inputs: [
{
internalType: 'address[]',
name: 'underlyings',
type: 'address[]',
components: [],
},
],
stateMutability: 'nonpayable',
type: 'function',
name: 'createStaticATokens',
outputs: [
{
internalType: 'address[]',
name: '',
type: 'address[]',
components: [],
},
],
},
{
inputs: [
{
internalType: 'address',
name: 'underlying',
type: 'address',
components: [],
},
],
stateMutability: 'view',
type: 'function',
name: 'getStaticAToken',
outputs: [
{
internalType: 'address',
name: '',
type: 'address',
components: [],
},
],
},
{
inputs: [],
stateMutability: 'view',
type: 'function',
name: 'getStaticATokens',
outputs: [
{
internalType: 'address[]',
name: '',
type: 'address[]',
components: [],
},
],
},
{
inputs: [],
stateMutability: 'nonpayable',
type: 'function',
name: 'initialize',
outputs: [],
},
] as const;
Loading

0 comments on commit 6e89a60

Please sign in to comment.