Energy Rental
Introduction
All transactions on JustLend DAO require Energy, which can only be acquired through staking or burning TRX. This process involves high costs and lengthy procedures. In response, JustLend DAO introduces the Energy Rental service, allowing users to rent Energy at a significantly reduced price compared to staking or burning TRX. The contract EnergyRental used to set up the Energy Rental service.
Query Interface
Rental Order Information
View the information of an rental order.
Parameter description:
renter
: order payer;receiver
: the resource receiver of this rental;resourceType
: resource type, 0: bandwidth; 1: energy.
Returns:
amount
: order resources corresponding to the amount of TRX (delegated TRX amount);securityDeposit
: order deposit, not updated to current;rentIndex
: order's global index at the time of its last update.
Current Rental Order Information (updated to current)
View the information of an rental order, with the returned data updated to current.
Parameter description:
renter
: order payer;receiver
: the resource receiver of this rental;resourceType
: resource type, 0: bandwidth; 1: energy.
Returns:
securityDeposit
: order deposit, updated to current;rentIndex
: real-time global index of the order at the time of query.
Bad Debt
If the user's rent is greater than securityDeposit, a bad debt will be generated. This field will be updated when repayment or liquidation occurs.
Parameter description: N/A;
Returns: the amount of bad debt in TRX, minimum unit.
Covered Bad Debt
Bad debts will be filled when the collectible rewards (_settleIncome
) are updated or the repayBadDebt
function is triggered.
Parameter description: N/A;
Returns: the amount of cumulative bad debt has been filled in TRX , minimum unit.
Bad Debt To Be Covered
The amount of bad debt that has not been processed. In fact, this value is equal to the amount of badDebt minus badDebtCovered.
Parameter description: N/A;
Returns: the amount of bad debt to be covered in TRX, minimum unit.
Total Rent Income
Rental income from renting energy.
Parameter description: N/A;
Returns: the amount of total rental income.
Claimed Rent Income
The STRX contract can extract the income through the claimRental
function, which records the accumulated income that has been extracted.
Parameter description: N/A;
Returns: the amount of accumulate income that has been extracted.
Liquidation Rate
The liquidateRate
is used during liquidation. If the price fluctuates greatly, it will be diluted for 6 hours. Rapidly raised prices will not take effect immediately during the liquidation process.
Parameter description:
resourceType
: resource type, 0: bandwidth; 1: energy.
Returns: current liquidation rate.
Rental Rate
Get the latest rental rate. when the amount is passed as 0, it returns the current tental rate. When the amount is greater than 0, for example, 100, it returns the rental rate after the energy changes by 100.
Parameter description:
amount
: order resources corresponding to the amount of TRX;resourceType
: resource type, 0: bandwidth; 1: energy.
Returns: current rental rate.
Write Interface
Rent Resources
Rent resources, allow amount = 0 (extension only) or msg.value = 0 (no new deposit), both are 0 is not allowed.
Parameter description:
receiver
: the resource receiver of this rental. Not allowed to be a contract or an unactivated account;amount
: the rent resource corresponding to the amount of TRX (delegated TRX amount), the minimum unit, if the amount is not 0 (renewal only), it must be greater than 1 TRX;resourceType
: resource type, 0: bandwidth; 1: energy;msg.sender
: the payer for this rental;msg.value
: new deposit of this time.
Returns: None, revert on failure.
📅 Event
Emits when renting occurs.
renter
: order payer;receiver
: the resource receiver of this rental;addedAmount
: the TRX amount (minimum unit) of the newly-rent resource;resourceType
: resource type, 0: bandwidth; 1: energy;addedSecurityDeposit
: the added deposit amount;amount
: the total amount of rental resources in the order after renting.
Return Resources (called by payer)
Return resources. Return resources in the order (msg.sender, receiver, resourceType). When the remaining deposit is insufficient, all resources will be forcibly emptied, and the remaining deposit will be returned to the order payer.
Parameter description:
receiver
: the resource receiver of this rental;amount
: rent resource corresponding to the amount of TRX (delegated TRX amount), the minimum unit;resourceType
: resource type, 0: bandwidth; 1: energy;msg.sender
: resource receiver.
Returns: the amount of the deposit returned in this operation. 0 for a partial return.
📅 Event
Emits when resources are returned.
renter
: order payer;receiver
: the resource receiver of this rental;subedAmount
: the amount of TRX (minimum unit) for returned resources;resourceType
: resource type, 0: bandwidth; 1: energy;usageRental
: the cost of recovery for the used resources in the returned resources;subedSecurityDeposit
: the refunded deposit amount (0 for partial returns);amount
: the remaining amount of rental resources after returning resources.
Return resources (called by receiver)
Return resources. Return resources in the order (renter, msg.sender, resourceType). When the remaining deposit is insufficient, all resources will be forcibly emptied, and the remaining deposit will be returned to the order payer.
Parameter description:
renter: order payer;
amount: rent resource corresponding to the amount of TRX (delegated TRX amount), the minimum unit;
resourceType: resource type, 0: bandwidth; 1: energy;
msg.sender: resource receiver;
Returns: the amount of the deposit returned in this operation. 0 for partial return.
Liquidate
When the order deposit is insufficient, the liquidator can liquidate the order, and the liquidator will get the liquidation reward. If there is any remaining deposit, it will be returned to the order payer.
Parameter description:
renter: order payer;
receiver: the resource receiver of this rental;
resourceType: resource type, 0: bandwidth; 1: energy;
msg.sender: liquidator;
Returns: Liquidation reward in this operation.
📅 Event
Emits when liquidation occurs.
liquidator
: the person liquidate the order;renter
: order payer;receiver
: the resource receiver of this rental;amount
: rent resource corresponding to the amount of TRX (delegated TRX amount), the minimum unit;resourceType
: resource type, 0: bandwidth; 1: energy;usageRental
: the fee for the recovery time of the order resource usage;liquidateFee
: the liquidation reward received by the liquidator;sendBack
: the remaining deposit received by the payer.
Last updated