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 module to simplify payments directly to Dai Surplus Buffer.
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.
This module provides a contract which can:
- Receive Dai as the destination of a
transfer
call. - 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.
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 theJar
to the Surplus Buffer. Any Dai sent directly to it will simply accumulate until someone calls this function.
Effectively the 2 functions above will:
- Burn ERC-20 Dai
- Credit the due amount to the
Vow
’s balance in theVat
.
Jar
s 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.
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
andadress 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
- For the official MCD deployments (Goerli and Mainnet), go to the chainlog and look for:
Installs all node.js deps.
Usage:
make nodejs-deps
Builds the current project with the predefined settings with forge build
.
Usage:
make build
Runs all tests with forge test
.
ETH_RPC_URL
environment variable pointing to a valid Goerli node before running it.
Usage:
make build
Deploys a new JarFactory
instance and verifies it.
Usage:
make deploy
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
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")"