> For the complete documentation index, see [llms.txt](https://crafting-finance.gitbook.io/crafting-finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://crafting-finance.gitbook.io/crafting-finance/white-paper/major-modules/kingsman/how-to-calculate-profit-or-loss.md).

# How to calculate profit or loss

![](https://810882225-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgM337tO_IkXKTfqkZI%2Fuploads%2FqBH6nQiA5xSiuzNRpqs6%2Fimage.png?alt=media\&token=b8330f26-af05-4ccf-9639-f5838f52d69d)

Bellows are two examples to illustrate how we calculate profit or loss using SDP trading mode.

&#x20;**Example 4**: Assuming two users A and B, A generates $100 rBTC, and B generates $100 rUSD, the respective debt ratio is 50%, and the total system debt is $200.  Suppose the price of BTC rises by 50%, so the value of rBTC held by A becomes $150, and the value of rUSD held by B is still $100. At this time, the total system liability becomes $150+$100=$250.  Note that because the debt ratio has not changed, A’s debt is $250\*50%=$125, and B’s debt is also $125.  Therefore, it can be calculated that the profit or loss of A is $150-$125=$25, and the profit or loss of B is $100- $125=-$25.  The sum of all users' profit and loss in the entire system is 0, which is similar to a traditional contract trading system.&#x20;

It should be noted that although B did nothing after generating rUSD, he/she still lost money due to the increase in the price of BTC.  This is because rUSD is generated, which by default is equivalent to becoming a long position in the U.S. dollar (in this case, it is also equivalent to a short position in BTC)! We define this loss as "crafting loss".

&#x20;**Example 5**: Suppose that following the assumption in example 4, now A holds $150 rBTC, and B holds $100 rUSD.  Now suppose that there is a new user C, who generates rUSD of $100, and calculates the new debt ratio.  Note that the total debt of A and B is now $250 instead of $200 in the initial state!  Therefore, after C's operation, the total debt of the system becomes $350.  The ratio of A is $125/$350=35.71%, the ratio of B is $125/$350=35.71%, and the ratio of C is $100/$350=28.57%.
