Contract Interactions
Calculate Outputs
computeTokenOutput() can be used on the SLPHub contract to calculate the outputs for a given user stake and chance combination.
SLPHub.sol
/**
* @notice Computes the net output, pool edge, net profit and profit.
* @dev The total output is the staked amount divided by winning chance.
* @param _stake The stake amount.
* @param _chance The percentage of winning chance in 10000 BASE_POINT
* @return netOutput (profit + stake - edge)
* @return edge percentage of profit amount
* @return netProfit (profit - edge)
* @return profit The value of profit from the trade without removing pool edge
* @return platformFee The platform fee
*/
function computeTokenOutput(
uint112 _stake,
uint16 _chance
)
public
view
returns (
uint112 netOutput,
uint112 edge,
uint112 netProfit,
uint112 profit,
uint112 platformFee
);
Create Tickets
The SLPHub contract has two entrypoints for creating tickets. When opening a ticket, a target pair must be chosen alongside the token which can facilitate the winnings for the stake/chance combination.
SLPHub.sol
/**
* @notice Creates a new ticket against an SLP pair
* @dev Will attempt to use users contract balance if available.
* @param _pair The address of the token pair
* @param _token The address of the play token
* @param _stake The stake for a ticket
* @param _chance The percentage of winning chance in BASE_POINT (5% = 0.05*10000)
* @param _user The user to create the ticket for
* @return ticketId The ID of the attempted ticket
*/
function createTicket(
address _pair,
address _token,
uint112 _stake,
uint16 _chance,
address _user
) public returns (uint256 ticketId);
/**
* @notice Creates a new ticket against an SLP pair using ETH
* This function wraps the ETH and treats ticket as WETH
* @param _pair The address of the token pair
* @param _stake The stake amount for a ticket in wei
* @param _chance The percentage of winning chance in BASE_POINT (5% = 0.05*10000)
* @param _user The user to create the ticket for
* @return ticketId The registered ticket ID
*/
function createTicketWithETH(
address _pair,
uint112 _stake,
uint16 _chance,
address _user
) public payable returns (uint256 ticketId);
Get Ticket Status
The getTicketStatus() helper will return the current state and result of its target token. Alternatively, the tickets mapping can be used to retrieve the complete ticket data.
SLPHub.sol
// Mapping from ticket ID to ticket details
mapping(uint256 => Ticket) public tickets;
/**
* @notice Get the status of a ticket
* @param _ticketId The ID of the ticket
* @return status The status of the ticket
* @return isWin Whether the ticket is a win
* @return chance Selected chance of the ticket
* @return result Stored result of resolved ticket
*/
function getTicketStatus(
uint256 _ticketId
) public view returns (TicketStatus status, bool isWin, uint16 chance, uint16 result);
Withdraw Balance
See Game Balances page.