mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
fix deployment and tests
This commit is contained in:
parent
43c8ef02db
commit
84cf68e58e
|
@ -32,8 +32,8 @@ import {Ierc20Detailed} from '../types/Ierc20Detailed';
|
||||||
import {StableDebtToken} from '../types/StableDebtToken';
|
import {StableDebtToken} from '../types/StableDebtToken';
|
||||||
import {VariableDebtToken} from '../types/VariableDebtToken';
|
import {VariableDebtToken} from '../types/VariableDebtToken';
|
||||||
import {MockSwapAdapter} from '../types/MockSwapAdapter';
|
import {MockSwapAdapter} from '../types/MockSwapAdapter';
|
||||||
import { signTypedData_v4, TypedData } from "eth-sig-util";
|
import {signTypedData_v4, TypedData} from 'eth-sig-util';
|
||||||
import { fromRpcSig, ECDSASignature } from "ethereumjs-util";
|
import {fromRpcSig, ECDSASignature} from 'ethereumjs-util';
|
||||||
|
|
||||||
export const registerContractInJsonDb = async (contractId: string, contractInstance: Contract) => {
|
export const registerContractInJsonDb = async (contractId: string, contractInstance: Contract) => {
|
||||||
const currentNetwork = BRE.network.name;
|
const currentNetwork = BRE.network.name;
|
||||||
|
@ -251,49 +251,55 @@ export const deployDefaultReserveInterestRateStrategy = async ([
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
export const deployStableDebtToken = async ([name, symbol, underlyingAsset, poolAddress]: [
|
export const deployStableDebtToken = async ([
|
||||||
string,
|
name,
|
||||||
string,
|
symbol,
|
||||||
tEthereumAddress,
|
underlyingAsset,
|
||||||
tEthereumAddress
|
poolAddress,
|
||||||
]) => {
|
incentivesController,
|
||||||
|
]: [string, string, tEthereumAddress, tEthereumAddress, tEthereumAddress]) => {
|
||||||
const token = await deployContract<StableDebtToken>(eContractid.StableDebtToken, [
|
const token = await deployContract<StableDebtToken>(eContractid.StableDebtToken, [
|
||||||
poolAddress,
|
poolAddress,
|
||||||
underlyingAsset,
|
underlyingAsset,
|
||||||
name,
|
name,
|
||||||
symbol,
|
symbol,
|
||||||
|
incentivesController,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deployVariableDebtToken = async ([name, symbol, underlyingAsset, poolAddress]: [
|
export const deployVariableDebtToken = async ([
|
||||||
string,
|
name,
|
||||||
string,
|
symbol,
|
||||||
tEthereumAddress,
|
underlyingAsset,
|
||||||
tEthereumAddress
|
poolAddress,
|
||||||
]) => {
|
incentivesController,
|
||||||
|
]: [string, string, tEthereumAddress, tEthereumAddress, tEthereumAddress]) => {
|
||||||
const token = await deployContract<VariableDebtToken>(eContractid.VariableDebtToken, [
|
const token = await deployContract<VariableDebtToken>(eContractid.VariableDebtToken, [
|
||||||
poolAddress,
|
poolAddress,
|
||||||
underlyingAsset,
|
underlyingAsset,
|
||||||
name,
|
name,
|
||||||
symbol,
|
symbol,
|
||||||
|
incentivesController,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deployGenericAToken = async ([poolAddress, underlyingAssetAddress, name, symbol]: [
|
export const deployGenericAToken = async ([
|
||||||
tEthereumAddress,
|
poolAddress,
|
||||||
tEthereumAddress,
|
underlyingAssetAddress,
|
||||||
string,
|
name,
|
||||||
string
|
symbol,
|
||||||
]) => {
|
incentivesController,
|
||||||
|
]: [tEthereumAddress, tEthereumAddress, string, string, tEthereumAddress]) => {
|
||||||
const token = await deployContract<AToken>(eContractid.AToken, [
|
const token = await deployContract<AToken>(eContractid.AToken, [
|
||||||
poolAddress,
|
poolAddress,
|
||||||
underlyingAssetAddress,
|
underlyingAssetAddress,
|
||||||
name,
|
name,
|
||||||
symbol,
|
symbol,
|
||||||
|
incentivesController,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
|
@ -491,20 +497,20 @@ export const buildPermitParams = (
|
||||||
) => ({
|
) => ({
|
||||||
types: {
|
types: {
|
||||||
EIP712Domain: [
|
EIP712Domain: [
|
||||||
{ name: "name", type: "string" },
|
{name: 'name', type: 'string'},
|
||||||
{ name: "version", type: "string" },
|
{name: 'version', type: 'string'},
|
||||||
{ name: "chainId", type: "uint256" },
|
{name: 'chainId', type: 'uint256'},
|
||||||
{ name: "verifyingContract", type: "address" },
|
{name: 'verifyingContract', type: 'address'},
|
||||||
],
|
],
|
||||||
Permit: [
|
Permit: [
|
||||||
{ name: "owner", type: "address" },
|
{name: 'owner', type: 'address'},
|
||||||
{ name: "spender", type: "address" },
|
{name: 'spender', type: 'address'},
|
||||||
{ name: "value", type: "uint256" },
|
{name: 'value', type: 'uint256'},
|
||||||
{ name: "nonce", type: "uint256" },
|
{name: 'nonce', type: 'uint256'},
|
||||||
{ name: "deadline", type: "uint256" },
|
{name: 'deadline', type: 'uint256'},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
primaryType: "Permit" as const,
|
primaryType: 'Permit' as const,
|
||||||
domain: {
|
domain: {
|
||||||
name: tokenName,
|
name: tokenName,
|
||||||
version: revision,
|
version: revision,
|
||||||
|
@ -520,16 +526,12 @@ export const buildPermitParams = (
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export const getSignatureFromTypedData = (
|
export const getSignatureFromTypedData = (
|
||||||
privateKey: string,
|
privateKey: string,
|
||||||
typedData: any // TODO: should be TypedData, from eth-sig-utils, but TS doesn't accept it
|
typedData: any // TODO: should be TypedData, from eth-sig-utils, but TS doesn't accept it
|
||||||
): ECDSASignature => {
|
): ECDSASignature => {
|
||||||
const signature = signTypedData_v4(
|
const signature = signTypedData_v4(Buffer.from(privateKey.substring(2, 66), 'hex'), {
|
||||||
Buffer.from(privateKey.substring(2, 66), "hex"),
|
data: typedData,
|
||||||
{
|
});
|
||||||
data: typedData,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return fromRpcSig(signature);
|
return fromRpcSig(signature);
|
||||||
};
|
};
|
||||||
|
|
|
@ -175,7 +175,8 @@ const initReserves = async (
|
||||||
lendingPoolAddressesProvider: LendingPoolAddressesProvider,
|
lendingPoolAddressesProvider: LendingPoolAddressesProvider,
|
||||||
lendingPool: LendingPool,
|
lendingPool: LendingPool,
|
||||||
lendingPoolConfigurator: LendingPoolConfigurator,
|
lendingPoolConfigurator: LendingPoolConfigurator,
|
||||||
aavePool: AavePools
|
aavePool: AavePools,
|
||||||
|
incentivesController: tEthereumAddress
|
||||||
) => {
|
) => {
|
||||||
if (aavePool !== AavePools.proto && aavePool !== AavePools.secondary) {
|
if (aavePool !== AavePools.proto && aavePool !== AavePools.secondary) {
|
||||||
console.log(`Invalid Aave pool ${aavePool}`);
|
console.log(`Invalid Aave pool ${aavePool}`);
|
||||||
|
@ -230,6 +231,7 @@ const initReserves = async (
|
||||||
`stableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
`stableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
||||||
tokenAddress,
|
tokenAddress,
|
||||||
lendingPool.address,
|
lendingPool.address,
|
||||||
|
incentivesController,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const variableDebtToken = await deployVariableDebtToken([
|
const variableDebtToken = await deployVariableDebtToken([
|
||||||
|
@ -237,6 +239,7 @@ const initReserves = async (
|
||||||
`variableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
`variableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
||||||
tokenAddress,
|
tokenAddress,
|
||||||
lendingPool.address,
|
lendingPool.address,
|
||||||
|
incentivesController,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const aToken = await deployGenericAToken([
|
const aToken = await deployGenericAToken([
|
||||||
|
@ -244,6 +247,7 @@ const initReserves = async (
|
||||||
tokenAddress,
|
tokenAddress,
|
||||||
`Aave interest bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
`Aave interest bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
||||||
`a${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
`a${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
||||||
|
incentivesController,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (process.env.POOL === AavePools.secondary) {
|
if (process.env.POOL === AavePools.secondary) {
|
||||||
|
@ -481,7 +485,8 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
addressesProvider,
|
addressesProvider,
|
||||||
lendingPoolProxy,
|
lendingPoolProxy,
|
||||||
lendingPoolConfiguratorProxy,
|
lendingPoolConfiguratorProxy,
|
||||||
AavePools.proto
|
AavePools.proto,
|
||||||
|
ZERO_ADDRESS
|
||||||
);
|
);
|
||||||
await enableReservesToBorrow(
|
await enableReservesToBorrow(
|
||||||
reservesParams,
|
reservesParams,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user