@whetstone-research/doppler-sdk 1.0.21 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,6 +10,7 @@ The Doppler SDK exposes network-specific entrypoints for creating, managing, and
10
10
 
11
11
  - **EVM Auctions**: Static auctions, dynamic auctions, and multicurve launches across Uniswap V3/V4 paths
12
12
  - **EVM Migration Paths**: Support for V2, V2 split, V4, V4 split, DopplerHook, and no-op migration
13
+ - **EVM Multicurve Fees**: Single-token and batched pending-fee previews plus beneficiary fee claiming for locked multicurve pools
13
14
  - **Solana Launches**: Initializer, CPMM, migrator, hook, oracle, and Token-2022-compatible instruction helpers
14
15
  - **Solana Clients and React**: Read clients, PDA helpers, generated codecs, and optional React bindings
15
16
  - **Token Management**: Built-in EVM support for DERC20 tokens with vesting
@@ -554,7 +555,7 @@ For decay pools, `pool.fee` is always the terminal fee (`endFee`) of the schedul
554
555
  When you want fee revenue to flow to specific addresses without migrating liquidity after the auction, use lockable beneficiaries with NoOp migration:
555
556
 
556
557
  ```typescript
557
- import { WAD } from '@whetstone-research/doppler-sdk/evm';
558
+ import { MulticurveFees, WAD } from '@whetstone-research/doppler-sdk/evm';
558
559
 
559
560
  // Define beneficiaries with shares that sum to WAD (1e18 = 100%)
560
561
  // IMPORTANT: Protocol owner must be included with at least 5% shares
@@ -603,21 +604,30 @@ const result = await sdk.factory.createMulticurve(params);
603
604
  const assetAddress = result.tokenAddress; // SAVE THIS - you'll need it to collect fees!
604
605
  console.log('Asset address:', assetAddress);
605
606
 
606
- // Later, to collect fees (works before and after migration):
607
+ // Later, to preview and claim fees while the pool is locked:
607
608
  // const pool = await sdk.getMulticurvePool(assetAddress)
609
+ // const pending = await pool.getPendingFees('0xBeneficiary...')
608
610
  // await pool.collectFees()
611
+ //
612
+ // To preview many locked multicurve tokens at once:
613
+ // const fees = new MulticurveFees(publicClient, walletClient, tokenAddresses)
614
+ // const pendingByToken = await fees.getPendingFees('0xBeneficiary...')
609
615
  ```
610
616
 
611
617
  **Important Notes:**
612
618
 
613
619
  - Set `fee` > 0 (e.g., 3000 for 0.3%) to accumulate trading fees for beneficiaries
614
620
  - **Save the asset address** (token address) returned from creation - you need it to collect fees later
615
- - Beneficiaries receive fees proportional to their shares when `collectFees()` is called
621
+ - Use `MulticurvePool.getPendingFees(beneficiary)` to preview a beneficiary's claimable token0/token1 fees for one pool
622
+ - Use `MulticurveFees.getPendingFees(beneficiary)` to preview pending fees for multiple tokens with one multicall by default
623
+ - Pass `tokenBatchSize` to `MulticurveFees` when an RPC provider needs large pending-fee previews split into smaller token batches
624
+ - `collectFees()` claims a payout for the calling account only when the caller is a configured beneficiary
616
625
  - Pool enters "Locked" status (status = 2) and liquidity cannot be migrated
617
626
  - Beneficiaries are immutable and set at pool creation time
618
627
  - The SDK automatically handles PoolKey construction and PoolId computation for you
619
628
 
620
629
  See [examples/multicurve-lockable-beneficiaries.ts](./examples/multicurve-lockable-beneficiaries.ts) for a complete example.
630
+ See [docs/multicurve-fees.md](./docs/multicurve-fees.md) for single-token and multi-token pending-fee previews, claiming, batching, and current migrated-launch limitations.
621
631
 
622
632
  #### Transaction gas override
623
633
 
@@ -773,9 +783,12 @@ const currentEpoch = await auction.getCurrentEpoch();
773
783
 
774
784
  ### Multicurve Pool Interactions
775
785
 
776
- Multicurve pools support fee collection and distribution to beneficiaries when configured with `lockableBeneficiaries`.
786
+ Multicurve pools support fee collection and beneficiary claims when configured
787
+ with `pool.beneficiaries` and no-op migration.
777
788
 
