Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.
/ dss-jar Public archive

MCD module to allow payments directly into the surplus buffer

License

Notifications You must be signed in to change notification settings

dewiz-xyz/dss-jar

Repository files navigation

⚠️⚠️⚠️

THIS REPOSITORY IS EXPERIMENTAL AND SHOULD NOT BE USED AS IT IS.
FOR NOW IT HAS BEEN ARCHIVED AND WILL BE KEPT ONLY AS A REFERENCE.

If you are looking for how to make payments of stability fees directly into the surplus buffer in the context of Real World Assets (RWA), please refer to mip21-toolkit.

⚠️⚠️⚠️

DSS Jar

DSS module to simplify payments directly to Dai Surplus Buffer.

Why?

The Surplus Buffer is not a "first-class citizen" in DSS. It exists only as a concept, however there is no address to which one can send Dai to in order to increase the surplus buffer.

What?

This module provides a contract which can:

  1. Receive Dai as the destination of a transfer call.
  2. Pull Dai from the users wallet and send it directly to the Surplus Buffer.

For 1., an additional transaction is required to actually send Dai to the Surplus Buffer, since currently Dai sticks to simple ERC-20 semantics and does not allow contracts to react when they receive.

How?

A Jar implements the following interface:

interface JarLike {
  function toss(uint256 wad) external;

  function void() external;
}
  • toss(uint256 wad): pulls Dai from the sender’s wallet and send it to the Surplus Buffer atomically.
  • void(): flushes any Dai balance of the Jar to the Surplus Buffer. Any Dai sent directly to it will simply accumulate until someone calls this function.

Effectively the 2 functions above will:

  1. Burn ERC-20 Dai
  2. Credit the due amount to the Vow’s balance in the Vat.

Use Cases

RWA Stability Fee Collection

Jars make it easier for off-chain collateral deals (RWA) to differentiate stability fee payments from collateral repayments. Each deal can have a different Jar instance to collect stability fees off-chain, while the accounting mechanism of the vault is made simpler by setting Stability Fees to 0.

RWA partners can simply send Dai to the Jar address related to the deal and someone will periodically and permissionlessly flush the Dai to the Surplus Buffer.

...

Usage

Jar instances can be easily created by the companion factory JarFactory. Look for JAR_FAB in DSS chainlog for the official MCD deployments (Goerli and Mainnet) or in this reference file for CES MCD on Goerli:

interface JarFactoryLike {
  function createJar(
    bytes32 ilk,
    address daiJoin,
    address vow
  ) external returns (Jar);
}

This factory allows creating 1 Jar per ilk (collateral type) in DSS.

To obtain the parameters you can:

  • bytes32 ilk
    cast --from-ascii 'RWA010-A' # change to the actual ILK representing the deal
    
  • address daiJoin and adress vow
    • For the official MCD deployments (Goerli and Mainnet), go to the chainlog and look for:
      • MCD_DAI_JOIN
      • MCD_VOW
    • For CES MCD on Goerli, go to the reference file and look for:
      • MCD_DAI_JOIN
      • MCD_VOW

Scripts

make nodejs-deps

Installs all node.js deps.

Usage:

make nodejs-deps

make build

Builds the current project with the predefined settings with forge build.

Usage:

make build

make test

Runs all tests with forge test.

⚠️ ATTENTION: This project requires testing with forking mode. Make sure to set the ETH_RPC_URL environment variable pointing to a valid Goerli node before running it.

Usage:

make build

make deploy

Deploys a new JarFactory instance and verifies it.

Usage:

make deploy

make create-jar

Creates a new Jar instance from a given JarFactory.

Usage:

make create-jar factory='<FACTORY_ADDRESS>' \
  ilk=$(cast --from-ascii '<ILK_NAME>') \
  dai_join=$MCD_JOIN_DAI \
  vow=$MCD_VOW

make verify

Verifies a contract in Etherscan.

Usage:

# Without constructor args:
make verify \
  address=<address> \
  contract=src/JarFactory.sol:JarFactory

# With constructor args:
make verify \
  address=<address> \
  contract=src/Jar.sol:Jar \
  verify_opts="--constructor-args=\$(cast abi-encode 'constructor(address,address)' "$MCD_JOIN_DAI" "$MCD_VOW")"

Contributing

Dependencies

Dev Dependencies

About

MCD module to allow payments directly into the surplus buffer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published