Chuyển tới nội dung chính

Events and data reference

Mọi thứ một indexer hoặc dashboard cần: các event để lắng nghe, cách tra cứu ngược một sale, và mọi struct, enum, và constant mà bộ docs này nhắc tới.

Mục lục​

Mô hình indexing​

Mỗi kiểu launch neo danh tính của nó vào một địa chỉ fundManager, một tham số indexed trên mọi event vòng đời, nên bạn có thể lọc toàn bộ lịch sử của một sale bằng một topic duy nhất. Các event create (PoolCreated, MicroSaleCreated, BondingCurvePoolCreated) cũng mang theo token, nên bạn có thể build map sale-tới-token chỉ từ event create.

indexed được áp dụng cho fundManager và user trên các event vòng đời; index dạng số không được index trên các event trade/finalize, nên hãy lọc và join trên fundManager.

Các event quan trọng nhất cho một feed listings:

  • PoolCreated / MicroSaleCreated / BondingCurvePoolCreated: một sale đã được tạo (và với một microsale hoặc Melt Pool, một token đã được mint).
  • Finalized / MicroSaleFinalized / BondingCurveFinalized: token đã được list trên DEX và việc giao dịch bắt đầu.

Pool events​

Được phát ra bởi các luồng presale, fair launch, và subscription.

event PoolCreated(uint256 index, address indexed fundManager, address owner, address token, uint256 timestamp);

event Contributed(uint256 index, address indexed fundManager, address indexed user, uint256 amount, uint256 timestamp);

event Claimed(
uint256 index,
address indexed fundManager,
address indexed user,
uint256 claimed,
uint256 totalPurchased,
uint256 timestamp
);

event ExcessiveRefunded(
uint256 index,
address indexed fundManager,
address indexed user,
uint256 amount,
uint256 total,
uint256 timestamp
);

event WithdrawContribution(uint256 index, address indexed fundManager, address indexed user, uint256 amount, uint256 timestamp);

event EmergencyWithdrawContribution(uint256 index, address indexed fundManager, address indexed user, uint256 amount, uint256 timestamp);

event Finalized(uint256 index, address indexed fundManager, uint256 timestamp);
event Cancelled(uint256 index, address indexed fundManager, uint256 timestamp);
event PoolUpdated(uint256 index, address indexed fundManager, uint256 timestamp);

// whitelist
event WhitelistRootUpdated(address indexed fundManager, bytes32 root, uint256 timestamp);
event WhitelistTierAdded(address indexed fundManager, uint256 tier, uint256 startTime, uint256 duration, uint256 timestamp);
event WhitelistTierUpdated(address indexed fundManager, uint256 tier, uint256 startTime, uint256 duration, uint256 timestamp);

// subscription allocation
event AllocationSubmitted(uint256 indexed poolIndex, address indexed fundManager, bytes32 allocationRoot, uint256 totalVolumePurchased);
event AllocationApproved(uint256 indexed poolIndex, address indexed fundManager);
event AllocationRevoked(uint256 indexed index, address indexed fundManager);

Lưu ý: Finalized và Cancelled thuộc về pools. Microsale phát ra MicroSaleFinalized và MicroSaleCancelled thay vào đó. Trên các event subscription allocation, poolIndex được index (khác với index dạng số trên các event vòng đời).

Microsale events​

Mọi event vòng đời được khai báo với các signature này. Các tham số indexed là các topic có thể lọc.

event MicroSaleCreated(
uint256 indexed index,
address indexed fundManager,
address indexed owner,
address token,
uint256 configId,
uint256 timestamp
);

event MicroSaleContributed(
uint256 index,
address indexed fundManager,
address indexed user,
uint256 amount,
uint256 timestamp
);

event MicroSaleFinalized(uint256 index, address indexed fundManager, uint256 timestamp);

event MicroSaleClaimed(
uint256 index,
address indexed fundManager,
address indexed user,
uint256 claimed,
uint256 timestamp
);

event MicroSaleWithdraw(
uint256 index,
address indexed fundManager,
address indexed user,
uint256 amount,
uint256 timestamp
);

event MicroSaleEmergencyWithdraw(
uint256 index,
address indexed fundManager,
address indexed user,
uint256 amount,
uint256 timestamp
);

event MicroSaleCancelled(uint256 index, address indexed fundManager, uint256 timestamp);

event MicroSaleUpdated(uint256 indexed index, address indexed fundManager, uint256 timestamp);

