Skip to content

Commit 6752878

Browse files
committed
Update contracts. New pool config encoder. Salt mixing
1 parent 3b59656 commit 6752878

File tree

4 files changed

+31
-22
lines changed

4 files changed

+31
-22
lines changed

packages/thirdweb/src/assets/constants.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
export const DEFAULT_MAX_SUPPLY_ERC20 = 10_000_000_000n;
2-
export const DEFAULT_POOL_FEE = 10000;
32
export const DEFAULT_POOL_INITIAL_TICK = 230200;
3+
export const DEFAULT_REFERRER_REWARD_BPS = 5000; // 50%
44
export const DEFAULT_INFRA_ADMIN = "0x1a472863cf21d5aa27f417df9140400324c48f22";
55
export const DEFAULT_FEE_RECIPIENT =
6-
"0x1af20c6b23373350ad464700b5965ce4b0d2ad94";
6+
"0x1Af20C6B23373350aD464700B5965CE4B0D2aD94";
77
export const DEFAULT_FEE_BPS = 50n;
88
export const DEFAULT_SALT = "thirdweb";
99

1010
export 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: "",

packages/thirdweb/src/assets/create-token.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff 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,

packages/thirdweb/src/assets/token-utils.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { encodeAbiParameters } from "../utils/abi/encodeAbiParameters.js";
77
import { toUnits } from "../utils/units.js";
88
import {
99
DEFAULT_MAX_SUPPLY_ERC20,
10-
DEFAULT_POOL_FEE,
1110
DEFAULT_POOL_INITIAL_TICK,
11+
DEFAULT_REFERRER_REWARD_BPS,
1212
} from "./constants.js";
1313
import type { MarketConfig, PoolConfig, TokenParams } from "./types.js";
1414

@@ -50,29 +50,29 @@ export async function encodeInitParams(options: {
5050

5151
export 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

packages/thirdweb/src/assets/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export type TokenParams = {
1616
export type PoolConfig = {
1717
amount: bigint;
1818
currency?: string;
19-
fee?: number;
2019
initialTick?: number;
20+
referrerRewardBps?: number;
2121
};
2222

2323
export type MarketConfig = {
@@ -48,4 +48,5 @@ export type CreateTokenOptions = ClientAndChainAndAccount & {
4848
salt?: string;
4949
params: TokenParams;
5050
launchConfig?: LaunchConfig;
51+
referrerAddress?: string;
5152
};

0 commit comments

Comments
 (0)