> For the complete documentation index, see [llms.txt](https://docs.gooddollar.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gooddollar.org/previous-protocol-versions/protocol-v3/core-contracts-and-api/contributioncalculation.md).

# ContributionCalculation

### Events

#### SellContributionRatioUpdated

Emits when the contribution ratio is updated.

<table><thead><tr><th width="320.9082692632695">Parameter name</th><th>Annotation</th></tr></thead><tbody><tr><td>caller</td><td>The address of the Avatar.</td></tr><tr><td>nom</td><td>The nominator of the ratio.</td></tr><tr><td>denom</td><td>The denominator of the ratio.</td></tr></tbody></table>

```
event SellContributionRatioUpdated(
    address indexed caller, 
    uint256 nom, 
    uint256 denom
);
```

### calculateContribution

Calculate the amount after contribution during the sell action. There is a `sellContributionRatio` percent contribution.

| Parameter name | Annotation                              |
| -------------- | --------------------------------------- |
| \_marketMaker  | The market maker address.               |
| \_reserve      | The reserve address.                    |
| \_contributer  | The contributer address.                |
| \_token        | The token to convert from.              |
| \_gdAmount     | The total G$ amount to contribute from. |

Returns: the contribution amount for sell.

```
function calculateContribution(
   GoodMarketMaker _marketMaker,
   GoodReserveCDai _reserve,
   address _contributer,
   ERC20 _token,
   uint256 _gdAmount
) external view returns (uint256);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gooddollar.org/previous-protocol-versions/protocol-v3/core-contracts-and-api/contributioncalculation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