Lưu ý: microsale phát ra MicroSaleFinalized. Event Finalized chung thuộc về luồng presale và fair-launch pool cũ hơn, không phải microsale.

Melt Pool events​

Được phát ra bởi luồng Melt Pool. Contract viết những cái này là BondingCurve* — đó là tên kỹ thuật cho đường giá mà một Melt Pool chạy trên đó. Xem melt-pool.md.

event BondingCurvePoolCreated(
uint256 indexed index,
address indexed fundManager,
address owner,
address token,
address quoteToken,
uint256 timestamp
);

// one per buy and per sell
event BondingCurveTraded(
uint256 index,
address indexed fundManager,
address indexed user,
bool isBuy,
uint256 quoteAmount, // BNB in (buy) or out (sell)
uint256 baseAmount, // tokens out (buy) or in (sell)
uint256 reserveBase, // reserves after the trade
uint256 reserveQuote,
uint256 timestamp
);

// the buy that takes the last curve token
event BondingCurveSoldOut(uint256 index, address indexed fundManager, uint256 timestamp);

event BondingCurveFinalized(uint256 index, address indexed fundManager, address pair, uint256 timestamp);

event BondingCurvePoolUpdated(uint256 indexed index, address indexed fundManager, uint256 timestamp);

BondingCurveTraded mang theo các reserve sau giao dịch, nên bạn có thể track giá (reserveQuote / reserveBase) và volume mà không cần một lệnh đọc theo sau. BondingCurveSoldOut kích hoạt trên lệnh mua làm cạn curve, đó là tín hiệu cho bạn biết pool đã sẵn sàng graduate. Đó là một thời điểm tách biệt với BondingCurveFinalized, thứ kích hoạt khi ai đó thực sự gọi finalize và token list, và mang theo pair DEX. BondingCurvePoolUpdated kích hoạt khi chủ sở hữu pool chỉnh sửa metadata.

Vault events​

Được phát ra bởi các vault contract, không phải bởi launchpad. Lọc chúng trên địa chỉ vault bạn lấy từ getMicroSaleByFundManager(fundManager).vault.

Chung cho mọi vault được build trên VaultBase:

event Bound(address indexed token);      // fee-receiver wired to its token, once
event RevenueReceived(uint256 amount); // best-effort signal when the token settles tax

SplitterVault:

event Distributed(uint256 amount);
event Paid(address indexed payee, uint256 amount);
event PayFailed(address indexed payee, uint256 amount); // payee could not receive; kept as owed
event Claimed(address indexed payee, uint256 amount);

GiftVault:

event BeneficiaryBound(address indexed beneficiary, uint256 nonce, bool viaRelayer);
event Distributed(uint256 amount);
event Paid(address indexed to, uint256 amount);
event PayFailed(address indexed to, uint256 amount);
event Claimed(address indexed to, uint256 amount);
event Locked();
event DividendDistributed(uint256 amount); // timeout fallback fired; vault is now dividend-only

Tra cứu ngược​

Mọi mapping bạn cần đều là một view call. Pools và microsale có các getter song song.

// microsales
await launchpad.getMicroSaleByFundManager(fundManager);
await launchpad.getMicroSaleByToken(token); // 1:1
await launchpad.getMicroSaleByVault(vault); // vault launches
await launchpad.getMicroSale(index);
await launchpad.getMicroSalesCount();

// pools
await launchpad.getPoolByFundManager(fundManager); // confirm result.fundManager === fundManager
await launchpad.getPoolByIndex(index);
await launchpad.getPoolCount();

// melt pools
await launchpad.getBondingCurvePoolByFundManager(fundManager); // confirm result.fundManager === fundManager
await launchpad.getBondingCurvePool(index);
await launchpad.getBondingCurvePoolsCount();

Một getPoolByFundManager (và đối tác Melt Pool của nó) cho một địa chỉ không xác định trả về pool 0 thay vì revert, nên hãy kiểm tra result.fundManager === fundManager trước khi tin vào nó. Từ một MicroSale, Pool, hoặc BondingCurvePool bạn đã có token, fundManager, và owner, nên hầu hết các join không cần một lệnh gọi thứ hai. Melt Pools không có getter theo token, nhưng địa chỉ token là một trường trên struct.

Cấu trúc dữ liệu​

Pool​

Được trả về bởi các view getPool*. Những trường nào có ý nghĩa tùy vào loại pool (một fair launch để rate và hardCap bằng không; một subscription dùng softCapTokens thay vì softCap).

