Created
May 21, 2021 19:58
-
-
Save dukedorje/610f4871140a4e74526e38e61f10fa14 to your computer and use it in GitHub Desktop.
Manually withdraw staked k-tokens from KeeperDAO Legacy app with Hardhat
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
// Set up Hardhat project. | |
// Download the source code from etherscan: https://etherscan.io/address/0x35ffd6e268610e764ff6944d07760d0efe5e40e5#code | |
// and compile | |
// kTokens: | |
/* | |
kETH: 0x179212cb86D0eE6A4dfb2AbB1CF6A09feE0A9525 | |
kwETH: 0x834CAcd6425fA6c7126b028B3d1E4cda53EB7257 | |
kDAI: 0x8EE17Fa30D63ebD66e02205B1DF2f30D60a5CA30 | |
kBTC: 0x77565202D78a6EDA565c7DC737FF1d8E64fd672a | |
kUSDC: 0x3045312Fb54f00f43d6607999e387Db58FFb4cF4 | |
*/ | |
// Export the private key from Metamask, etc, and put it in your hardhat config: | |
module.exports = { | |
defaultNetwork: "mainnet", | |
networks: { | |
mainnet: { | |
url: "https://eth-mainnet.alchemyapi.io/v2/my_api_key", | |
chainId: 1, | |
accounts: [ | |
"0xmy_private_key", | |
], | |
}, | |
}, | |
solidity: { | |
compilers: [{ version: "0.5.12" }], | |
}, | |
}; | |
// here's the task: | |
task("rook", "Withdraw ktokens", async (args, hre) => { | |
const account = (await hre.ethers.getSigners())[0]; | |
console.log("From:", account.address); | |
// whichever token you use goes here | |
const kUsdc = await hre.ethers.getContractAt( | |
"IKToken", | |
"0xac826952bc30504359a099c3a486d44e97415c77" | |
); | |
const bal = await kUsdc.balanceOf(account.address); | |
console.log("Balance", hre.ethers.utils.formatUnits(bal, 6), "kUSDC"); | |
console.log("Underlying:", await kUsdc.underlying()); | |
const liqPool = await hre.ethers.getContractAt( | |
"LiquidityPoolV2", | |
"0x35fFd6E268610E764fF6944d07760D0EFe5E40E5" | |
); | |
// withdraw(address payable _to, IKToken _kToken, uint256 _kTokenAmount) | |
const tx = await liqPool.withdraw(account.address, kUsdc.address, bal); | |
console.log(tx); | |
const mined = await tx.wait(); | |
console.log(mined); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I saw your post above....but it is way above my abilities....I'm a relative newbie.
I have some kETH (0xC4c43C78fb32F2c7F8417AF5af3B85f090F1d327) in my metamask wallet (eth that I staked a few years back) and I have no idea how to swap them back to regular eth.
Zapper.xyz say it is a V2 pool.
Any ideas? Thanks for any help you may have for me.
[email protected]
metamask: 0x6Ae9B6361dD35D7DDe77a09e4BB96B4e2Fa05aC3