Skip to content

Commit

Permalink
Merge pull request #9786 from vegaprotocol/9785-one-off-network-treasury
Browse files Browse the repository at this point in the history
feat: tranfers to netork treasury support
  • Loading branch information
jeremyletang authored Oct 13, 2023
2 parents 6603d6a + 1cf0414 commit 3f69360
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
- [9541](https://github.com/vegaprotocol/vega/issues/9731) - Add X day aggregate totals for referral set referees.
- [2985](https://github.com/vegaprotocol/system-tests/issues/2985) - Coverage for insurance pool transfers, fix deadlock when terminating pending market through governance.
- [9770](https://github.com/vegaprotocol/vega/issues/9770) - Fix `PnL` flickering bug.
- [9785](https://github.com/vegaprotocol/vega/issues/9785) - Support transfers to network treasury.

### 🐛 Fixes

Expand Down
2 changes: 1 addition & 1 deletion commands/transfer_funds.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func checkTransfer(cmd *commandspb.Transfer) (e Errors) {
} else {
switch k := cmd.Kind.(type) {
case *commandspb.Transfer_OneOff:
if cmd.ToAccountType != vega.AccountType_ACCOUNT_TYPE_GLOBAL_REWARD && cmd.ToAccountType != vega.AccountType_ACCOUNT_TYPE_GENERAL && cmd.ToAccountType != vega.AccountType_ACCOUNT_TYPE_UNSPECIFIED {
if cmd.ToAccountType != vega.AccountType_ACCOUNT_TYPE_GLOBAL_REWARD && cmd.ToAccountType != vega.AccountType_ACCOUNT_TYPE_GENERAL && cmd.ToAccountType != vega.AccountType_ACCOUNT_TYPE_UNSPECIFIED && cmd.ToAccountType != vega.AccountType_ACCOUNT_TYPE_NETWORK_TREASURY {
errs.AddForProperty("transfer.to_account_type", errors.New("account type is not valid for one off transfer"))
}
if k.OneOff.GetDeliverOn() < 0 {
Expand Down
3 changes: 1 addition & 2 deletions core/collateral/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -2538,7 +2538,7 @@ func (e *Engine) getTransferFundsTransferRequest(ctx context.Context, t *types.T
}

// this could not exists as well, let's just create in this case
case types.AccountTypeGlobalReward, types.AccountTypeLPFeeReward, types.AccountTypeMakerReceivedFeeReward,
case types.AccountTypeGlobalReward, types.AccountTypeLPFeeReward, types.AccountTypeMakerReceivedFeeReward, types.AccountTypeNetworkTreasury,
types.AccountTypeMakerPaidFeeReward, types.AccountTypeMarketProposerReward, types.AccountTypeAveragePositionReward,
types.AccountTypeRelativeReturnReward, types.AccountTypeReturnVolatilityReward, types.AccountTypeValidatorRankingReward:
market := noMarket
Expand All @@ -2550,7 +2550,6 @@ func (e *Engine) getTransferFundsTransferRequest(ctx context.Context, t *types.T
// shouldn't happen, we just created it...
return nil, err
}

default:
return nil, fmt.Errorf("unsupported to account for TransferFunds: %v", accountType.String())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,11 @@ Scenario: Transfer from general account to Network Treasury Account by specifyin
| 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_NETWORK_TREASURY | VEGA | 10000 | 2021-08-26T00:00:01Z |

Then "f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c" should have general account balance of "9985000" for asset "VEGA"
# We check the system account receiving the balance because the treasury transfer is on-chain.
And the reward account of type "ACCOUNT_TYPE_PENDING_TRANSFERS" should have balance of "10000" for asset "VEGA"

When the network moves ahead "1" epochs
Then "f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c" should have general account balance of "9985000" for asset "VEGA"

# We check the system account receiving the balance because the treasury transfer is on-chain.
And the reward account of type "ACCOUNT_TYPE_PENDING_TRANSFERS" should have balance of "10000" for asset "VEGA"
And the reward account of type "ACCOUNT_TYPE_NETWORK_TREASURY" should have balance of "10000" for asset "VEGA"

0 comments on commit 3f69360

Please sign in to comment.