struct Pool {
uint256 index;
PoolTypeIndex poolType;
address owner;
address token;
address currency; // address(0) = native (BNB)
address fundManager; // the sale handle
address router; // address(0) for a manual-listing pool
uint256 startTime;
uint256 endTime;
uint256 publicSaleStartTime; // whitelist window ends here
uint256 whitelistTierCount;
uint256 minContribution;
uint256 maxContribution;
uint256 softCap; // currency; presale + fair launch
uint256 hardCap; // currency; presale
uint256 softCapTokens; // tokens; subscription
uint256 totalSellingTokens; // fair launch + subscription
uint256 hardCapTokensPerUser; // subscription
uint256 rate; // tokens per currency unit; presale + subscription
uint256 listingRate;
uint256 lockDuration; // LP lock seconds; 0 = burn
uint256 listingPercent; // percent of the raise into liquidity
uint256 buybackPercent;
uint256 affiliateBps;
RefundType refundType; // Refund | Burn (unsold tokens)
State state; // Active | Finalized | Cancelled
uint256 listedAt;
uint256 claimTime;
uint256 totalRaised;
uint256 totalCommitted; // subscription commitments before allocation
uint256 totalVolumePurchased; // tokens sold / allocated
int256 lockId; // locker id when locked, else -1
string poolDetails;
string kycDetails;
bytes32 whitelistRoot; // 0 = no whitelist
bytes32 allocationRoot; // subscription / overflow allocation
bytes32 noAllocationRoot; // overflow non-allocated refunds
uint256 tgePercent; // vesting: released at claim start
uint256 cyclePercent; // vesting: released per cycle
uint256 cycle; // vesting: cycle length in seconds
bool requireContributorValidation; // contributions need a platform signature
}

getContributionInfosByFundManager được phân trang trả về ContributionInfoResponse, thứ là ContributionInfo với địa chỉ user được thêm vào đầu:

struct ContributionInfoResponse {
address user;
uint256 contribution;
uint256 purchased;
uint256 claimed;
uint256 excessiveRefunded;
}

MicroSale​

Được trả về bởi mọi view getMicroSale*.

struct MicroSale {
uint256 index; // creation index
MicroSaleTypeIndex microSaleType;
address owner; // creator
address token; // minted token
address currency; // raise currency; address(0) = native (BNB)
address fundManager; // the sale handle
address router; // DEX router used at finalize
uint256 startTime;
uint256 endTime;
uint256 hardCap; // in the raise currency
uint256 totalSellingTokens; // presale allocation
uint256 rate; // presale rate; purchased = amount * rate / 1e18
uint256 listingRate; // opening DEX price basis
State state; // Active | Finalized | Cancelled
uint256 filledAt; // when the hard cap filled (0 if not)
uint256 listedAt; // when finalized (0 if not)
uint256 totalRaised;
uint256 totalVolumePurchased; // total tokens sold
uint256 configId; // template it launched from
string poolDetails; // free-form metadata
string kycDetails; // platform-set KYC metadata
uint256 maxContribution; // per-wallet cap; 0 = unlimited
uint256 lockDuration; // LP lock seconds; 0 = LP burned
int256 lockId; // locker id when locked, else -1
address vault; // attached vault, or address(0)
address vaultFactory; // factory that made the vault, or address(0)
}

MicroSaleConfig​

Được trả về bởi getMicroSaleConfig và các view active-configs.

struct MicroSaleConfig {
uint256 configId;
uint256 presaleTokens; // tokens sold in the presale
uint256 lpTokens; // tokens paired into liquidity
uint256 hardCap; // in the template's raise currency
uint256 duration; // sale length in seconds
uint256 buyTaxBps; // template buy tax (used by templated tax tokens)
uint256 sellTaxBps; // template sell tax
uint256 taxDuration; // template tax lifetime
bool active;
}

presaleTokens + lpTokens luôn bằng tổng cung cố định 1,000,000,000 token.

ContributionInfo​

Ledger theo từng user, dùng chung bởi pools và microsale. getContributionInfo (pools) và getMicroSaleContribution (microsale) trả về nó đầy đủ; response microsale được phân trang bỏ excessiveRefunded.

struct ContributionInfo {
uint256 contribution; // amount put in, in the raise currency
uint256 purchased; // tokens allocated
uint256 claimed; // tokens claimed so far
uint256 excessiveRefunded; // subscription / overflow refund; unused by microsales
}

