Skip to content

Commit

Permalink
Fixed Hardhat curveSwap task
Browse files Browse the repository at this point in the history
  • Loading branch information
naddison36 committed Oct 21, 2024
1 parent 32a1ef1 commit 1c030d0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
8 changes: 4 additions & 4 deletions contracts/tasks/amoStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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, {
Expand Down Expand Up @@ -331,7 +331,7 @@ 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);
}
Expand All @@ -355,7 +355,7 @@ 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);
Expand All @@ -380,7 +380,7 @@ 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);
Expand Down
12 changes: 9 additions & 3 deletions contracts/tasks/curve.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,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,
Expand All @@ -330,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
Expand Down
2 changes: 1 addition & 1 deletion contracts/tasks/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit 1c030d0

Please sign in to comment.