778
789
  ```typescript
790
+ import { MulticurveFees } from '@whetstone-research/doppler-sdk/evm';
791
+
779
792
  // Get a multicurve pool instance using the asset address (token address)
780
793
  const pool = await sdk.getMulticurvePool(assetAddress);
781
794
 
@@ -795,15 +808,37 @@ if (feeSchedule) {
795
808
  console.log('Fee schedule:', feeSchedule);
796
809
  }
797
810
 
798
- // Collect and distribute fees to beneficiaries
799
- // This can be called by anyone, but only beneficiaries receive fees
811
+ // Preview pending fees for a beneficiary. This is a read-only call.
812
+ const pendingFees = await pool.getPendingFees(beneficiaryAddress);
813
+ console.log('Pending fees (token0):', pendingFees.fees0);
814
+ console.log('Pending fees (token1):', pendingFees.fees1);
815
+
816
+ // Preview pending fees for multiple launched tokens. By default this builds
817
+ // one multicall for all requested tokens.
818
+ const multicurveFees = new MulticurveFees(
819
+ publicClient,
820
+ walletClient,
821
+ [assetAddress, anotherAssetAddress],
822
+ { tokenBatchSize: 25 },
823
+ );
824
+ const pendingFeesByToken =
825
+ await multicurveFees.getPendingFees(beneficiaryAddress);
826
+ for (const pendingFees of pendingFeesByToken) {
827
+ console.log('Asset:', pendingFees.tokenAddress);
828
+ console.log('Pending fees (token0):', pendingFees.fees0);
829
+ console.log('Pending fees (token1):', pendingFees.fees1);
830
+ }
831
+
832
+ // Claim fees from a beneficiary wallet while the pool is locked.
833
+ // Any account can call collectFees(), but only a configured beneficiary caller
834
+ // receives their pending share.
800
835
  const { fees0, fees1, transactionHash } = await pool.collectFees();
801
836
  console.log('Fees collected (token0):', fees0);
802
837
  console.log('Fees collected (token1):', fees1);
803
838
  console.log('Transaction:', transactionHash);
804
839
 
805
840
  // Get token addresses
806
- const tokenAddress = await pool.getTokenAddress();
841
+ const tokenAddress = pool.getTokenAddress();
807
842
  const numeraireAddress = await pool.getNumeraireAddress();
808
843
  ```
809
844
 
@@ -812,33 +847,35 @@ const numeraireAddress = await pool.getNumeraireAddress();
812
847
  The SDK handles the complexity of fee collection by:
813
848
 
814
849
  1. **Retrieving pool configuration** from the multicurve initializer contract
815
- 2. **Detecting migration status** and, if the pool has migrated, resolving the shared `StreamableFeesLockerV2`
816
- address via the multicurve migrator (no manual lookup required)
850
+ 2. **Detecting pool status** so only locked initializer-side pools proceed
817
851
  3. **Computing the PoolId** from the PoolKey using `keccak256(abi.encode(poolKey))`
818
- 4. **Calling the correct contract** (initializer while locked, locker after migration) with the computed PoolId
819
- 5. **Distributing fees** proportionally to all configured beneficiaries
852
+ 4. **Previewing pending fees** with a Multicall3 aggregate that simulates collection and reads beneficiary share/checkpoint data
853
+ 5. **Calling the initializer** with the computed PoolId when a beneficiary claims via `collectFees()`
820
854
 
821
855
  **Important Notes:**
822
856
 
823
857
  - Fees accumulate from swap activity on the pool (only if fee tier > 0)
824
- - Anyone can call `collectFees()`, but fees are distributed to beneficiaries only
825
- - Fees are automatically split according to configured beneficiary shares
826
- - The function returns the total amount collected for both tokens in the pair
827
- - Works exclusively with pools created using `lockableBeneficiaries` in the multicurve configuration
858
+ - `MulticurvePool.getPendingFees(beneficiary)` returns the beneficiary's pending share for both tokens in one pair
859
+ - `MulticurveFees.getPendingFees(beneficiary)` returns pending fees for each requested token and uses one multicall by default
860
+ - `MulticurveFees` accepts `tokenBatchSize` when large token lists need to be split into smaller multicalls
861
+ - `collectFees()` sends a transaction; the caller needs a wallet client
862
+ - Anyone can call `collectFees()`, but only a configured beneficiary caller receives their pending share
863
+ - The `collectFees()` return values are the newly collected pool fees, not necessarily the caller's beneficiary payout
864
+ - Works exclusively with initializer-side locked pools created with `pool.beneficiaries` and no-op migration
828
865
  - Pools in "Locked" status (status = 2) use the multicurve initializer for collection
829
- - Pools in "Exited" status (status = 3) automatically stream fees through `StreamableFeesLockerV2`; the SDK
830
- resolves the locker address and stream data for you
866
+ - Pools in "Exited" status (status = 3) are migrated and are not currently supported by `MulticurvePool.getPendingFees()` or `MulticurvePool.collectFees()`
831
867
  - `getFeeSchedule()` returns decay schedule details only for dynamic-fee multicurve pools, otherwise `null`
832
868
  - Beneficiaries must be configured at pool creation time and cannot be changed
833
869
 
834
870
  **Common Use Cases:**
835
871
 
872
+ - Preview pending fees for a portfolio or paginated token list
836
873
  - Set up periodic fee collection (e.g., daily or weekly)
837
874
  - Integrate with a bot that automatically collects fees when threshold is reached
838
875
  - Allow any beneficiary to trigger collection after significant trading activity
839
876
  - Monitor swap events to determine optimal collection timing
840
877
 
841
- See [examples/multicurve-collect-fees.ts](./examples/multicurve-collect-fees.ts) for a complete example.
878
+ See [docs/multicurve-fees.md](./docs/multicurve-fees.md) for a focused guide, [examples/multicurve-get-pending-fees.ts](./examples/multicurve-get-pending-fees.ts) for batched previews, and [examples/multicurve-collect-fees.ts](./examples/multicurve-collect-fees.ts) for claims.
842
879
 
843
880
  ## Token Management
844
881