-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
520 additions
and
5 deletions.
There are no files selected for viewing
Submodule aave-v3-origin
updated
7 files
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,358 @@ | ||
export const IUmbrella_ABI = [ | ||
{ | ||
inputs: [ | ||
{internalType: 'contract IPool', name: 'pool', type: 'address'}, | ||
{internalType: 'address', name: 'collector', type: 'address'}, | ||
{internalType: 'contract ITransparentProxyFactory', name: 'proxyFactory', type: 'address'}, | ||
{internalType: 'address', name: 'stakeTokenImpl', type: 'address'}, | ||
{internalType: 'address', name: 'proxyAdmin', type: 'address'}, | ||
], | ||
stateMutability: 'nonpayable', | ||
type: 'constructor', | ||
}, | ||
{inputs: [], name: 'CannotSlashReserve', type: 'error'}, | ||
{ | ||
inputs: [{internalType: 'bytes32', name: 'key', type: 'bytes32'}], | ||
name: 'EnumerableMapNonexistentKey', | ||
type: 'error', | ||
}, | ||
{inputs: [], name: 'InvalidInitialization', type: 'error'}, | ||
{inputs: [], name: 'InvalidLiquidationBonus', type: 'error'}, | ||
{inputs: [], name: 'MathOverflowedMulDiv', type: 'error'}, | ||
{inputs: [], name: 'NoDeficitToCover', type: 'error'}, | ||
{inputs: [], name: 'NoDeficitToSlash', type: 'error'}, | ||
{inputs: [], name: 'NotInitializing', type: 'error'}, | ||
{ | ||
inputs: [{internalType: 'address', name: 'owner', type: 'address'}], | ||
name: 'OwnableInvalidOwner', | ||
type: 'error', | ||
}, | ||
{ | ||
inputs: [{internalType: 'address', name: 'account', type: 'address'}], | ||
name: 'OwnableUnauthorizedAccount', | ||
type: 'error', | ||
}, | ||
{inputs: [], name: 'StataAssetMustMatchReserve', type: 'error'}, | ||
{ | ||
inputs: [{internalType: 'address', name: 'target', type: 'address'}], | ||
name: 'UmbrellaNotInControl', | ||
type: 'error', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [{indexed: false, internalType: 'uint64', name: 'version', type: 'uint64'}], | ||
name: 'Initialized', | ||
type: 'event', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{indexed: true, internalType: 'address', name: 'previousOwner', type: 'address'}, | ||
{indexed: true, internalType: 'address', name: 'newOwner', type: 'address'}, | ||
], | ||
name: 'OwnershipTransferred', | ||
type: 'event', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{indexed: true, internalType: 'address', name: 'reserve', type: 'address'}, | ||
{indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256'}, | ||
], | ||
name: 'RecordedReserveDeficitChanged', | ||
type: 'event', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{indexed: true, internalType: 'address', name: 'reserve', type: 'address'}, | ||
{indexed: false, internalType: 'address', name: 'stakeToken', type: 'address'}, | ||
{indexed: false, internalType: 'uint256', name: 'liquidationBonus', type: 'uint256'}, | ||
{indexed: false, internalType: 'address', name: 'oracle', type: 'address'}, | ||
{indexed: false, internalType: 'bool', name: 'isReserveStataToken', type: 'bool'}, | ||
], | ||
name: 'SlashingConfigurationChanged', | ||
type: 'event', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{indexed: true, internalType: 'address', name: 'reserve', type: 'address'}, | ||
{indexed: false, internalType: 'address', name: 'stakeToken', type: 'address'}, | ||
], | ||
name: 'SlashingConfigurationRemoved', | ||
type: 'event', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{indexed: false, internalType: 'address', name: 'stakeToken', type: 'address'}, | ||
{indexed: false, internalType: 'address', name: 'underlying', type: 'address'}, | ||
{indexed: false, internalType: 'string', name: 'name', type: 'string'}, | ||
{indexed: false, internalType: 'string', name: 'symbol', type: 'string'}, | ||
], | ||
name: 'StakeTokenCreated', | ||
type: 'event', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'COLLECTOR', | ||
outputs: [{internalType: 'address', name: '', type: 'address'}], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'POOL', | ||
outputs: [{internalType: 'contract IPool', name: '', type: 'address'}], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'POOL_ADDRESSES_PROVIDER', | ||
outputs: [{internalType: 'contract IPoolAddressesProvider', name: '', type: 'address'}], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'PROXY_ADMIN', | ||
outputs: [{internalType: 'address', name: '', type: 'address'}], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'STAKE_TOKEN_IMPL', | ||
outputs: [{internalType: 'address', name: '', type: 'address'}], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'TRANSPARENT_PROXY_FACTORY', | ||
outputs: [{internalType: 'contract ITransparentProxyFactory', name: '', type: 'address'}], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [ | ||
{internalType: 'address', name: 'reserve', type: 'address'}, | ||
{internalType: 'uint256', name: 'amount', type: 'uint256'}, | ||
], | ||
name: 'coverReserveDeficit', | ||
outputs: [{internalType: 'uint256', name: '', type: 'uint256'}], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [ | ||
{internalType: 'address', name: 'underlying', type: 'address'}, | ||
{internalType: 'uint256', name: 'defaultCooldown', type: 'uint256'}, | ||
{internalType: 'uint256', name: 'defaultUnstakeWindow', type: 'uint256'}, | ||
], | ||
name: 'createStakeToken', | ||
outputs: [{internalType: 'address', name: '', type: 'address'}], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [ | ||
{internalType: 'address', name: 'stakeToken', type: 'address'}, | ||
{internalType: 'address', name: 'to', type: 'address'}, | ||
{internalType: 'uint256', name: 'amount', type: 'uint256'}, | ||
], | ||
name: 'emergencyEtherTransferStk', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [ | ||
{internalType: 'address', name: 'stakeToken', type: 'address'}, | ||
{internalType: 'address', name: 'erc20Token', type: 'address'}, | ||
{internalType: 'address', name: 'to', type: 'address'}, | ||
{internalType: 'uint256', name: 'amount', type: 'uint256'}, | ||
], | ||
name: 'emergencyTokenTransferStk', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{internalType: 'address', name: 'reserve', type: 'address'}], | ||
name: 'getPendingDeficitResolution', | ||
outputs: [{internalType: 'uint256', name: '', type: 'uint256'}], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [ | ||
{internalType: 'address', name: 'reserve', type: 'address'}, | ||
{internalType: 'address', name: 'stakeToken', type: 'address'}, | ||
], | ||
name: 'getReserveSlashingConfig', | ||
outputs: [ | ||
{ | ||
components: [ | ||
{internalType: 'address', name: 'stakeToken', type: 'address'}, | ||
{internalType: 'contract AggregatorInterface', name: 'oracle', type: 'address'}, | ||
{internalType: 'uint256', name: 'liquidationBonus', type: 'uint256'}, | ||
{internalType: 'bool', name: 'isReserveStataToken', type: 'bool'}, | ||
], | ||
internalType: 'struct IUmbrellaConfiguration.SlashingConfig', | ||
name: '', | ||
type: 'tuple', | ||
}, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{internalType: 'address', name: 'reserve', type: 'address'}], | ||
name: 'getReserveSlashingConfigs', | ||
outputs: [ | ||
{ | ||
components: [ | ||
{internalType: 'address', name: 'stakeToken', type: 'address'}, | ||
{internalType: 'contract AggregatorInterface', name: 'oracle', type: 'address'}, | ||
{internalType: 'uint256', name: 'liquidationBonus', type: 'uint256'}, | ||
{internalType: 'bool', name: 'isReserveStataToken', type: 'bool'}, | ||
], | ||
internalType: 'struct IUmbrellaConfiguration.SlashingConfig[]', | ||
name: '', | ||
type: 'tuple[]', | ||
}, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'getStkTokens', | ||
outputs: [{internalType: 'address[]', name: '', type: 'address[]'}], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{internalType: 'address', name: 'owner', type: 'address'}], | ||
name: 'initialize', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{internalType: 'address', name: 'reserve', type: 'address'}], | ||
name: 'isReserveSlashable', | ||
outputs: [{internalType: 'bool', name: '', type: 'bool'}], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{internalType: 'address', name: 'stakeToken', type: 'address'}], | ||
name: 'isUmbrellaStkToken', | ||
outputs: [{internalType: 'bool', name: '', type: 'bool'}], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'owner', | ||
outputs: [{internalType: 'address', name: '', type: 'address'}], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{internalType: 'address', name: 'stakeToken', type: 'address'}], | ||
name: 'pauseStk', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
components: [ | ||
{internalType: 'address', name: 'reserve', type: 'address'}, | ||
{internalType: 'address', name: 'stakeToken', type: 'address'}, | ||
], | ||
internalType: 'struct IUmbrellaConfiguration.SlashingConfigRemoval[]', | ||
name: 'removalPairs', | ||
type: 'tuple[]', | ||
}, | ||
], | ||
name: 'removeSlashingConfigs', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'renounceOwnership', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [ | ||
{internalType: 'address', name: 'stakeToken', type: 'address'}, | ||
{internalType: 'uint256', name: 'newCooldown', type: 'uint256'}, | ||
], | ||
name: 'setCooldownStk', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [ | ||
{internalType: 'address', name: 'stakeToken', type: 'address'}, | ||
{internalType: 'uint256', name: 'newUnstakeWindow', type: 'uint256'}, | ||
], | ||
name: 'setUnstakeWindowStk', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{internalType: 'address', name: 'reserve', type: 'address'}], | ||
name: 'slashReserveDeficit', | ||
outputs: [{internalType: 'uint256', name: '', type: 'uint256'}], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{internalType: 'address', name: 'newOwner', type: 'address'}], | ||
name: 'transferOwnership', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{internalType: 'address', name: 'stakeToken', type: 'address'}], | ||
name: 'unpauseStk', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
components: [ | ||
{internalType: 'address', name: 'reserve', type: 'address'}, | ||
{internalType: 'address', name: 'stakeToken', type: 'address'}, | ||
{internalType: 'uint256', name: 'liquidationBonus', type: 'uint256'}, | ||
{internalType: 'bool', name: 'isReserveStataToken', type: 'bool'}, | ||
{internalType: 'address', name: 'stakeTokenOracle', type: 'address'}, | ||
], | ||
internalType: 'struct IUmbrellaConfiguration.SlashingConfigUpdate[]', | ||
name: 'coverageConfig', | ||
type: 'tuple[]', | ||
}, | ||
], | ||
name: 'updateSlashingConfigs', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
] as const; |
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 |
---|---|---|
@@ -1,20 +1,33 @@ | ||
import {HttpTransportConfig, createPublicClient, Client, http} from 'viem'; | ||
import {HttpTransportConfig, createClient, Client, http} from 'viem'; | ||
import {ChainList, getRPCUrl} from '@bgd-labs/rpc-env'; | ||
|
||
const commonConfig: HttpTransportConfig = {timeout: 30_000, batch: true}; | ||
const batchConfig = {batch: {multicall: true}}; | ||
|
||
const clientCache: Record<number, Client> = {}; | ||
|
||
const set = (obj, path, value) => { | ||
// Regex explained: https://regexr.com/58j0k | ||
const pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g); | ||
|
||
pathArray.reduce((acc, key, i) => { | ||
if (acc[key] === undefined) acc[key] = {}; | ||
if (i === pathArray.length - 1) acc[key] = value; | ||
return acc[key]; | ||
}, obj); | ||
}; | ||
|
||
export function getClient(chainId: number) { | ||
if (!clientCache[chainId]) { | ||
const rpcURL = getRPCUrl(chainId as any, {alchemyKey: process.env.ALCHEMY_API_KEY}); | ||
|
||
clientCache[chainId] = createPublicClient({ | ||
const transport = http(rpcURL, commonConfig); | ||
const client = createClient({ | ||
chain: ChainList[chainId], | ||
transport: http(rpcURL, commonConfig), | ||
transport: transport, | ||
...batchConfig, | ||
}); | ||
|
||
clientCache[chainId] = client; | ||
} | ||
return clientCache[chainId]; | ||
} |
Oops, something went wrong.