Skip to content

Commit c2de8f9

Browse files
committed
fix(sdk): correct asset retrieval in getTopupPayload
1 parent 5b41218 commit c2de8f9

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

packages/sdk/src/Incentives/CGDAIncentive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ export class CGDAIncentive extends DeployableTarget<
492492
* @param {bigint} netAmount The additional tokens to add to `totalBudget`.
493493
* @returns {Hex} The ABI-encoded, updated CGDAIncentive payload.
494494
*/
495-
public getTopupPayload(netAmount: bigint): Hex {
495+
public async getTopupPayload(netAmount: bigint): Promise<Hex> {
496496
return encodeAbiParameters(
497497
[
498498
{ type: 'address', name: 'asset' },
@@ -503,7 +503,7 @@ export class CGDAIncentive extends DeployableTarget<
503503
{ type: 'address', name: 'manager' },
504504
],
505505
[
506-
this.payload?.asset ?? zeroHash,
506+
(await this.asset()) ?? zeroHash,
507507
this.payload?.initialReward ?? 0n,
508508
this.payload?.rewardDecay ?? 0n,
509509
this.payload?.rewardBoost ?? 0n,

packages/sdk/src/Incentives/ERC20Incentive.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,15 +512,16 @@ export class ERC20Incentive extends DeployableTarget<
512512
* @param {?WriteParams} [params] (optional) if you need them
513513
* @returns {Hex} the ABI-encoded data for top-up
514514
*/
515-
public getTopupPayload(netAmount: bigint): Hex {
515+
public async getTopupPayload(netAmount: bigint): Promise<Hex> {
516516
// 1. Build a typed object matching your `ERC20IncentivePayload`.
517517
// For example, you might want to increment `limit` by `netAmount`,
518518
// or set `reward = netAmount`. That’s up to your logic:
519+
const asset = await this.asset();
519520
const typed: ERC20IncentivePayload = {
520-
asset: this.payload?.asset || zeroAddress,
521-
strategy: this.payload?.strategy || StrategyType.POOL, // e.g. StrategyType.POOL
522-
reward: netAmount, // store net top-up as the "reward"
523-
limit: 1n, // or maybe add netAmount to existing limit
521+
asset: asset || zeroAddress,
522+
strategy: StrategyType.POOL, // e.g. StrategyType.POOL
523+
reward: 1n, // store net top-up as the "reward"
524+
limit: netAmount, // or maybe add netAmount to existing limit
524525
manager: this.payload?.manager || zeroAddress,
525526
};
526527

packages/sdk/src/Incentives/ERC20PeggedIncentive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,9 @@ export class ERC20PeggedIncentive extends DeployableTarget<
487487
* @param {bigint} netAmount - The additional limit to add to this incentive.
488488
* @returns {Hex} The ABI-encoded payload with the updated `limit`.
489489
*/
490-
public getTopupPayload(netAmount: bigint): Hex {
490+
public async getTopupPayload(netAmount: bigint): Promise<Hex> {
491491
return prepareERC20PeggedIncentivePayload({
492-
asset: this.payload?.asset ?? zeroAddress,
492+
asset: (await this.asset()) ?? zeroAddress,
493493
peg: this.payload?.peg ?? zeroAddress,
494494
reward: this.payload?.reward ?? 0n,
495495
limit: netAmount,

packages/sdk/src/Incentives/ERC20PeggedVariableCriteriaIncentive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,9 @@ export class ERC20PeggedVariableCriteriaIncentive extends DeployableTarget<
622622
* @param {bigint} netAmount - The additional limit to add to this incentive.
623623
* @returns {Hex} The ABI-encoded payload with the updated `limit`.
624624
*/
625-
public getTopupPayload(netAmount: bigint): Hex {
625+
public async getTopupPayload(netAmount: bigint): Promise<Hex> {
626626
return prepareERC20PeggedVariableCriteriaIncentivePayload({
627-
asset: this.payload?.asset ?? zeroAddress,
627+
asset: (await this.asset()) ?? zeroAddress,
628628
peg: this.payload?.peg ?? zeroAddress,
629629
reward: this.payload?.reward ?? 0n,
630630
limit: netAmount,

packages/sdk/src/Incentives/ERC20VariableIncentive.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,12 @@ export class ERC20VariableIncentive<
404404
* @param {bigint} netAmount - The additional limit to add to this incentive.
405405
* @returns {Hex} The ABI-encoded payload with the updated `limit`.
406406
*/
407-
public getTopupPayload(netAmount: bigint): Hex {
407+
public async getTopupPayload(netAmount: bigint): Promise<Hex> {
408408
return prepareERC20VariableIncentivePayload({
409-
asset: zeroAddress,
410-
reward: 0n,
409+
asset: (await this.asset()) as Address,
410+
reward: netAmount,
411411
manager: zeroAddress,
412-
limit: netAmount,
412+
limit: 1n,
413413
});
414414
}
415415

0 commit comments

Comments
 (0)