Skip to content

Commit 00d2fdb

Browse files
Merge pull request #52 from keep-network/docs-v2
Document the v1 coverage pool
2 parents c8c233e + fd0f88a commit 00d2fdb

File tree

3 files changed

+297
-0
lines changed

3 files changed

+297
-0
lines changed

README.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ the market. If you need to cover risk in a new system... maybe because you're
5858
building a synthetic asset exchange, or a lending platform — coverage pools
5959
might be for you.
6060

61+
== Getting started
62+
63+
* Read the link:./docs/design.adoc[v1 design documentation].
64+
* For questions and support, join the #keep-protocol channel on
65+
https://discord.gg/4R6RGFf[Discord].
66+
6167
== Build and test
6268

6369
Coverage pool contracts use https://hardhat.org/[*Hardhat*] development
File renamed without changes.

docs/design.adoc

Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,291 @@
1+
= Coverage pool
2+
3+
== Overview
4+
5+
A coverage pool is a flexible new money lego that can be used as a back-stop or
6+
"buyer of last resort" in on-chain financial systems. It is a governable,
7+
fee-earning pool to cover low-likelihood on-chain events.
8+
9+
This document describes the v1, single-asset version of a coverage pool.
10+
11+
v2 of a coverage pool includes a multi-asset coverage and rewards, and is
12+
covered in v2 documentation.
13+
14+
== Components
15+
16+
=== Asset pool
17+
18+
Asset pool accepts a single ERC-20 token as collateral, and returns an
19+
underwriter token. For example, an asset-specific pool might accept
20+
deposits in KEEP in return for covKEEP underwriter tokens. Underwriter tokens
21+
represent an ownership share in the underlying collateral of the asset-specific
22+
pool, including ownership in rewards accrued by the asset pool.
23+
24+
Underwriter tokens natively support meta transactions. This means owners can
25+
authorize a transfer of their underwriter tokens with a signature rather than
26+
an on-chain transaction from their address. The signed message conforms EIP-712
27+
standard, the same one used by Uniswap pool share tokens or MakerDAO DAI tokens.
28+
Anyone can submit the signature on the owner's behalf by calling the EIP-2612
29+
permit function, paying gas fees and possibly performing other actions in the
30+
same transaction.
31+
32+
=== Rewards pool
33+
34+
Rewards pool accepts a single ERC-20 token as a reward and releases it to the
35+
asset pool over time in one-week reward intervals. The owner of the rewards pool
36+
is the reward manager address funding the pool with rewards. The token released
37+
by the reward pool is the same ERC-20 token as the one accepted by the asset
38+
pool as collateral.
39+
40+
=== Coverage pool
41+
42+
Coverage pool is an owner of the asset pool with the right to demand coverage
43+
from the pool. The coverage pool keeps a governable list of approved risk
44+
managers allowed to claim the coverage.
45+
46+
=== Risk manager
47+
48+
Risk manager is a smart contract with the exclusive right to claim coverage
49+
from the coverage pool.
50+
51+
Demanding coverage is akin to filing a claim in traditional insurance and
52+
processing your own claim. The risk manager holds an incredibly privileged
53+
position, because the ability to claim coverage of an arbitrarily large
54+
position could bankrupt the coverage pool.
55+
56+
Because of the nature of the role, the risk manager is a critical component of
57+
the coverage pool. Depending on the implementation, a risk manager can determine
58+
whether to put assets at capped or uncapped risk; how quickly auctions should
59+
put collateral up on offer; whether to end an auction early; and whether to
60+
remunerate existing underwriters in the case of "extra" assets on hand from an
61+
auction.
62+
63+
Coverage is always paid out in the pool's covered asset.
64+
65+
=== Auctions
66+
67+
When the risk manager claims coverage, it specifies an amount denominated in
68+
the asset the pool covers. An auction is opened, increasing the portion of the
69+
pool on offer over time. Eventually, if no offer was taken, the entire coverage
70+
pool is on offer.
71+
72+
For an auction to be filled, a participant pays the asking price, and in return
73+
receives a portion of the asset from the asset pool. An auction can be filled
74+
partially, allowing multiple participants to take the offer.
75+
76+
In addition to claiming coverage and opening an auction, the risk manager
77+
determines the length of the auction, determining its velocity. Risk manager
78+
might decide to end an auction early if coverage is no longer needed.
79+
80+
== Depositing and withdrawing from the pool
81+
82+
Underwriters can deposit into the pool at any time and they can top up their
83+
positions at any time with no initialization period.
84+
85+
There is a fixed, non-governable, two-week withdrawal period for underwriters.
86+
During this period, underwriters are earning rewards but their positions are
87+
also a subject of potential claims of the risk manager.
88+
89+
Before asset pool balance sheet changes during deposit, withdrawal, or claim
90+
operations, asset pool withdraws unlocked rewards from the rewards pool.
91+
This way, asset pool can adjust the number of underwriter (COV) tokens minted so
92+
that new underwriters are not participating in rewards accrued by the pool
93+
before they joined. Also, rewards unlocked by the rewards pool are
94+
"auto-compounding" for the asset pool underwriters:
95+
96+
```
97+
COV_toMint / COV_totalSupply = collateral_toDeposit / collateral_totalDeposited
98+
COV_toMint = collateral_toDeposit * COV_totalSupply / collateral_totalDeposited
99+
```
100+
101+
The three scenarios below illustrate how deposit and withdrawal works, and how
102+
coverage claim affects the asset pool. For simplicity, a two-week withdrawal
103+
period has been omitted.
104+
105+
=== Scenario 1
106+
107+
==== Description
108+
70k KEEP allocated as a weekly reward.
109+
110+
Three underwriters depositing roughly at the same time:
111+
112+
* underwriter 1 depositing 150k KEEP
113+
* underwriter 2 depositing 50k KEEP
114+
* underwriter 3 depositing 200k KEEP
115+
116+
After four days, 40k KEEP rewards unlocked and all three underwriters are
117+
withdrawing from the pool.
118+
119+
==== Earnings
120+
* underwriter 1: 15k KEEP
121+
* underwriter 2: 5k KEEP
122+
* underwriter 3: 20k KEEP
123+
124+
==== Explanation
125+
* underwriter 1 has 150/400 share of the pool (150k out of 400k COV tokens), +
126+
they can claim 150/400 rewards unlocked: 150 / 400 * 40k = 15k
127+
* underwriter 2 has 50/400 share of the pool. (50k out of 400k COV tokens), +
128+
they can claim 50/400 rewards unlocked: 50 / 400 * 40k = 5k
129+
* underwriter 3 has 200/400 share of the pool. (200k out of 400k COV tokens), +
130+
they can claim 200/400 rewards unlocked: 200/400 * 40k = 20k
131+
132+
=== Scenario 2
133+
134+
70k KEEP allocated as a weekly reward.
135+
136+
Three underwriters depositing:
137+
138+
* underwriter 1 depositing 150k KEEP
139+
* underwriter 2 depositing 50k KEEP after 24 hours
140+
* underwriter 3 depositing 200k KEEP after 24 hours
141+
142+
24 hours passes, all three underwriters are withdrawing from the pool.
143+
144+
==== Earnings
145+
* underwriter 1: ~21610 KEEP
146+
* underwriter 2: ~3627 KEEP
147+
* underwriter 3: ~4761 KEEP
148+
149+
==== Explanation
150+
Underwriter 1 is depositing. They receive 150k COV tokens. +
151+
For the first 24 hours, underwriter 1 is the only one in the pool.
152+
They earn 70k / 7 = 10k KEEP.
153+
154+
Underwriter 2 is depositing. There is 150k + 10k KEEP is in the pool at that
155+
time (deposited and rewarded). The pool needs too adjust the amount of COV
156+
tokens minted for underwriter 2 so that they do not take a share of rewards
157+
accrued by the pool so far: COV_minted = 50k * 150k / 160k = 46.87k.
158+
159+
For the next 24 hours. there are two underwriters in the pool and they earn
160+
rewards proportionally to their share in the pool:
161+
162+
* underwriter 1: 150 / 196.87 * 10k = 7619.24 KEEP
163+
* underwriter 2: 46.87 / 196.87 * 10k = 2380.75 KEEP
164+
165+
Underwriter 3 is depositing. 150k + 10k + 50k + 10k is in the pool at that time
166+
(deposited and rewarded). The pool needs to adjust the amount of COV tokens
167+
minted for underwriter 3 so that they do not take a share of rewards accrued by
168+
the pool so far: COV_minted = 200k * 196.87k / 220k = 178.97k.
169+
170+
For the next 24 hours, there are three underwriters in the pool and they earn
171+
rewards proportionally to their share:
172+
173+
- underwriter 1: 150 / 375.84 * 10k = 3991.06 KEEP
174+
- underwriter 2: 46.87 / 375.84 * 10k = 1247.07 KEEP
175+
- underwriter 3: 178.97 / 375.84 * 10k = 4761.86 KEEP
176+
177+
In total, underwriters earn:
178+
179+
- underwriter 1: 10k + 7619.24 + 3991.06 = 21610.3 KEEP
180+
- underwriter 2: 2380.75 + 1247.07 = 3627.82 KEEP
181+
- underwriter 3: 4761.86 KEEP
182+
183+
184+
=== Scenario 3
185+
186+
This scenario is an extension of Scenario 2 with an additional claim for
187+
50k KEEP tokens from the coverage pool at the end.
188+
189+
There is 430k KEEP in the pool (deposited + rewards):
190+
191+
* underwriter 1 has 150 / 375.84 = 0.399 of the pool (= (150k + 21 610) / 430k))
192+
* underwriter 2 has 46.87 / 375.84 = 0.124 of the pool (= (50k + 3 627) / 430k))
193+
* underwriter 3 has 178.97 / 375.84 = 0.476 of the pool (= (200k + 4 761) / 430k))
194+
195+
The coverage pool claims 50k KEEP and all underwriters withdraw their funds
196+
right after.
197+
198+
==== Earnings
199+
- underwriter 1: 1655 KEEP
200+
- underwriter 2: -2608 KEEP
201+
- underwriter 3: -19048 KEEP
202+
203+
==== Explanation
204+
205+
Coverage pool loses 50k KEEP. Underwriters are expected to take a hit
206+
proportionally to their share of the pool:
207+
208+
* underwriter 1: -50k * 150 / 375.84 = -19955 KEEP
209+
* underwriter 2: -50k * 46.87 / 375.84 = -50k * 0.124 = -6235 KEEP
210+
* underwriter 3: -50k * 178.97 / 375.84 = -50k * 0.476 = -23809 KEEP
211+
212+
In total, underwriters earn/lose:
213+
214+
* underwriter 1: 21610 - 19955 = 1655 KEEP
215+
* underwriter 2: 3627 - 6235 = -2608 KEEP
216+
* underwriter 3: 4761 - 23809 = -19048 KEEP
217+
218+
== tBTC v1 risk manager
219+
220+
tBTC v1 risk manager will be the first implementation of a risk manager approved
221+
by the coverage pool. The coverage pool will contribute to potentially lowering
222+
collateral ratios and scaling tBTC’s TVL. The coverage pool serves as a buyer
223+
of last resort. It purchases enough TBTC on auction to make the depositor whole
224+
in the event of liquidation if the stakers' collateral is not sufficient.
225+
226+
In case of liquidation of a tBTC deposit below a certain collateralization
227+
threshold, the risk manager opens an auction to acquire TBTC to purchase signer
228+
bonds. Collateralization threshold and auction length are governable parameters.
229+
230+
ETH purchased by the risk manager from tBTC signer bonds is swapped and
231+
transferred to the asset pool and there are two strategies for doing that:
232+
233+
* ETH is automatically swapped to asset pool underlying token on Uniswap,
234+
* ETH is deposited in the escrow contract allowing the governance to do the swap
235+
manually and deposit the underlying token to the asset pool.
236+
237+
Which strategy is used is a governable parameter.
238+
239+
In case signer bonds were purchased by a third party before the auction was
240+
fully filled, TBTC acquired by the risk manager from potential partial auction
241+
takes will be used in the future, to purchase signer bonds once the accumulated
242+
surplus value allows for it. For example:
243+
244+
* Liquidation of 1 TBTC deposit, auction opened for 1 TBTC and early closed
245+
after being filled for 0.3 TBTC total. 0.3 TBTC goes to the risk manager.
246+
* Liquidation of 1 TBTC deposit, auction opened for 1 TBTC and early closed
247+
after being filled for 0.8 TBTC total. 0.8 TBTC goes to the risk manager.
248+
* Liquidation of 1 TBTC deposit, there is 1.1 TBTC in the surplus, instead of
249+
opening an auction, risk manager purchases signer bonds reducing the surplus
250+
to 0.1 TBTC.
251+
252+
== Upgradeability
253+
254+
All coverage pool contracts are non-upgradeable and there are few governable
255+
parameters listed in the next section. Underwriters can migrate to a new version
256+
of coverage pool by moving their collateral to a new asset pool approved by the
257+
governance.
258+
259+
== Governance
260+
261+
The governance included in the system design follows two principles:
262+
263+
* All governance should abide by a time delay, giving users time to respond
264+
to changes in the system.
265+
* The governance role should be assignable to a credibly neutral third party or
266+
eventual decentralization, such as the community multisig.
267+
268+
.Governable parameters
269+
|===
270+
|Parameter |Time delay|Description
271+
272+
|Approved risk managers
273+
|30 days
274+
|Governance can approve and unapprove a risk manager.
275+
276+
|Auction length
277+
|12 hours
278+
|Governance can adjust auction length based on coverage pool TVL and the minimum
279+
possible auctioned value.
280+
281+
|tBTC deposit collateralization
282+
|12 hours
283+
|Governance can set the maximum collateralization level of tBTC deposit under
284+
the liquidation the tBTC v1 risk manager is going to open an auction for. The
285+
risk manager is a buyer of the last resort and should not work with tBTC
286+
liquidating deposits still attractive for arbitraging bots.
287+
288+
|The strategy for depositing purchased tBTC signer bonds
289+
|12 hours
290+
|Governance can chose which strategy should be used by tBTC v1 risk manager for
291+
depositing ETH signer bonds purchased from tBTC to the asset pool.

0 commit comments

Comments
 (0)