Context
PR #60 introduced getPoolModule() and getUpdatePoolFn() helpers in AutobalanceLpStrategy to resolve the Move module name based on asset position. These are used in the new pendingRewardAmount() method but not yet applied to the existing collectReward() and getUserRewards() methods, which still have three nearly identical if/else branches differing only by module name.
What to change
collectReward() (lines 630-682)
Collapse three branches into one using getPoolModule():
private collectReward(tx: Transaction) {
const moduleName = this.getPoolModule();
for (const reward of this.parentPoolObject.rewardInfos) {
const rewardType = '0x' + reward.rewardCoinType;
tx.moveCall({
target: `${this.poolLabel.packageId}::${moduleName}::collect_reward`,
typeArguments: [this.poolLabel.assetA.type, this.poolLabel.assetB.type, rewardType],
arguments: [ /* unchanged */ ],
});
}
}
getUserRewards() (lines 685-764)
Same pattern — collapse using getPoolModule() and a new getRewardsFn() helper (analogous to getUpdatePoolFn()) to resolve get_user_rewards_v4 vs get_user_rewards_v3.
Impact
Pure refactor, no behavioral change. Reduces ~130 lines to ~50.
Context
PR #60 introduced
getPoolModule()andgetUpdatePoolFn()helpers inAutobalanceLpStrategyto resolve the Move module name based on asset position. These are used in the newpendingRewardAmount()method but not yet applied to the existingcollectReward()andgetUserRewards()methods, which still have three nearly identicalif/elsebranches differing only by module name.What to change
collectReward()(lines 630-682)Collapse three branches into one using
getPoolModule():getUserRewards()(lines 685-764)Same pattern — collapse using
getPoolModule()and a newgetRewardsFn()helper (analogous togetUpdatePoolFn()) to resolveget_user_rewards_v4vsget_user_rewards_v3.Impact
Pure refactor, no behavioral change. Reduces ~130 lines to ~50.