// paginated microsale response shape
struct MicroSaleContributionInfoResponse {
address user;
uint256 contribution;
uint256 purchased;
uint256 claimed;
}

WhitelistTier​

Được trả về bởi getWhitelistTiers(fundManager) cho một pool.

struct WhitelistTier {
uint256 tier; // 1-indexed
uint256 startTime; // when the tier opens
uint256 duration; // seconds the tier stays open; 0 = single open-ended tier
string description;
}

BondingCurvePool​

Được trả về bởi getBondingCurvePool(index) và getBondingCurvePoolByFundManager(fundManager).

struct BondingCurvePool {
uint256 index;
address owner;
address token;
address quoteToken; // address(0) = native (BNB); otherwise an allowed ERC20 quote token
address fundManager; // the pool handle
address router;
uint256 initialBase; // virtual base reserve seed
uint256 initialQuote; // virtual quote reserve seed
uint256 totalSellingBase; // tokens sellable before graduation
uint256 reserveBase; // current base reserve
uint256 reserveQuote; // current quote reserve
CurveState state; // Active | Finalized
uint256 listedAt; // graduation timestamp, 0 until finalized
uint8 tokenType; // 0 = no-tax (CheeseToken), 4 = tax (CheeseTaxTokenV2)
address vault; // attached vault, or address(0)
address vaultFactory; // factory that made the vault, or address(0)
string poolDetails; // free-form metadata
}

Giá là reserveQuote / reserveBase. Bán hết (graduated) nghĩa là reserveBase == initialBase - totalSellingBase; nó được suy ra từ các reserve, không được lưu như một trạng thái.

BondingCurveConfig​

Curve template của platform cho một đồng tiền quote, được trả về bởi getBondingCurveConfig(quoteToken).

struct BondingCurveConfig {
bool active; // curves cannot be created against an inactive config
uint256 initialBase; // virtual base reserve seed
uint256 initialQuote; // virtual quote reserve seed
uint256 totalSellingBase; // tokens sellable before graduation
}

TaxConfig​

Được truyền bên trong struct CreateParamsV2 cho các launch tax-token CheeseTaxTokenV2. Chi phối thuế của token và nơi thuế đi. Các lệnh create tax-token cũng nhận một dexKey ở cuối (DEX để list) bên cạnh params.

struct TaxAllocation {   // BPS; the four must sum to 10000
uint16 feeReceiver; // to the fee receiver (wallet or vault)
uint16 holders; // to holders as dividends
uint16 burn; // to the dead address
uint16 liquidity; // added back as LP
}

struct TaxConfig {
uint256 buyTaxBps; // <= 1000 (10%)
uint256 sellTaxBps; // <= 1000 (10%); buyTaxBps + sellTaxBps must be > 0
uint256 taxDuration; // seconds after listing that tax applies; must be > 0
uint256 antiFarmerDuration; // seconds of the anti-farmer window; <= taxDuration
TaxAllocation allocation; // must sum to 10000
address feeReceiver; // wallet path only; vault path binds the vault instead
address quoteToken; // 0 fills from the template binding (WETH or an allowed ERC20 quote token)
uint256 minHolderShare; // required > 0 only if allocation.holders > 0
// Anti-farmer venue prediction — filled by the launchpad from the chosen DEX, not
// by the caller. Leave at zero defaults.
address v3Factory;
bytes32 v2PairInitCodeHash;
bytes32 v3PoolInitCodeHash;
uint24[] v3FeeTiers;
}

Trên creator tax này, CheesePad thu thêm một khoản phí platform 10% trên thuế (giai đoạn curve và sau khi listing); xem tokens.md#the-fee-model.

Platform config​

getMasterConfig() trả về các cài đặt toàn platform.

struct LaunchpadMasterConfig {
address feeTo; // platform fee + creation fee sink
address locker; // LP locker for locked-liquidity sales
address affiliateProgram;
address buybackManager;
address verificationWallet;
uint256 creationFee; // pool creation fee (not microsale)
uint128 nativeFeePercent;
uint256 maxAffiliateBps;
uint256 fairLaunchMaxDuration;
uint256 totalParticipants;
address cheeseTokenHelper; // shared swap/liquidity helper for tax tokens
address platformRole; // vault emergency-rescue backstop
address giftRelayerSigner; // EIP-712 attestor for GiftVault identity binds
uint256 microSaleCreationFee; // flat native fee to create a microsale
address swapRouter; // shared upgradeable router for CheeseTaxTokenV2 processors
uint16 platformCutPreBps; // platform fee on curve-phase creator tax (BPS)
uint16 platformCutPostBps; // platform fee on post-listing creator tax (BPS)
}

