Getting Started

dpack is a package management tool for working with EVM smart contracts. It pins “packs”, lightweight files pointing to multiple types and objects which may or may not be dependencies of some core object.

The important thing with dpack is that you can quickly access an environment with a smart contract system and all of its dependencies by supplying an IPFS Content ID that looks something like bafkreihqad3xblizwul5mapncataszn2syjdbpzib6fuvzyz3spvdtuayi.

Loading RCS0

You’ll need ipfs.

Clone the starter repository:

$ git clone
$ cd ricobank-example
$ npm i

Start the hardhat node console and load the pack:

$ npx hardhat --network arbitrum console

> ali = await ethers.getSigner()
> ALI = ali.address

> rcs0cid = 'bafkreihqad3xblizwul5mapncataszn2syjdbpzib6fuvzyz3spvdtuayi'

> dpack = require('@etherpacks/dpack')

> dapp = await dpack.load(rcs0cid, ethers, ali)

Creating a CDP

With LINK Collateral

Suppose you have some LINK on Arbitrum that you got from a DEX. Then you can create a CDP:

> { bank, link } = dapp
> BANK = bank.address
> { b32, wad } = require('minihat')

> await link.approve(BANK, wad(200))

> dink = ethers.utils.defaultAbiCoder.encode(['int'], [wad(200)])

> dart = wad(1)

> await bank.frob(b32('link'), ALI, dink, dart)

wad multiplies the number by 10 ^ 18. If all went well, you should have some Rico. If frob failed, try increasing dink (to increase collateralization) or dart (to raise debt above the minimum amount). Negative dink removes collateral, and negative dart pays down debt.

With UniswapV3 Position NFT Collateral

Suppose you created a UniswapV3 position in a LINK-USDC pool. Then you can create an NFT-backed CDP:

> await dapp.nonfungiblePositionManager.approve(BANK, tokenId)

> dir  = 1

> dink = ethers.utils.defaultAbiCoder.encode(['uint[]'], [[dir, tokenId]])

> dart = wad(1)

> await bank.frob(b32(':uninft'), ALI, dink, dart)

To remove the position, dir = -1.