Skip to content

Commit

Permalink
add sequence diagrams for v2 flows
Browse files Browse the repository at this point in the history
  • Loading branch information
makarychev committed Jun 10, 2024
1 parent 48e61d2 commit b0fe6c1
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,57 @@ People who donate are eligible to receive token rewards.
## Protocol data design
![Solana Donation](https://github.com/donaty-io/donaproto/assets/3645723/5773ddc5-f67f-4765-9f58-f342890f12d1)

## Create fundraising in SPL token different from defaults
Donation protocol supports default SPL token mint in which organizations can collect fundraisings.
Calculation of donors rewards, contributors and creators statistics depend on default token.
So in order to introduce different fundraising token mint we integrate v2 instructions with Raydium CLMM and sdk-v2.
Raydium CLMM `PoolState` is used to get current token pair price and calculate fair rewards and statistics.

### Authorize CLMM program and PoolState
In order to be able to create fundraising in different token then default new donation must be authorized by donation protocol authority.
New donation mints are allowed with high liquidity on DEX and have tradable pair linked with USDC token.
```mermaid
sequenceDiagram
autonumber
actor Creator
actor Authority
participant DonationProtocol
participant OnChain
Creator->>Authority: requests support of new fundraising token mint
loop Verify requests
Authority->>Authority: Check DEX liquidity regarding USDC token
end
Authority->>DonationProtocol: authorize clmm program
DonationProtocol->>OnChain: create authorized clmm program data
Authority->>DonationProtocol: authorize clmm pool state
DonationProtocol->>OnChain: create authorized clmm pool data
Authority->>Creator: notify creator about requested token mint support
Note left of Authority: Creator can start to create fundraising in requested token
```

### Fundraising flow v2
```mermaid
sequenceDiagram
autonumber
actor Creator
actor Contributor
participant DonationProtocol
participant OnChain
Creator->>DonationProtocol: createDonationV2
DonationProtocol->>OnChain: update data
Note left of OnChain: verify donation mint and intialize data
loop Fundraising
Contributor->>DonationProtocol: donateV2(amount)
DonationProtocol->>OnChain: update data
Note left of OnChain: transfer and add amount to fundraising,<br>convert amount to default_amount base on PoolState,<br>+default_amount to statistic and transfer rewards in default amount
end
Creator->>DonationProtocol: withdrawFundsV2
DonationProtocol->>OnChain: update data
Note left of OnChain: transfer total_amount_received in donation_mint,<br>calculate default_amount base on PoolState,<br>add default_amount to total_amount_received
```

# Environment Setup

Expand Down

0 comments on commit b0fe6c1

Please sign in to comment.