File tree Expand file tree Collapse file tree 4 files changed +31
-22
lines changed
packages/thirdweb/src/assets Expand file tree Collapse file tree 4 files changed +31
-22
lines changed Original file line number Diff line number Diff line change 11export const DEFAULT_MAX_SUPPLY_ERC20 = 10_000_000_000n ;
2- export const DEFAULT_POOL_FEE = 10000 ;
32export const DEFAULT_POOL_INITIAL_TICK = 230200 ;
3+ export const DEFAULT_REFERRER_REWARD_BPS = 5000 ; // 50%
44export const DEFAULT_INFRA_ADMIN = "0x1a472863cf21d5aa27f417df9140400324c48f22" ;
55export const DEFAULT_FEE_RECIPIENT =
6- "0x1af20c6b23373350ad464700b5965ce4b0d2ad94 " ;
6+ "0x1Af20C6B23373350aD464700B5965CE4B0D2aD94 " ;
77export const DEFAULT_FEE_BPS = 50n ;
88export const DEFAULT_SALT = "thirdweb" ;
99
1010export const IMPLEMENTATIONS : Record < number , Record < string , string > > = {
1111 8453 : {
12- AssetEntrypointERC20 : "0x7FF679bFb89ee0F88645CAb8Ab0844ea485a3434 " ,
12+ AssetEntrypointERC20 : "0x556688D4d192FC59b27E239ff6e06D28786aAdbE " ,
1313 ERC20AssetImpl : "" ,
1414 V3PositionManager : "" ,
1515 V4PositionManager : "" ,
1616 } ,
1717 84532 : {
18- AssetEntrypointERC20 : "0x79C1236cFe59f1f088A15Da08b0D8667387d9703 " ,
18+ AssetEntrypointERC20 : "0xf0ED90ea4df819017ee1dfDADf26d65a678b31b7 " ,
1919 ERC20AssetImpl : "" ,
2020 V3PositionManager : "" ,
2121 V4PositionManager : "" ,
Original file line number Diff line number Diff line change @@ -35,13 +35,21 @@ export async function createToken(options: CreateTokenOptions) {
3535 ...options ,
3636 } ) ;
3737 const blockNumber = await eth_blockNumber ( rpcRequest ) ;
38- const salt = options . salt
39- ? options . salt . startsWith ( "0x" ) && options . salt . length === 66
40- ? ( options . salt as `0x${string } `)
41- : keccakId ( options . salt )
42- : toHex ( blockNumber , {
38+
39+ let salt : Hex = "0x" ;
40+ if ( ! options . salt ) {
41+ salt =
42+ "0x1f" +
43+ toHex ( blockNumber , {
4344 size : 32 ,
44- } ) ;
45+ } ) . substring ( 4 ) ;
46+ } else {
47+ if ( options . salt . startsWith ( "0x" ) && options . salt . length === 66 ) {
48+ salt = options . salt as `0x${string } `;
49+ } else {
50+ salt = "0x1f" + keccakId ( options . salt ) . substring ( 4 ) ;
51+ }
52+ }
4553
4654 const entrypoint = await getOrDeployEntrypointERC20 ( options ) ;
4755
@@ -87,7 +95,7 @@ export async function createToken(options: CreateTokenOptions) {
8795 amount,
8896 data : encodedInitData ,
8997 hookData,
90- referrer : ZERO_ADDRESS ,
98+ referrer : options . referrerAddress || ZERO_ADDRESS ,
9199 salt,
92100 } ,
93101 creator,
Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ import { encodeAbiParameters } from "../utils/abi/encodeAbiParameters.js";
77import { toUnits } from "../utils/units.js" ;
88import {
99 DEFAULT_MAX_SUPPLY_ERC20 ,
10- DEFAULT_POOL_FEE ,
1110 DEFAULT_POOL_INITIAL_TICK ,
11+ DEFAULT_REFERRER_REWARD_BPS ,
1212} from "./constants.js" ;
1313import type { MarketConfig , PoolConfig , TokenParams } from "./types.js" ;
1414
@@ -50,29 +50,29 @@ export async function encodeInitParams(options: {
5050
5151export function encodePoolConfig ( poolConfig : PoolConfig ) : Hex {
5252 const POOL_PARAMS = [
53- {
54- name : "currency" ,
55- type : "address" ,
56- } ,
5753 {
5854 name : "amount" ,
5955 type : "uint256" ,
6056 } ,
6157 {
62- name : "fee " ,
63- type : "uint24 " ,
58+ name : "currency " ,
59+ type : "address " ,
6460 } ,
6561 {
6662 name : "initialTick" ,
67- type : "uint24" ,
63+ type : "int24" ,
64+ } ,
65+ {
66+ name : "referrerRewardBps" ,
67+ type : "uint16" ,
6868 } ,
6969 ] as const ;
7070
7171 return encodeAbiParameters ( POOL_PARAMS , [
72- poolConfig . currency || NATIVE_TOKEN_ADDRESS ,
7372 toUnits ( poolConfig . amount . toString ( ) , 18 ) ,
74- poolConfig . fee || DEFAULT_POOL_FEE ,
73+ poolConfig . currency || NATIVE_TOKEN_ADDRESS ,
7574 poolConfig . initialTick || DEFAULT_POOL_INITIAL_TICK ,
75+ poolConfig . referrerRewardBps || DEFAULT_REFERRER_REWARD_BPS ,
7676 ] ) ;
7777}
7878
Original file line number Diff line number Diff line change @@ -16,8 +16,8 @@ export type TokenParams = {
1616export type PoolConfig = {
1717 amount : bigint ;
1818 currency ?: string ;
19- fee ?: number ;
2019 initialTick ?: number ;
20+ referrerRewardBps ?: number ;
2121} ;
2222
2323export type MarketConfig = {
@@ -48,4 +48,5 @@ export type CreateTokenOptions = ClientAndChainAndAccount & {
4848 salt ?: string ;
4949 params : TokenParams ;
5050 launchConfig ?: LaunchConfig ;
51+ referrerAddress ?: string ;
5152} ;
You can’t perform that action at this time.
0 commit comments