GnosisRouter
Last updated
Last updated
Router implementation with functions to interact with xDAI on Gnosis Chain.
sDAI address.
SavingsXDaiAdapter address.
Constructor.
Parameters
Name | Type | Description |
---|---|---|
Splits a position using xDAI and sends the ERC20 outcome tokens back to the user.
The ERC20 associated to each outcome must be previously created on the wrapped1155Factory.
Parameters
Pre-condition
The ERC20 associated to each outcome must be previously created on the wrapped1155Factory.
Logic
The user send native tokens (xDAI), which will be converted to Savings xDAI (sDAI) and transferred to GnosisRouter
.
Call conditionalTokens.splitPosition
to transfer sDAI from GnosisRouter
to ConditionalTokens
, while minting corresponding ERC1155 outcome tokens to GnosisRouter
.
Transfer ERC1155 outcome tokens from GnosisRouter
to Wrapped1155Factory
contract. There is a callback function in Wrapped1155Factory
that will wrap the tokens into ERC20 tokens, then transfer the wrapped tokens back to the original user.
Merges positions and sends xDAI to the user.
The ERC20 associated to each outcome must be previously created on the wrapped1155Factory.
Parameters
Pre-condition
The ERC20 associated to each outcome must be previously created on the wrapped1155Factory.
The caller must have <amount> ERC20 tokens of all the outcomes of a market. For example, to call mergeToBase
of a market with 3 outcomes: Yes, No, Invalid, the caller must have <amount> tokens for each outcome.
Logic
Merging positions does precisely the opposite of what splitting a position does.
Unwraps ERC20 outcome tokens (which will burn these tokens and transfer corresponding ERC1155 outcome tokens back to the GnosisRouter
contract).
Call conditionalTokens.mergePositions
to burn ERC1155 outcome tokens.
Return sDAI to GnosisRouter
, which will then be converted to xDAI and sent to the user.
Redeems positions and sends xDAI to the user.
The ERC20 associated to each outcome must be previously created on the wrapped1155Factory.
Parameters
Pre-condition
The ERC20 associated to each outcome must be previously created on the wrapped1155Factory.
The caller must have ERC20 tokens of the outcomes they want to redeem. For example, to call redeemToBase
for outcome Yes of a market with 3 outcomes: Yes, No, Invalid, the caller must have Yes tokens. (The call will still be processed even if the caller does not have tokens, but it will have no effect).
conditionalTokens.reportPayouts
has been called by an oracle.
Logic
Unwraps ERC20 outcome tokens (which will burn these tokens and transfer corresponding ERC1155 outcome tokens back to the GnosisRouter
contract).
Call conditionalTokens.redeemPositions
to burn ERC1155 outcome tokens.
Return sDAI to GnosisRouter
. GnosisRouter
will calculate the sDAI difference before and after redeeming, which will then be converted to xDAI and sent to the user.
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
_conditionalTokens
contract IConditionalTokens
Conditional Tokens contract.
_wrapped1155Factory
contract IWrapped1155Factory
Wrapped1155Factory contract.
market
contract Market
The Market to split.
market
contract Market
The Market to merge.
amount
uint256
The amount of outcome tokens to merge.
market
contract Market
The Market to redeem.
outcomeIndexes
uint256[]
The index of the outcomes to redeem.
amounts
uint256[]
Amount to redeem of each outcome.