🏛️AF2.0 Repurchasing Guide
Note: Anyone can become a repurchaser. No whitelisting is required.
Repurchasing Criteria
Once the money market sub-account is underwater, the account is publicly open to be repurchased.
To determine if the sub-account is underwater, the sub-account’s borrowing power (risk-adjusted collateral value) must be less than used borrowing power (risked-adjusted borrowed value).
Checking eligibility
To easily retrieve the data of the sub-account, you can call our view-only contract using the signature as follow:
moneyMarketReader: 0x4913DEC75cC0e061Ba78ebbDb2584905760be4C6
mmDiamond: 0x7389aaf2e32872cABD766D0CEB384220e8F2A590
mmAccountManager: 0xD20B887654dB8dC476007bdca83d22Fa51e93407
![](https://docs.alpacafinance.org/~gitbook/image?url=https%3A%2F%2F161395342-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MU6Wanx5w-7VGZNflCi-887967055%252Fuploads%252FJ7j2Mkj73SNa2SIXD2g1%252FScreen%2520Shot%25202566-04-26%2520at%252016.42.12.png%3Falt%3Dmedia%26token%3Ddb8ab862-c0e0-41ad-9db1-090b2d364d39&width=768&dpr=4&quality=100&sign=be830d37&sv=1)
The SubAccountSummary struct is as follow
![](https://docs.alpacafinance.org/~gitbook/image?url=https%3A%2F%2F161395342-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MU6Wanx5w-7VGZNflCi-887967055%252Fuploads%252F8BJrUgFW2wYbTEj9zC20%252FScreen%2520Shot%25202566-04-26%2520at%252016.55.18.png%3Falt%3Dmedia%26token%3D255cc5a9-671e-4a52-9f92-14a083a242bc&width=768&dpr=4&quality=100&sign=66f4499c&sv=1)
Close factor
The close factor determines how much used borrowing power can be removed from the sub-account by repurchasing.
Example: Given
close factor = 50%,
USDC borrow factor = 0.9
BUSD borrow factor = 0.8
USDC debt = $500
BUSD debt = $1000
Used borrowing power = (1000 / 0.9) + (500 / 0.8) = 1736.1111111111
The maximum used borrowing power that can be removed = 1736.1111111111 / 2 = 868.05555555555
BUSD can only be repurchased 868.05555555555 * 0.9 => 781.249999999995
USDC can only be repurchased 868.05555555555 * 0.8 => 694.44444444444
Since USDC debt is only $500, all of it can be repurchased
Executing Repurchase
In order to initiate the repurchase process, the repurchaser will need to call the following function @ 0x… (MMDiamond)
![](https://docs.alpacafinance.org/~gitbook/image?url=https%3A%2F%2F161395342-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MU6Wanx5w-7VGZNflCi-887967055%252Fuploads%252FTFAy1KWxbhAP9MGNTu84%252FScreen%2520Shot%25202566-04-26%2520at%252016.56.53.png%3Falt%3Dmedia%26token%3Dd4c5020a-6239-4f87-be5c-aea388c7e813&width=768&dpr=4&quality=100&sign=43236f2d&sv=1)
Repurchaser need to specify the debt token to be repaid in exchange of which collateral token.
By using the aforementioned example,
Given:
close factor = 50%
USDC borrow factor = 0.9
BUSD borrow factor = 0.8
USDC debt = $500
BUSD debt = $1000
ibBNB collateral factor = 0.8
ibBNB priced at 300
4 ibBNB were posed as collaterals
Repurchase reward rate = 5%
Repurchaser can repurchase 600 BUSD debt, which equivalent to 2 ibBNB by calling
![](https://docs.alpacafinance.org/~gitbook/image?url=https%3A%2F%2F161395342-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MU6Wanx5w-7VGZNflCi-887967055%252Fuploads%252F4wSdS3YC8urTtNBr8Qe2%252FScreen%2520Shot%25202566-04-26%2520at%252016.58.22.png%3Falt%3Dmedia%26token%3Da154c52c-06c0-4f83-a81a-e8dc80020f04&width=768&dpr=4&quality=100&sign=a5f2202d&sv=1)
Expecting to get 2 ibBNB * 105% = 2.10 ibBNB in return.
Converting ibToken to Token
In order to withdraw the ibToken from AF2.0, the repurchaser can call the following function @ 0x… (AccountManager)
![](https://docs.alpacafinance.org/~gitbook/image?url=https%3A%2F%2F161395342-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MU6Wanx5w-7VGZNflCi-887967055%252Fuploads%252FLzl33zuIIrLzls229SCy%252FScreen%2520Shot%25202566-04-26%2520at%252016.59.03.png%3Falt%3Dmedia%26token%3D38b96c2e-a7df-493c-87e4-23ec99454e84&width=768&dpr=4&quality=100&sign=3ba76391&sv=1)
Last updated