Skip to content

Commit f051911

Browse files
authored
update docs to use platform referrer for tba vs zora coins (#165)
1 parent 1cbec39 commit f051911

1 file changed

Lines changed: 37 additions & 12 deletions

File tree

docs/cookbook/base-app-coins.mdx

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ export async function getCurrency(address: string): Promise<Currency> {
112112

113113
```typescript
114114
let coinType: string | undefined;
115-
let appType = "ZORA";
116115
if (key.hooks === "0xd61A675F8a0c67A73DC3B54FB7318B4D91409040") {
117116
coinType = "ZORA_CREATOR_COIN"
118117
} else if (key.hooks === "0x9ea932730A7787000042e34390B8E435dD839040") {
@@ -121,20 +120,49 @@ if (key.hooks === "0xd61A675F8a0c67A73DC3B54FB7318B4D91409040") {
121120

122121
if (!coinType) continue;
123122

124-
if (TBA_PAIRINGS.includes(pool.currency0.wrapped.address) || TBA_PAIRINGS.includes(pool.currency1.wrapped.address)) {
125-
appType = "TBA"
126-
}
123+
// Detect if the coin is coming from Base App or Zora
124+
const appType = await categorizeAppType(pool);
127125
```
128126

129127
**Base App Token Detection:**
130128
```typescript
131-
const TBA_PAIRINGS = [
132-
"0x4200000000000000000000000000000000000006", // WETH
133-
// "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" // USDC - not yet used
134-
]
129+
130+
export async function categorizeAppType(pool: Pool) {
131+
async function tryGetPlatformReferrer(address: string) {
132+
const zoraBaseCoin = getContract({
133+
abi: parseAbi([
134+
"function platformReferrer() view returns (address)",
135+
]),
136+
address: address as `0x${string}`,
137+
client: publicClient
138+
})
139+
140+
try {
141+
const platformReferrer = await zoraBaseCoin.read.platformReferrer()
142+
return platformReferrer
143+
} catch (error) {
144+
return ADDRESS_ZERO
145+
}
146+
}
147+
148+
// Try to fetch `platformReferrer()` on both currencies in the Pool
149+
// falling back to ADDRESS_ZERO if the function does not exist (currency is not a Zora coin)
150+
const [currency0PlatformReferrer, currency1PlatformReferrer] = await Promise.all([
151+
tryGetPlatformReferrer(pool.currency0.wrapped.address),
152+
tryGetPlatformReferrer(pool.currency1.wrapped.address)
153+
])
154+
155+
// If either of the currencies has the Base App referrer address,
156+
// the coin is coming from the Base App
157+
if ([currency0PlatformReferrer, currency1PlatformReferrer].includes(BASE_PLATFORM_REFERRER)) {
158+
return "TBA"
159+
}
160+
161+
return "ZORA"
162+
}
135163
```
136164

137-
Since the coins are created via Zora, filtering down to which ones are from Base App is a matter of looking at what token the pool is paired with. Tokens created via the Base App are paired with `WETH`. In the future, `USDC` pairing will also be used. Tokens created directly via the Zora app do not pair with `WETH` or `USDC` - so we use this as a way of identifying and tagging if the coin came from Zora or Base App.
165+
Since the coins are created via Zora, filtering down to which ones are from Base App is a matter of looking at what the platform referrer address is on the Zora coin. We don't know if the Zora coin is necessarily `currency0` or `currency1` in the pool - so we attempt to fetch the platform referrer address for both. For tokens like WETH which don't have that view function available, it will just fall back to the zero address. If either of the currencies return a valid platform referrer address that also matches the referrer address used by the Base App, we classify the coin as having come from the Base App.
138166

139167

140168
#### 4. Liquidity Calculations
@@ -268,9 +296,6 @@ const metadata = {
268296
### Block Range
269297
Modify `START_BLOCK_NUMBER` and `END_BLOCK_NUMBER` in `index.ts` to scan different ranges or implement continuous monitoring.
270298

271-
### Token Pairing Rules
272-
Update `TBA_PAIRINGS` array to modify which base tokens indicate Base App classification.
273-
274299
### Hook Addresses
275300
Add new hook addresses to the classification logic as new Zora contracts are deployed.
276301

0 commit comments

Comments
 (0)