You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+74-16Lines changed: 74 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
# Slice Hooks
2
2
3
-
Smart contracts for creating custom pricing strategies and onchain actions for [Slice](https://slice.so) products. Hooks enable dynamic pricing, purchase restrictions, rewards, and other custom behaviors when products are bought.
3
+
Smart contracts for creating custom pricing strategies and onchain actions for [Slice](https://slice.so) products.
4
+
5
+
Hooks enable dynamic pricing, purchase restrictions, rewards, integration with external protocols and other custom behaviors when products are bought.
4
6
5
7
## Repository Structure
6
8
@@ -17,12 +19,50 @@ src/
17
19
18
20
## Core Concepts
19
21
20
-
Slice hooks are built around three main interfaces:
22
+
Hooks are built around three main interfaces:
21
23
22
24
-**[`IOnchainAction`](./src/interfaces/IOnchainAction.sol)**: Execute custom logic during purchases (eligibility checks, rewards, etc.)
23
25
-**[`IPricingStrategy`](./src/interfaces/IPricingStrategy.sol)**: Calculate dynamic prices for products
24
26
-**[`IHookRegistry`](./src/interfaces/IHookRegistry.sol)**: Enable reusable hooks across multiple products with frontend integration
25
27
28
+
Hooks can be:
29
+
30
+
-**Product-specific**: Custom smart contracts tailored for individual products. These are integrated using the `custom` onchain action or pricing strategy in Slice.
31
+
-**Registry hooks**: Reusable contracts designed to support multiple products. Registries enable automatic integration with Slice clients.
32
+
33
+
See [Hook types](#hook-types) for more details.
34
+
35
+
## Product Purchase Lifecycle
36
+
37
+
Here's how hooks integrate into the product purchase flow:
38
+
39
+
```
40
+
Checkout
41
+
│
42
+
▼
43
+
┌─────────────────────┐
44
+
│ Price Fetching │ ← `productPrice` called here
45
+
│ (before purchase) │ (IPricingStrategy)
46
+
└─────────────────────┘
47
+
│
48
+
▼
49
+
┌─────────────────────┐
50
+
│ Purchase Execution │ ← `onProductPurchase` called here
51
+
│ (during purchase) │ (IOnchainAction)
52
+
└─────────────────────┘
53
+
│
54
+
▼
55
+
┌─────────────────────┐
56
+
│ Purchase Complete │
57
+
└─────────────────────┘
58
+
```
59
+
60
+
**Pricing Strategies** are called during the price fetching phase to calculate price based on buyer and custom logic
61
+
62
+
**Onchain Actions** are executed during the purchase transaction to:
0 commit comments