Skip to content

Commit

Permalink
fill up the pool with higher stake if both are below min
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaczanowski committed Jan 15, 2025
1 parent b5e1aea commit 02034c4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/staking-cli/src/cmd/ton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ async function runTx (
{
delegator: config.delegatorAddress,
validatorAddress: config.validatorAddress,
validatorAddress2: config.validatorAddress2,
messageType: msgType,
args: arg,
broadcast: broadcastEnabled
Expand Down
4 changes: 2 additions & 2 deletions packages/ton/src/TonPoolStaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ export class TonPoolStaker extends TonBaseStaker {

// prioritize filling a pool that hasn't reached the minStake
if (!hasReachedMinStake(balancePool1) && !hasReachedMinStake(balancePool2)) {
// if neither pool has reached minStake, prioritize the one with the smaller balance
return balancePool1 <= balancePool2 ? 0 : 1;
// if neither pool has reached minStake, prioritize the one with the higher balance
return balancePool1 >= balancePool2 ? 0 : 1;
} else if (!hasReachedMinStake(balancePool1)) {
return 0; // fill pool 1 to meet minStake
} else if (!hasReachedMinStake(balancePool2)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/ton/test/pool-staker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ describe('TonPoolStaker', () => {
expect(result).to.equal(0); // Pool 1 needs to reach minStake
})

it('should prioritize the pool with a smaller balance if both are below minStake', () => {
it('should prioritize the pool with a higher balance if both are below minStake', () => {
const result = TonPoolStaker.selectPool(200n, 1000n, [100n, 150n]);
expect(result).to.equal(0); // Pool 1 has a smaller balance
expect(result).to.equal(1); // Pool 2 has a higher balance
})

it('should balance the pools if both have reached minStake but are below maxStake', () => {
Expand Down

0 comments on commit 02034c4

Please sign in to comment.