Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: gnosis paraswap adapters (#700) #701

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions safe.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,7 @@ address,name,chainId
0x33AE1f41546a2e05368Bf789b3d868813c0Ae658,AaveV3Gnosis CAPS_PLUS_RISK_STEWARD,100
0x3e652E97ff339B73421f824F5b03d75b62F1Fb51,AaveV3Gnosis COLLECTOR,100
0x97CB9e81d480A2AB03299760654C1DDC0C16bE07,AaveV3Gnosis CONFIG_ENGINE,100
0xE28E2c8d240dd5eBd0adcab86fbD79df7a052034,AaveV3Gnosis DEBT_SWAP_ADAPTER,100
0x589750BA8aF186cE5B55391B0b7148cAD43a1619,AaveV3Gnosis DEFAULT_A_TOKEN_IMPL_REV_1,100
0xaD4F91D26254B6B0C6346b390dDA2991FDE2F20d,AaveV3Gnosis DEFAULT_INCENTIVES_CONTROLLER,100
0xBeC519531F0E78BcDdB295242fA4EC5251B38574,AaveV3Gnosis DEFAULT_VARIABLE_DEBT_TOKEN_IMPL_REV_1,100
Expand All @@ -1063,12 +1064,15 @@ address,name,chainId
0x7304979ec9E4EaA0273b6A037a31c4e9e5A75D16,AaveV3Gnosis POOL_CONFIGURATOR,100
0x4816b2C2895f97fB918f1aE7Da403750a0eE372e,AaveV3Gnosis POOL_CONFIGURATOR_IMPL,100
0xF2C312BfAF4CF0429DB4DA15a0cf5F770Ea3E770,AaveV3Gnosis POOL_IMPL,100
0x86b0521f92a554057e54B93098BA2A6Aaa2F4ACB,AaveV3Gnosis REPAY_WITH_COLLATERAL_ADAPTER,100
0x677c9f358dA5DC83aF6760a839E4448D72840d04,AaveV3Gnosis RISK_STEWARD,100
0x02e9b27599C4Bf8f789d34b6E65C51092c3d9FA6,AaveV3Gnosis STATIC_A_TOKEN_FACTORY,100
0x63dfa7c09Dc2Ff4030d6B8Dc2ce6262BF898C8A4,AaveV3Gnosis SWAP_COLLATERAL_ADAPTER,100
0x5d4D4007A4c6336550DdAa2a7c0d5e7972eebd16,AaveV3Gnosis UI_INCENTIVE_DATA_PROVIDER,100
0x5598BbFA2f4fE8151f45bBA0a3edE1b54B51a0a9,AaveV3Gnosis UI_POOL_DATA_PROVIDER,100
0x4172E6aAEC070ACB31aaCE343A58c93E4C70f44D,AaveV3Gnosis WALLET_BALANCE_PROVIDER,100
0x7B9c12915c594a68dE96201Cbdc79147F09da278,AaveV3Gnosis WETH_GATEWAY,100
0xc0179321f0825c3e0F59Fe7Ca4E40557b97797a3,AaveV3Gnosis WITHDRAW_SWAP_ADAPTER,100
0xF937ffAeA1363e4Fa260760bDFA2aA8Fc911F84D,GovernanceV3Gnosis CL_EMERGENCY_ORACLE,100
0x8Dc5310fc9D3D7D1Bb3D1F686899c8F082316c9F,GovernanceV3Gnosis CROSS_CHAIN_CONTROLLER,100
0x1dF462e2712496373A347f8ad10802a5E95f053D,GovernanceV3Gnosis EXECUTOR_LVL_1,100
Expand Down
4 changes: 4 additions & 0 deletions scripts/configs/pools/gnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ export const gnosisProtoV3: PoolConfig = {
RISK_STEWARD: '0x677c9f358dA5DC83aF6760a839E4448D72840d04',
FREEZING_STEWARD: '0x3Ceaf9b6CAb92dFe6302D0CC3F1BA880C28d35e5',
STATIC_A_TOKEN_FACTORY: '0x02e9b27599C4Bf8f789d34b6E65C51092c3d9FA6',
REPAY_WITH_COLLATERAL_ADAPTER: '0x86b0521f92a554057e54B93098BA2A6Aaa2F4ACB',
SWAP_COLLATERAL_ADAPTER: '0x63dfa7c09Dc2Ff4030d6B8Dc2ce6262BF898C8A4',
DEBT_SWAP_ADAPTER: '0xE28E2c8d240dd5eBd0adcab86fbD79df7a052034',
WITHDRAW_SWAP_ADAPTER: '0xc0179321f0825c3e0F59Fe7Ca4E40557b97797a3',
},
};
13 changes: 13 additions & 0 deletions src/AaveV3Gnosis.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ library AaveV3Gnosis {

// https://gnosisscan.io/address/0x02e9b27599C4Bf8f789d34b6E65C51092c3d9FA6
address internal constant STATIC_A_TOKEN_FACTORY = 0x02e9b27599C4Bf8f789d34b6E65C51092c3d9FA6;

// https://gnosisscan.io/address/0x86b0521f92a554057e54B93098BA2A6Aaa2F4ACB
address internal constant REPAY_WITH_COLLATERAL_ADAPTER =
0x86b0521f92a554057e54B93098BA2A6Aaa2F4ACB;

// https://gnosisscan.io/address/0x63dfa7c09Dc2Ff4030d6B8Dc2ce6262BF898C8A4
address internal constant SWAP_COLLATERAL_ADAPTER = 0x63dfa7c09Dc2Ff4030d6B8Dc2ce6262BF898C8A4;

// https://gnosisscan.io/address/0xE28E2c8d240dd5eBd0adcab86fbD79df7a052034
address internal constant DEBT_SWAP_ADAPTER = 0xE28E2c8d240dd5eBd0adcab86fbD79df7a052034;

// https://gnosisscan.io/address/0xc0179321f0825c3e0F59Fe7Ca4E40557b97797a3
address internal constant WITHDRAW_SWAP_ADAPTER = 0xc0179321f0825c3e0F59Fe7Ca4E40557b97797a3;
}
library AaveV3GnosisAssets {
// https://gnosisscan.io/address/0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1
Expand Down
12 changes: 12 additions & 0 deletions src/ts/AaveV3Gnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ export const FREEZING_STEWARD = '0x3Ceaf9b6CAb92dFe6302D0CC3F1BA880C28d35e5';
// https://gnosisscan.io/address/0x02e9b27599C4Bf8f789d34b6E65C51092c3d9FA6
export const STATIC_A_TOKEN_FACTORY = '0x02e9b27599C4Bf8f789d34b6E65C51092c3d9FA6';

// https://gnosisscan.io/address/0x86b0521f92a554057e54B93098BA2A6Aaa2F4ACB
export const REPAY_WITH_COLLATERAL_ADAPTER = '0x86b0521f92a554057e54B93098BA2A6Aaa2F4ACB';

// https://gnosisscan.io/address/0x63dfa7c09Dc2Ff4030d6B8Dc2ce6262BF898C8A4
export const SWAP_COLLATERAL_ADAPTER = '0x63dfa7c09Dc2Ff4030d6B8Dc2ce6262BF898C8A4';

// https://gnosisscan.io/address/0xE28E2c8d240dd5eBd0adcab86fbD79df7a052034
export const DEBT_SWAP_ADAPTER = '0xE28E2c8d240dd5eBd0adcab86fbD79df7a052034';

// https://gnosisscan.io/address/0xc0179321f0825c3e0F59Fe7Ca4E40557b97797a3
export const WITHDRAW_SWAP_ADAPTER = '0xc0179321f0825c3e0F59Fe7Ca4E40557b97797a3';

export const CHAIN_ID = 100;
export const ASSETS = {
WETH: {
Expand Down
12 changes: 12 additions & 0 deletions tests/cache/verified.json
Original file line number Diff line number Diff line change
Expand Up @@ -3341,6 +3341,18 @@
},
"0xCb45E82419baeBCC9bA8b1e5c7858e48A3B26Ea6": {
"name": "GnosisSafeProxy"
},
"0x86b0521f92a554057e54B93098BA2A6Aaa2F4ACB": {
"name": "ParaSwapRepayAdapter"
},
"0xc0179321f0825c3e0F59Fe7Ca4E40557b97797a3": {
"name": "ParaSwapWithdrawSwapAdapter"
},
"0x63dfa7c09Dc2Ff4030d6B8Dc2ce6262BF898C8A4": {
"name": "ParaSwapLiquiditySwapAdapter"
},
"0xE28E2c8d240dd5eBd0adcab86fbD79df7a052034": {
"name": "ParaSwapDebtSwapAdapterV3"
}
},
"137": {
Expand Down
87 changes: 87 additions & 0 deletions tests/sanity/psp.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import {describe, it, expect} from 'vitest';
import * as addressBook from '../../src/ts/AaveAddressBook';
import {getContract} from 'viem';
import {getClient} from '../../scripts/clients';
import {getGovernance} from '../utils';
import {IRiskSteward_ABI} from '../../src/ts/abis/IRiskSteward';

export async function checkGetters(address, addresses: Record<string, any>) {
const client = getClient(addresses.CHAIN_ID);
const riskStewardContract = getContract({
abi: [
{
inputs: [],
name: 'ADDRESSES_PROVIDER',
outputs: [{internalType: 'contract IPoolAddressesProvider', name: '', type: 'address'}],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'AUGUSTUS_REGISTRY',
outputs: [{internalType: 'contract IParaSwapAugustusRegistry', name: '', type: 'address'}],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'ORACLE',
outputs: [{internalType: 'contract IPriceOracleGetter', name: '', type: 'address'}],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'POOL',
outputs: [{internalType: 'contract IPool', name: '', type: 'address'}],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'owner',
outputs: [{internalType: 'address', name: '', type: 'address'}],
stateMutability: 'view',
type: 'function',
},
] as const,
address: address,
client,
});
const [POOL, ORACLE, OWNER] = await Promise.all([
riskStewardContract.read.POOL(),
riskStewardContract.read.ORACLE(),
riskStewardContract.read.owner(),
]);
expect(POOL).toEqual(addresses.POOL);
expect(ORACLE).toEqual(addresses.ORACLE);

const governance = getGovernance(addresses.CHAIN_ID);
if (!governance) {
console.log(`SANITY_PSP: Skipped due to missing governance on ${client.chain?.name}`);
} else {
const l1Executor = (governance as any).EXECUTOR_LVL_1;
expect(OWNER).toEqual(l1Executor);
}
}

describe('paraswap adapters', () => {
it('should reference correct contracts on all getters', async () => {
await Promise.all(
Object.keys(addressBook).map((library) => {
const addresses = addressBook[library];
// we currently only validate V3 adapters as v2 has no getters
if (library.startsWith('AaveV3')) {
if (addresses.REPAY_WITH_COLLATERAL_ADAPTER)
return checkGetters(addresses.REPAY_WITH_COLLATERAL_ADAPTER, addresses);
if (addresses.SWAP_COLLATERAL_ADAPTER)
return checkGetters(addresses.SWAP_COLLATERAL_ADAPTER, addresses);
if (addresses.DEBT_SWAP_ADAPTER)
return checkGetters(addresses.DEBT_SWAP_ADAPTER, addresses);
if (addresses.WITHDRAW_SWAP_ADAPTER)
return checkGetters(addresses.WITHDRAW_SWAP_ADAPTER, addresses);
}
}),
);
});
});
1 change: 1 addition & 0 deletions tests/verification.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ describe(
status: string;
result: {ContractName: string}[];
};
await sleep(300);
if (status !== '1' || !result[0].ContractName) {
errors.push({item, error: result});
} else {
Expand Down
Loading