Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
A subaccount is a unique account variant wherein the subaccount module regulates both its balance and permissions.
Subaccount module parameter types and definition.
The House module has the following parameters:
Wager Enabled: Determines if the wagering by subaccount is active or not.
Deposit Enabled: Determines if the deposit (be the house) by subaccount is active or not.
The proto for the params is as follows:
The SGE-Network node application introduces a distinctive account type called
subaccount
and its balance is managed by this module. The subaccount balance is intended for use in betting and engaging in the "be the house" feature to participate in the markets as a house.
The subaccount balance is established with an unlocking period, following which the balance can be withdrawn to the owner's main balance.
Owners have the option to create the Subaccount themselves, or it can be generated by the rewards module.
Defines the way in which the state of the Subaccount is being stored in the chain.
The Create and TopUp messages are used to store the data of a particular subaccount's locked balance in the blockchain. The AccountSummary
entity consists of the following fields:
deposited_amount
: The total amount that has been transferred to a subaccount so far.
spent_amount
: The spent amount that has been used for wager and deposit.
withdrawn_amount
: The amount that has been withdrawn from the subaccount's unlocked/locked balance.
lost_amount
: The amount that has been lost in wager and deposit.
The proto for the Deposit messages is as follows:
The Create and TopUp messages are used to store the data of a particular subaccount's locked balance in the blockchain. The LockedBalance
entity consists of the following fields:
amount
: The amount of locked balance.
unlock_ts
: The time when the amount would be unlocked.
The proto for the locked balance is as follows:
This section elaborates on the transaction message handler methods being exposed by the House module.
When a create transaction is processed, the following things happen:
Validate the incoming create message.
Call the Create
method of the keeper.
The RPC for creating a subaccount is as follows:
The request message for Create
is MsgCreate
. The proto for the request message is as follows:
The response message for Deposit
is MsgDepositResponse
. The proto for the request message is as follows:
When a top-up transaction is processed, the following things happen:
Validate the incoming create message.
Call the TopUp
method of the keeper.
The RPC for a top-up of the subaccount is as follows:
The request message for TopUp
is MsgTopUp
. The proto for the request message is as follows:
The response message for TopUp
is MsgTopUpResponse
. The proto for the request message is as follows:
When a top-up transaction is processed, the following things happen:
Validate the incoming create message.
Call the WihtdrawUnlocked
method of the keeper.
The RPC for a top-up of the subaccount is as follows:
The request message for WihtdrawUnlockedBalances
is MsgWihtdrawUnlockedBalances
. The proto for the request message is as follows:
The response message for WihtdrawUnlockedBalances
is MsgWihtdrawUnlockedBalancesResponse
. The proto for the request message is as follows:
When a wager transaction is processed, the following things happen:
Validate the incoming create message.
Call the Wager
method of the keeper.
The RPC for a wager of the subaccount is as follows:
The request message for Wager
is MsgWager
. The proto for the request message is as follows:
The response message for Wager
is MsgWagerResponse
. The proto for the request message is as follows:
The main logic of the House module definitions and methods.
There are several steps for subaccount create to be made:
Check for existing subaccount.
Generate a new ID.
Create a new account extracted from the generated ID.
Set the new account into the account keeper.
Store the owner, locked balances, and account summary in the state.
There are several steps for a subaccount top-up to be made:
Get account summary and locked balances from the state.
Update the account Summary and locked balances.
Send tokens from the transaction signer to the subaccount balance in the bank module.
There are several steps for a subaccount withdrawal to be made:
Get the account summary from the state.
Calculate the withdrawable balance according to the unlock timestamps and spend and lost amounts.
Update the account summary withdrawn amount.
Send tokens from the subaccount to the owner's balance.
There are several steps for a wager by a subaccount to be made:
Check the existence of the subaccount for the bettor.
Verify the ticket and unmarshal the payload and validate.
Use bet module's methods to prepare a bet object.
Withdraw the needed amount first from the unlocked, then the locked if there is not enough unlocked balance.
Use bet module to place the bet for the owner's account.
The below transaction can be used to create a subaccount on the blockchain.
The below table specifies the details of the arguments used in the above transaction:
The below transaction can be used to top up a subaccount on the blockchain.
The below table specifies the details of the arguments used in the above transaction:
The below transaction can be used to withdraw a subaccount unlocked balance.
The below table specifies the details of the arguments used in the above transaction:
The below transaction can be used to wager using the subaccount and owner account balance.
The below table specifies the details of the arguments used in the above transaction:
Argument | Description | Type | Validation | Example |
---|---|---|---|---|
Argument | Description | Type | Validation | Example |
---|---|---|---|---|
Argument | Description | Type | Validation | Example |
---|---|---|---|---|
Argument | Description | Type | Validation | Example |
---|---|---|---|---|
owner account address
the address of the owner of the subaccount
string
Required
Valid Address
sge1059gavv45jdp0l7c4kkskr0jae02j9cxmjr3f3
funds
the initial fund of the subaccount
uint64
Required
Valid Number
100000
duration
lock duration of the balance
duration
Required
Valid Duration
8760h
owner account address
the address of the owner of the subaccount
string
Required
Valid Address
sge1059gavv45jdp0l7c4kkskr0jae02j9cxmjr3f3
funds
the initial fund of the subaccount
uint64
Required
Valid Number
100000
duration
lock duration of the balance
duration
Required
Valid Duration
8760h
owner account address
the address of the owner of the subaccount
string
Required
Valid Address
sge1059gavv45jdp0l7c4kkskr0jae02j9cxmjr3f3
ticket
the ticket data
string
Required
Valid ticket
Subaccount module CLI.
This section specifies the queries, transactions, and required payloads. By following this section, one can get a deep understanding of the functioning of the subaccount
module in the SGE Network chain.
Params | Description | Type | Validation | Example |
---|---|---|---|---|
owner_address
owner account address
string
Required
Valid Address
sge1059gavv45jdp0l7c4kkskr0jae02j9cxmjr3f3