platformCutPreBps / platformCutPostBps là phí platform trên creator tax của một tax token trong giai đoạn curve và sau khi listing; đọc chúng trực tiếp bằng getPlatformCutBps(). Xem tokens.md#the-fee-model.

LaunchDataV1​

Những gì _reviewV1 của vault factory của bạn nhận được khi nó thẩm định một launch. Đó là các tham số launch, không có vaultData theo từng vault.

struct LaunchDataV1 {
uint256 configId;
address quoteToken;
uint256 buyTaxBps;
uint256 sellTaxBps;
uint256 taxDuration;
uint16 feeReceiverBps;
uint16 holdersBps;
uint16 burnBps;
uint16 liquidityBps;
uint256 minDispatch;
uint256 minHolderShare;
address creator;
}

Vault schema types​

Được dùng bởi vaultDataSchema() (form tạo) và vaultUISchema() (các hành động và trạng thái đọc được). Một UI render bất kỳ vault nào từ những cái này mà không cần code đặc thù cho vault.

enum FieldType {
String, Address, Uint16, Uint256, Uint128, Bool, Bytes, Bytes32, Time, MsgValue
}

struct Field {
string name;
FieldType fieldType;
bool isArray;
uint8 decimals; // UI multiplies inputs / divides outputs by 10^decimals
string hint;
}

struct VaultDataSchema { // how to encode vaultData for createVault
string description;
bool isArray; // true => vaultData is a tuple[]; false => a single tuple
Field[] fields;
}

struct ApprovalHint { // an ERC20 approval a UI must prompt before a write
string tokenRef; // "token", "quoteToken", or a 0x address literal
string amountField; // input field holding the amount; "*" = max approval
}

struct Method {
string name;
bytes4 selector;
bool isWrite; // true = tx button; false = read field
Field[] inputs;
Field[] outputs;
ApprovalHint[] approvals;
string hint;
}

struct VaultUISchema {
string vaultType;
string description;
Method[] methods;
}

Ghi chú về kiểu: Time là một Unix timestamp tuyệt đối (một duration chỉ là một Uint256 của giây). MsgValue là native BNB được gửi dưới dạng msg.value cùng một lệnh ghi, không phải một tham số ABI. decimals không áp dụng cho Time hoặc MsgValue. Spender cho bất kỳ ApprovalHint nào cũng luôn là vault.

Enums​

enum State { Active, Finalized, Cancelled }   // 0, 1, 2; used by pools and microsales

enum PoolTypeIndex { // Pool.poolType
Presale, // 0
FairLaunch, // 1
Subscription, // 2
OverflowPresale, // 3, not currently creatable
OverflowFairLaunch // 4, not currently creatable
}

enum RefundType { Refund, Burn } // 0, 1; handling of unsold pool tokens

enum SubscriptionCalculationStage { // getSubscriptionCalculationStage
notCalculated, // 0
needConfirm, // 1
calculated // 2, claiming can open
}

enum MicroSaleTypeIndex { Presale } // only one type today

enum CurveState { Active, Finalized } // 0, 1; BondingCurvePool.state (sold-out is derived)

Constant và giới hạn​

ConstantGiá trịỞ đâu
Minted token supply1,000,000,000 (18 decimals)mọi token microsale và Melt Pool (pools tự mang token của mình)
Tax cap per side10% (1000 BPS)tax token lúc launch
Template tax cap per side5% (500 BPS)microsale config template
Allocation base10000 BPStax allocation phải cộng lại bằng con số này
Platform fee at finalize5% (microsale) / nativeFeePercent (pool)finalize
Melt Pool trade fee1% (100 BPS) per trademỗi lệnh mua và bán trên curve
Emergency withdrawal fee10% of the contributionemergency withdraw
Emergency cutofflast 15 minutes before endemergency withdraw
Pool listing percent20 to 100pool create
Presale soft cap rulesoftCap * 4 >= hardCap and softCap < hardCappresale create
Minimum LP lock30 days (pool) / 365 days (microsale); 5 minutes on BNB testnet onlyfinalize with a lock
Maximum LP lock10 yearsmicrosale create
Melt Pool liquidityLP burned at graduation (permanent)Melt Pool finalize
SplitterVault max payees50SplitterVault
GiftVault bind window1 to 365 daysGiftVault launch