Skip to content

Commit

Permalink
feat: add collateral manager (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra authored Nov 8, 2023
1 parent 455f7d5 commit c852ff7
Show file tree
Hide file tree
Showing 43 changed files with 539 additions and 671 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
},
"homepage": "https://github.com/bgd-labs/aave-address-book#readme",
"devDependencies": {
"@types/node": "^20.5.7",
"@types/node": "^20.9.0",
"esbuild-plugin-file-path-extensions": "^1.0.0",
"prettier": "^3.0.3",
"prettier-plugin-solidity": "^1.1.3",
"tsup": "^7.2.0",
"tsx": "^3.12.7",
"tsx": "^3.14.0",
"typescript": "^5.2.2",
"viem": "^1.9.3"
"viem": "^1.18.9"
}
}
6 changes: 0 additions & 6 deletions scripts/configs/pools/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,4 @@ export const baseProtoV3: PoolConfig = {
WALLET_BALANCE_PROVIDER: '0x5779b29B0a34577d927E8D511B595ef9abbFAE82',
WETH_GATEWAY: '0x18CD499E3d7ed42FEbA981ac9236A278E4Cdc2ee',
},
initial: {
COLLECTOR: '0xBA9424d650A4F5c80a0dA641254d1AcCE2A37057',
DEFAULT_A_TOKEN_IMPL: '0x98F409Fc4A42F34AE3c326c7f48ED01ae8cAeC69',
DEFAULT_VARIABLE_DEBT_TOKEN_IMPL: '0x2425A746911128c2eAA7bEBDc9Bc452eE52208a1',
DEFAULT_STABLE_DEBT_TOKEN_IMPL: '0xe0b9B4f959fa8B52B7228c8D78875482b8813349',
},
};
6 changes: 0 additions & 6 deletions scripts/configs/pools/gnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,4 @@ export const gnosisProtoV3: PoolConfig = {
CAPS_PLUS_RISK_STEWARD: '0x33AE1f41546a2e05368Bf789b3d868813c0Ae658',
FREEZING_STEWARD: '0x3Ceaf9b6CAb92dFe6302D0CC3F1BA880C28d35e5',
},
initial: {
COLLECTOR: '0x3e652E97ff339B73421f824F5b03d75b62F1Fb51',
DEFAULT_A_TOKEN_IMPL: '0x589750BA8aF186cE5B55391B0b7148cAD43a1619',
DEFAULT_VARIABLE_DEBT_TOKEN_IMPL: '0xBeC519531F0E78BcDdB295242fA4EC5251B38574',
DEFAULT_STABLE_DEBT_TOKEN_IMPL: '0x06C35Cfd3FC61eC2aC437f0d08840d5776b945af',
}
};
2 changes: 1 addition & 1 deletion scripts/generator/assetsLibraryGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function generateAssetsLibrary(
const symbol = fixSymbol(_symbol, rest.UNDERLYING);
return {
[`${symbol}_UNDERLYING`]: rest.UNDERLYING,
[`${symbol}_DECIMALS`]: {value: rest.decimals, type: 'uint256'},
[`${symbol}_DECIMALS`]: {value: rest.decimals, type: 'uint8'},
[`${symbol}_A_TOKEN`]: rest.A_TOKEN,
[`${symbol}_V_TOKEN`]: rest.V_TOKEN,
[`${symbol}_S_TOKEN`]: rest.S_TOKEN,
Expand Down
2 changes: 1 addition & 1 deletion scripts/generator/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const RPC_PROVIDERS = {
}),
[ChainId.sepolia]: createPublicClient({
chain: sepolia,
transport: http(),
transport: http('https://ethereum-sepolia.publicnode.com'),
batch: {
multicall: true,
},
Expand Down
6 changes: 5 additions & 1 deletion scripts/generator/protocolV2Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface PoolV2Addresses {
COLLECTOR: AddressInfo;
EMISSION_MANAGER: AddressInfo;
DEFAULT_INCENTIVES_CONTROLLER: AddressInfo;
LENDING_POOL_COLLATERAL_MANAGER: AddressInfo;
reservesData: ReserveData[];
}

Expand Down Expand Up @@ -73,7 +74,7 @@ async function getAdditionalTokenInfo(
}

export async function getPoolV2Addresses(pool: PoolConfig): Promise<PoolV2Addresses> {
const publicClient = RPC_PROVIDERS[pool.chainId];
const publicClient = RPC_PROVIDERS[pool.chainId] as PublicClient;
const addressProviderContract = getContract({
address: pool.POOL_ADDRESSES_PROVIDER,
abi: ADDRESS_PROVIDER_V2_ABI,
Expand All @@ -88,6 +89,7 @@ export async function getPoolV2Addresses(pool: PoolConfig): Promise<PoolV2Addres
POOL_ADMIN,
EMERGENCY_ADMIN,
AAVE_PROTOCOL_DATA_PROVIDER,
LENDING_POOL_COLLATERAL_MANAGER,
] = await Promise.all([
addressProviderContract.read.getLendingPool(),
addressProviderContract.read.getLendingRateOracle(),
Expand All @@ -98,6 +100,7 @@ export async function getPoolV2Addresses(pool: PoolConfig): Promise<PoolV2Addres
addressProviderContract.read.getAddress([
'0x0100000000000000000000000000000000000000000000000000000000000000',
]),
addressProviderContract.read.getLendingPoolCollateralManager(),
]);

let reservesData: PoolV2Addresses['reservesData'] = [];
Expand Down Expand Up @@ -184,6 +187,7 @@ export async function getPoolV2Addresses(pool: PoolConfig): Promise<PoolV2Addres
DEFAULT_INCENTIVES_CONTROLLER,
...rest,
EMISSION_MANAGER,
LENDING_POOL_COLLATERAL_MANAGER,
reservesData,
};
} catch (error: any) {
Expand Down
18 changes: 11 additions & 7 deletions src/AaveV2Avalanche.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ library AaveV2Avalanche {
// https://snowtrace.io/address/0x5CfCd7E6D055Ba4f7B998914336254aDE3F69f26
address internal constant EMISSION_MANAGER = 0x5CfCd7E6D055Ba4f7B998914336254aDE3F69f26;

// https://snowtrace.io/address/0xa9c1bb836752a2Dfb3694ca084D8ffBB07768771
address internal constant LENDING_POOL_COLLATERAL_MANAGER =
0xa9c1bb836752a2Dfb3694ca084D8ffBB07768771;

// https://snowtrace.io/address/0xc1D40f4cF36e4aE4108Ffa08818cD16c2d9aEF73
address internal constant DEBT_SWAP_ADAPTER = 0xc1D40f4cF36e4aE4108Ffa08818cD16c2d9aEF73;

Expand Down Expand Up @@ -91,7 +95,7 @@ library AaveV2AvalancheAssets {
// https://snowtrace.io/address/0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB
address internal constant WETHe_UNDERLYING = 0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB;

uint256 internal constant WETHe_DECIMALS = 18;
uint8 internal constant WETHe_DECIMALS = 18;

// https://snowtrace.io/address/0x53f7c5869a859F0AeC3D334ee8B4Cf01E3492f21
address internal constant WETHe_A_TOKEN = 0x53f7c5869a859F0AeC3D334ee8B4Cf01E3492f21;
Expand All @@ -112,7 +116,7 @@ library AaveV2AvalancheAssets {
// https://snowtrace.io/address/0xd586E7F844cEa2F87f50152665BCbc2C279D8d70
address internal constant DAIe_UNDERLYING = 0xd586E7F844cEa2F87f50152665BCbc2C279D8d70;

uint256 internal constant DAIe_DECIMALS = 18;
uint8 internal constant DAIe_DECIMALS = 18;

// https://snowtrace.io/address/0x47AFa96Cdc9fAb46904A55a6ad4bf6660B53c38a
address internal constant DAIe_A_TOKEN = 0x47AFa96Cdc9fAb46904A55a6ad4bf6660B53c38a;
Expand All @@ -133,7 +137,7 @@ library AaveV2AvalancheAssets {
// https://snowtrace.io/address/0xc7198437980c041c805A1EDcbA50c1Ce5db95118
address internal constant USDTe_UNDERLYING = 0xc7198437980c041c805A1EDcbA50c1Ce5db95118;

uint256 internal constant USDTe_DECIMALS = 6;
uint8 internal constant USDTe_DECIMALS = 6;

// https://snowtrace.io/address/0x532E6537FEA298397212F09A61e03311686f548e
address internal constant USDTe_A_TOKEN = 0x532E6537FEA298397212F09A61e03311686f548e;
Expand All @@ -154,7 +158,7 @@ library AaveV2AvalancheAssets {
// https://snowtrace.io/address/0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664
address internal constant USDCe_UNDERLYING = 0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664;

uint256 internal constant USDCe_DECIMALS = 6;
uint8 internal constant USDCe_DECIMALS = 6;

// https://snowtrace.io/address/0x46A51127C3ce23fb7AB1DE06226147F446e4a857
address internal constant USDCe_A_TOKEN = 0x46A51127C3ce23fb7AB1DE06226147F446e4a857;
Expand All @@ -175,7 +179,7 @@ library AaveV2AvalancheAssets {
// https://snowtrace.io/address/0x63a72806098Bd3D9520cC43356dD78afe5D386D9
address internal constant AAVEe_UNDERLYING = 0x63a72806098Bd3D9520cC43356dD78afe5D386D9;

uint256 internal constant AAVEe_DECIMALS = 18;
uint8 internal constant AAVEe_DECIMALS = 18;

// https://snowtrace.io/address/0xD45B7c061016102f9FA220502908f2c0f1add1D7
address internal constant AAVEe_A_TOKEN = 0xD45B7c061016102f9FA220502908f2c0f1add1D7;
Expand All @@ -196,7 +200,7 @@ library AaveV2AvalancheAssets {
// https://snowtrace.io/address/0x50b7545627a5162F82A992c33b87aDc75187B218
address internal constant WBTCe_UNDERLYING = 0x50b7545627a5162F82A992c33b87aDc75187B218;

uint256 internal constant WBTCe_DECIMALS = 8;
uint8 internal constant WBTCe_DECIMALS = 8;

// https://snowtrace.io/address/0x686bEF2417b6Dc32C50a3cBfbCC3bb60E1e9a15D
address internal constant WBTCe_A_TOKEN = 0x686bEF2417b6Dc32C50a3cBfbCC3bb60E1e9a15D;
Expand All @@ -217,7 +221,7 @@ library AaveV2AvalancheAssets {
// https://snowtrace.io/address/0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7
address internal constant WAVAX_UNDERLYING = 0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7;

uint256 internal constant WAVAX_DECIMALS = 18;
uint8 internal constant WAVAX_DECIMALS = 18;

// https://snowtrace.io/address/0xDFE521292EcE2A4f44242efBcD66Bc594CA9714B
address internal constant WAVAX_A_TOKEN = 0xDFE521292EcE2A4f44242efBcD66Bc594CA9714B;
Expand Down
Loading

0 comments on commit c852ff7

Please sign in to comment.