Swap Schema
field | type |
---|---|
id | MongoId |
swapInitiator | Text |
swapInitiatorBufficorn | Number |
swapInitiatedTimestamp | Date |
swapInitiateSporkTx | Text |
swapExecutor | Text |
swapExecutorBufficorn | Number |
swapExecutedTimestamp | Date |
swapExecutedSporkTx | Text |
traitsToSwap | [Enum] |
stakeStatus | Enum |
Made an escrow contract gist for ideation. Bufficorn Trait Swapper Escrow
validations before going home:
- check if min grazing period over
As a swap initiator:
validations before initiating swap:
- check if the other bufficorn is grazing (using grazing contract)
- check if the initiator bufficorn is locked in any other swap (using escrow contract)
- check if the executor bufficorn is locked in any other swap (using escrow contract)
- check if initiator wallet has enough spork token balance
As a swap executor:
validations before executing the swap:
- check if the swap id is valid & the stake status(using database)
- check if the swap window over (using database)
- check if the executor bufficorn is locked in any other swap (using escrow contract)
- check if executor wallet has enough spork token balance
Withdraw stake
If the executor fails to finish the swap, the initiator can use the withdrawSporkStake() function in escrow contract to get back his stake.
validations before withdrawing the stake:
- check if the swap id is valid & the stake status(using database)
- check if the swap window over (using database)
- check if the requesting address is a swap initiator for the corresponding swap
- check if the escrow contract has enough spork balance to send back the stake