diff --git a/contracts/tasks/amoStrategy.js b/contracts/tasks/amoStrategy.js index 4ae72dd546..d9ca81df81 100644 --- a/contracts/tasks/amoStrategy.js +++ b/contracts/tasks/amoStrategy.js @@ -13,6 +13,7 @@ const { displayPortion, displayRatio, } = require("./curve"); +const { logTxDetails } = require("../utils/txLogger"); const log = require("../utils/logger")("task:curve"); @@ -49,7 +50,7 @@ async function amoStrategyTask(taskArguments) { vault, } = await curveContracts(poolOTokenSymbol); - // Strategy's Metapool LPs in the Convex pool + // Strategy's Curve LPs in the Convex pool const vaultLPsBefore = diffBlocks && (await cvxRewardPool.balanceOf(amoStrategy.address, { @@ -83,9 +84,9 @@ async function amoStrategyTask(taskArguments) { diffBlocks && oTokenSupplyBefore.sub(strategyOTokensInPoolBefore); const vaultAdjustedTotalSupply = oTokenSupply.sub(strategyOTokensInPool); - // Strategy's Metapool LPs in the Convex pool + // Strategy's LPs in the Convex pool output( - `\nvault Metapool LPs : ${displayPortion( + `\nStrategy's Curve LPs : ${displayPortion( vaultLPs, totalLPs, poolLPSymbol, @@ -94,7 +95,7 @@ async function amoStrategyTask(taskArguments) { ); // Strategy's share of the assets in the pool output( - `assets owned by strategy : ${displayPortion( + `Assets owned by strategy : ${displayPortion( strategyAssetsInPool, vaultAdjustedTotalValue, assetSymbol, @@ -112,7 +113,7 @@ async function amoStrategyTask(taskArguments) { strategyOTokensInPool, vaultAdjustedTotalValue, oTokenSymbol, - "OToken supply" + "adjusted vault value" )} ${displayDiff( diffBlocks, strategyOTokensInPool, @@ -120,7 +121,7 @@ async function amoStrategyTask(taskArguments) { )}` ); const stratTotalInPool = strategyAssetsInPool.add(strategyOTokensInPool); - output(`both owned by strategy : ${formatUnits(stratTotalInPool)}`); + output(`Both owned by strategy : ${formatUnits(stratTotalInPool)}`); // Strategy asset values let totalStrategyAssetsValueBefore = BigNumber.from(0); @@ -151,7 +152,7 @@ async function amoStrategyTask(taskArguments) { strategyAssetsValueScaled ); output( - `strategy ${symbol.padEnd(4)} value : ${displayPortion( + `Strategy ${symbol.padEnd(4)} value : ${displayPortion( strategyAssetsValueScaled, vaultTotalValue, symbol, @@ -164,7 +165,7 @@ async function amoStrategyTask(taskArguments) { ); } output( - `strategy total value : ${displayPortion( + `Strategy total value : ${displayPortion( totalStrategyAssetsValue, vaultTotalValue, assetSymbol, @@ -186,7 +187,7 @@ async function amoStrategyTask(taskArguments) { strategyOTokensInPool ); output( - `strategy adjusted value : ${displayPortion( + `Strategy adjusted value : ${displayPortion( strategyAdjustedValue, vaultAdjustedTotalValue, assetSymbol, @@ -206,6 +207,7 @@ async function amoStrategyTask(taskArguments) { )}` ); + console.log(""); for (const asset of assets) { const assetsInVaultBefore = diffBlocks && @@ -226,10 +228,11 @@ async function amoStrategyTask(taskArguments) { ) ); } + // Vault's total value v total supply output( displayProperty( - "\nOToken total supply", + "\nOToken total supply ", oTokenSymbol, oTokenSupply, oTokenSupplyBefore @@ -237,17 +240,17 @@ async function amoStrategyTask(taskArguments) { ); output( displayProperty( - "vault assets value", + "Vault assets value", assetSymbol, - totalStrategyAssetsValue, - totalStrategyAssetsValueBefore + vaultTotalValue, + vaultTotalValueBefore ) ); output( - `total value - supply : ${displayRatio( - totalStrategyAssetsValue, + `Total value - supply : ${displayRatio( + vaultTotalValue, oTokenSupply, - totalStrategyAssetsValueBefore, + vaultTotalValueBefore, oTokenSupplyBefore )}` ); @@ -262,14 +265,14 @@ async function amoStrategyTask(taskArguments) { ); output( displayProperty( - "vault adjusted value", + "Vault adjusted value", assetSymbol, vaultAdjustedTotalValue, vaultAdjustedTotalValueBefore ) ); output( - `adjusted value - supply : ${displayRatio( + `Adjusted value - supply : ${displayRatio( vaultAdjustedTotalValue, vaultAdjustedTotalSupply, vaultAdjustedTotalValueBefore, @@ -288,7 +291,7 @@ async function amoStrategyTask(taskArguments) { output( displayProperty( - "\nNet minted for strategy", + "\nNet minted for strategy ", assetSymbol, netMintedForStrategy ) @@ -329,9 +332,10 @@ async function mintAndAddOTokensTask(taskArguments) { const signer = await getSigner(); const amountUnits = parseUnits(amount.toString()); - log(`Minting ${formatUnits(amountUnits)} ${symbol} and adding to Metapool`); + log(`Minting ${formatUnits(amountUnits)} ${symbol} and adding to Curve pool`); - await amoStrategy.connect(signer).mintAndAddOTokens(amountUnits); + const tx = await amoStrategy.connect(signer).mintAndAddOTokens(amountUnits); + await logTxDetails(tx, "mintAndAddOTokens"); } async function removeAndBurnOTokensTask(taskArguments) { @@ -353,10 +357,13 @@ async function removeAndBurnOTokensTask(taskArguments) { log( `Remove OTokens using ${formatUnits( amountUnits - )} ${symbol} Metapool LP tokens and burn the OTokens` + )} ${symbol} Curve LP tokens and burn the OTokens` ); - await amoStrategy.connect(signer).removeAndBurnOTokens(amountUnits); + const tx = await amoStrategy + .connect(signer) + .removeAndBurnOTokens(amountUnits); + await logTxDetails(tx, "removeAndBurnOTokens"); } async function removeOnlyAssetsTask(taskArguments) { @@ -378,10 +385,11 @@ async function removeOnlyAssetsTask(taskArguments) { log( `Remove ETH using ${formatUnits( amountUnits - )} ${symbol} Metapool LP tokens and add to ${symbol} Vault` + )} ${symbol} Curve LP tokens and add to ${symbol} Vault` ); - await amoStrategy.connect(signer).removeOnlyAssets(amountUnits); + const tx = await amoStrategy.connect(signer).removeOnlyAssets(amountUnits); + await logTxDetails(tx, "removeOnlyAssets"); } module.exports = { diff --git a/contracts/tasks/curve.js b/contracts/tasks/curve.js index 02945bdde2..88c1bed08c 100644 --- a/contracts/tasks/curve.js +++ b/contracts/tasks/curve.js @@ -137,8 +137,19 @@ async function curvePool({ // Total Metapool assets const totalBalances = poolBalances[0].add(poolBalances[1]); + const excessAssetsBefore = + diffBlocks && + (poolBalancesBefore[1].gt(poolBalancesBefore[0]) + ? poolBalancesBefore[1].sub(poolBalancesBefore[0]) + : poolBalancesBefore[0].sub(poolBalancesBefore[1])); + const excessAssets = poolBalances[1].gt(poolBalances[0]) + ? poolBalances[1].sub(poolBalances[0]) + : poolBalances[0].sub(poolBalances[1]); + const excessAssetsSymbol = poolBalances[1].gt(poolBalances[0]) + ? oTokenSymbol + : assetSymbol; output( - `total assets in pool : ${displayPortion( + `Total assets in pool : ${displayPortion( poolBalances[0], totalBalances, assetSymbol, @@ -147,7 +158,7 @@ async function curvePool({ )} ${displayDiff(diffBlocks, poolBalances[0], poolBalancesBefore[0])}` ); output( - `total OTokens in pool : ${displayPortion( + `Total OTokens in pool : ${displayPortion( poolBalances[1], totalBalances, oTokenSymbol, @@ -155,6 +166,15 @@ async function curvePool({ 4 )} ${displayDiff(diffBlocks, poolBalances[1], poolBalancesBefore[1])}` ); + output( + displayProperty( + `Excess assets`, + `${excessAssetsSymbol}`, + excessAssets, + excessAssetsBefore, + 4 + ) + ); return { totalLPsBefore, @@ -280,17 +300,22 @@ async function curveSwapTask(taskArguments) { const signer = await getSigner(); - const fromAmount = parseUnits(from.toString()); + const fromAmount = parseUnits(amount.toString()); const minAmount = parseUnits(min.toString()); - log(`Swapping ${formatUnits(fromAmount)} ${from}`); const fromIndex = from === "ETH" || from === "3CRV" ? 0 : 1; const toIndex = from === "ETH" || from === "3CRV" ? 1 : 0; const override = from === "ETH" ? { value: amount } : {}; + + log( + `Swapping ${formatUnits( + fromAmount + )} ${from} from index ${fromIndex} to index ${toIndex}` + ); // prettier-ignore await pool - .connect(signer).exchange( + .connect(signer)["exchange(int128,int128,uint256,uint256)"]( fromIndex, toIndex, fromAmount, @@ -310,6 +335,7 @@ async function curveContracts(oTokenSymbol) { oTokenSymbol === "OETH" ? addresses.mainnet.CurveOETHMetaPool : addresses.mainnet.CurveOUSDMetaPool; + log(`Resolved ${oTokenSymbol} Curve pool to ${poolAddr}`); const strategyAddr = oTokenSymbol === "OETH" ? addresses.mainnet.ConvexOETHAMOStrategy diff --git a/contracts/tasks/tasks.js b/contracts/tasks/tasks.js index dc5c7e2c7b..00ef4f00a7 100644 --- a/contracts/tasks/tasks.js +++ b/contracts/tasks/tasks.js @@ -817,7 +817,7 @@ subtask( ) .addParam( "amount", - "Amount of Metapool LP tokens to burn for removed OTokens", + "Amount of Curve LP tokens to burn for removed OTokens", 0, types.float )