> For the complete documentation index, see [llms.txt](https://docs.evently.market/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.evently.market/smart-contracts/profiles.md).

# EventlyProfiles.sol v1.3

**Address:** `0x9F0708145BCCD1F5B16F610cB8a75A63fA4A9a24` **Version:** v1.3

***

## Constants

| Constant                        | Value      | Description                                               |
| ------------------------------- | ---------- | --------------------------------------------------------- |
| `MIN_USERNAME_LENGTH`           | 3          | Min username chars                                        |
| `MAX_USERNAME_LENGTH`           | 20         | Max username chars                                        |
| `LEADERBOARD_SIZE`              | 10         | Top N tracked onchain                                     |
| `REFERRAL_ACTIVATION_THRESHOLD` | 1 USDm     | Min prediction market trading volume to activate referral |
| `SWAP_POINTS_PER_USD_CENT`      | 5          | Points per $0.01 swapped                                  |
| `SWAP_COOLDOWN`                 | 30 seconds | Min delay between swap records                            |

***

## Profile Struct

```solidity
struct Profile {
    string username;
    uint256 swapVolumeUsd;    // Lifetime swap volume in USD cents
    uint256 swapPoints;       // Points earned from swaps
    uint256 tradePoints;      // Points earned from prediction market trades
    address referrer;         // Referrer address
    uint256 referralEarnings; // Total USDm earned via referrals
}
```

***

## Profile Creation

| Function                                                | Cost | Description                              |
| ------------------------------------------------------- | ---- | ---------------------------------------- |
| `createProfile(username, referrerUsername)`             | Free | Standard profile creation                |
| `createProfileWithPromo(username, referrer, promoCode)` | Free | Valid community code grants bonus points |

Profiles are **free for everyone**. Community codes grant a points bonus on creation.

Referrers are passed by **username** (not address). If the username doesn't resolve, it is silently ignored — no revert.

***

## Key Functions

### Called by Protocol Contracts

| Function                                           | Description              |
| -------------------------------------------------- | ------------------------ |
| `creditReferral(address referred, uint256 amount)` | Credits referrer balance |
| `referrerOf(address)`                              | Returns referrer address |

### User-Facing

| Function                     | Description                                             |
| ---------------------------- | ------------------------------------------------------- |
| `claimReferralEarnings()`    | Withdraw referral earnings                              |
| `recordSwap(volumeUsdCents)` | Log swap volume, award points (authorized callers only) |
| `getProfile(address)`        | View profile data                                       |
| `getLeaderboard()`           | Returns top 10 addresses + scores                       |

### Admin

| Function                             | Description                      |
| ------------------------------------ | -------------------------------- |
| `setAuthorizedContract(address)`     | Authorize protocol contract      |
| `addPromoCode(code, maxUses)`        | Create community code            |
| `removePromoCode(code)`              | Invalidate a code                |
| `setAuthorizedCaller(address, bool)` | Authorize address for recordSwap |
| `withdrawFees()`                     | Withdraw accumulated fees        |

***

## Events

| Event                | Trigger                          |
| -------------------- | -------------------------------- |
| `ProfileCreated`     | Profile created                  |
| `ReferralRewarded`   | Referral balance credited        |
| `ReferralClaimed`    | User withdraws referral earnings |
| `SwapRecorded`       | Swap volume logged               |
| `WhaleStatusUpdated` | Player marked as whale           |
| `PromoCodeUsed`      | Community code redeemed          |


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.evently.market/smart-contracts/profiles.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
