Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.
Open
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
35 changes: 29 additions & 6 deletions tasks/migrations/testnet-deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,70 @@ import {
} from "../../helpers/constants";
import { checkVerification } from "../../helpers/etherscan-verification";

task("testnet-deployment", "Deployment in mainnet network")
// Defines the deployment task for the Aave Token components on a test network.
task("testnet-deployment", "Deploys and initializes AaveToken and LendToAaveMigrator on a test environment.")
.addFlag(
"verify",
"Verify AaveToken, LendToAaveMigrator, and InitializableAdminUpgradeabilityProxy contract."
"Verify AaveToken, LendToAaveMigrator, and InitializableAdminUpgradeabilityProxy contracts on Etherscan."
)
.setAction(async ({ verify }, localBRE) => {
// 1. Setup the Buidler Runtime Environment
const BRE: BuidlerRuntimeEnvironment = await localBRE.run("set-bre");
const network = BRE.network.name as eEthereumNetwork;
const aaveAdmin = getAaveAdminPerNetwork(network);
const lendTokenAddress = getLendTokenPerNetwork(network);

// 2. Validate essential configurations
if (!aaveAdmin) {
throw Error(
"The --admin parameter must be set for mainnet network. Set an Ethereum address as --admin parameter input."
`Aave Admin address is not set for network: ${network}. Please check the configuration in 'constants.ts'.`
);
}

// If Etherscan verification is enabled, check needed enviroments to prevent loss of gas in failed deployments.
// Check Etherscan configuration if verification flag is set
if (verify) {
checkVerification();
}

console.log("AAVE ADMIN", aaveAdmin);
console.log(`AAVE ADMIN: ${aaveAdmin}`);
console.log(`LEND Token Address: ${lendTokenAddress}`);

// 3. Deployment Steps
console.log(`\n--- Deploying contracts on ${network} ---`);

// Deploy AaveToken (proxied)
await BRE.run(`deploy-${eContractid.AaveToken}`, { verify });

// Deploy LendToAaveMigrator (proxied)
await BRE.run(`deploy-${eContractid.LendToAaveMigrator}`, {
lendTokenAddress,
verify,
});

// 4. Initialization Steps
console.log("\n--- Initializing proxies ---");

// Initialize AaveToken proxy
await BRE.run(`initialize-${eContractid.AaveToken}`, {
admin: aaveAdmin,
onlyProxy: true,
});

// Initialize LendToAaveMigrator proxy
await BRE.run(`initialize-${eContractid.LendToAaveMigrator}`, {
admin: aaveAdmin,
onlyProxy: true,
});

console.log(
"\n✔️ Finished the deployment of the Aave Token Testnet Enviroment. ✔️"
`\n✔️ Finished the deployment and initialization of the Aave Token Testnet environment on ${network}. ✔️`
);
});
```

## 💡 Optimizasyon Gerekçeleri (Optimization Rationale)

1. **Kritik Çelişki Giderildi:** Görev adı olan `"testnet-deployment"` ile uyumlu olması için görevin açıklaması ve bitiş mesajı, açıkça bir test ortamına atıf yapacak şekilde yeniden yazıldı. Bu, yanlış ağda dağıtım riskini ortadan kaldırır.
2. **Yanlış Hata Mesajı Düzeltildi:** Admin adresi eksik olduğunda fırlatılan hata mesajı, kullanıcının `--admin` parametresi yerine **ağ konfigürasyonunu** kontrol etmesini belirtecek şekilde düzeltildi:
```typescript
`Aave Admin address is not set for network: ${network}. Please check the configuration in 'constants.ts'.`