Flash liquidation bot and stats printer for Rico Credit System 0.
On liquidation, keeper
calls strat.fill_flip
, which flash borrows Rico to fill the liquidation. fill_flip
then:
(a) if the ilk is erc20, trades the tokens through UniswapV3 for Rico to pay down the loan, or
(b) if the ilk is univ3, collects the tokens from the Uniswap positions and trades them through UniswapV3 to pay down the loan. It stops collecting tokens from Uniswap positions when it has enough Rico, so the user ends up with some ERC20 tokens and some UniswapV3 positions containing ERC20 tokens.
You need ipfs daemon running.
npm run initialize
npx hardhat --network <network> console
In hardhat console:
dpack = require('@etherpacks/dpack')
ali = await ethers.getSigner()
pack = await hre.run('deploy-strat', { netname: <name of packfile's network>, writepack: 'true', tokens: <tokens_path> }
dapp = await dpack.load(pack, ethers, ali)
In hardhat console:
{runKeeper, printStats} = require('./keeper')
await runKeeper('./args.json', ali)
args.json
has the following elements:
netname
: the lowercase network name ('arbitrum')ricopack
: IPFS CID pointing to core rico credit system packaggpack
: IPFS CID pointing to chainlink aggregators packfliptime
: Time between ilk scans in msaggs
: Object mapping chainlink data feed pair -> array of feeds to update when the aggregator updatesflip
: true if bailing urns, false if just collecting stats
To display urn stats:
printStats()