YBX issuance is the process by which platform YBX incentives are paid out to protocol lenders (only lenders with collateralized deposits receive YBX incentives), borrowers, and escrowers. Issuance is paid out daily and tracked and distributed with 2 different processes, Issuance Tracking and YBX Claims.
Issuance tracking tracks the amount of YBX that should be distributed to each user on a given issuance period(day). To do so, the protocol uses issuance tracker trades made by the UPDATE operation in the Claim contract. The issuance tracker trades track a pool or liability tokens issuance ratio, or the amount of YBX issued per pool or liability token of that type for the given issuance period. These trades exchange an assets issuance ratio tracker token for its issuance shift tracker token. The trades track the issuance ratio floating point style, the amount of ratio tokens sold is equal to the mantissa of the issuance ratio, and the amount of shift tokens sold is equal to that mantissa's exponential. The exponential amount is added to 15 to avoid numbers less than 0.
For example, if a pool tokens issuance ratio for a period is 12.1, the issuance trade will exchange 1.21 ratio tracker tokens for 14 shift tracker tokens.
Users claim YBX accrued to a given position whenever they modify the position or run the CLAIM operation in the Claim contract. To calculate accrued YBX, the protocol uses the following process
Check the last block the claimable balance for the position was modified.
Pull every trade involving the ratio and shift assets associated with the protocol token representing that position made after the block found in step 1.
Calculate the amount of YBX accrued by taking the sum of the following:
The position size multiplied by the most recent issuance trade ratio times the percent of the current period that has elapsed
The sum of each trade ratio in the set except the most recent one times the position size
The farthest back issuance trade ratio multiplied by the position size times the percent of the period that elapsed between when the position was modified and when the farthest back trade occurred.
We'll provide an example below:
Position: 100,000 l00XLM liability Position - last updated on 12/12/2021 - 12:00 UTC - Event timestamp is 12/15/2021 - 18:00 UTC
Astute observers will have noticed this can result in users missing out on a small amount of issuance if they modify a position many times during one issuance period. This is an unfortunate side effect of us being unable to overload the Claim contract with API calls.