# Options for Grin

OK this is to open up ideas and possibilities for smart contracts for Grin, including derivatives.

2 Likes

I didnāt realize smart contracts were possible on Grin. Iām gonna have to read up before commenting too muchā¦

COPIED FROM THE ORIGIN THREAD

To review an option, letās take a call. So Grin is say, \$4.50. Letās use Ether as the base. So you would pay ether (to whom?) for a call in 2 months at \$5.00 for 50 Grin. So if Grin is less than \$5 two months later, you would lose your ether to whomever you paid earlier. But if Grin were \$6 the same entity who received the ether would have to either sell you 50 Grin for \$5 a piece (in ether) or pay you the difference \$1 (\$6 current - 5 call) * 50, or 50 (in ether). And you could sell your option back for ether at any time in the two months recalculated in value per the black scholes equation. So the entity in question would need Grin and Ether in fair quantities locked into these contracts. Whoās doing this exactly?

Well, two people could do this, I suppose, one acting as the exchange for the other, which would be the test case, which is really a bet between two people, an atomic swap and smart contract with some intermediary calculation. I guess weāll start with the two party option agreement, which actually is more Grin-like and decentralized.

Itās funny, I started typing this to tell you why it was a waste of time, but I think I just convinced myself thatās a really cool idea ā¦

And to simplify we would obviously change the base currency from ether to Grin. And we would make them European style options that expire on a certain date (initially). Also these options will also expire at the strike price (initially).

Alice wants to buy a grin option, call. Alice pays Bob the price of the Grin option in Grin per the Black Scholes equation. Bob must secure the (difference between the current price and the strike price ) * the quantity. If the date occurs without reaching the strike price, Alice loses the option price she paid, and Bobās stake is liberated for him. If the strike price hits at any time, Bob send the staked amount to Alice, end of contract.

The prices would be in bitcoin. And since unlike an option with USD as the base, the underlying base is a varying speculative asset, so Black Scholes cannot be calculated. So really Alice pays Bob an agreed upon amount of money, and if the price or Grin in bitcoin reaches a certain amount, Bob pays a locked amount out, otherwise no. This is just a bet, and it can be on anything at all to occur on or before a certain date. Itās just a bet.

So if you really want to do this, weāre gambling on arbitrary oracles. That would be the first project if thatās what you want to do.

If you think about crypto is a computer program. Computer programs are functions: they take in data, perform control structures, and produce output, the simplest being binary, true or false. In financial terms, a smart contract takes in data, performs some control structures to filter that data, then outputs. In simplest terms, for finance, this is a bet, one party wager, data is filtered, and thereās a payout or loss of wager. If you keep the data āin houseā to limit the issues, this is computer dice or cards. This is why gambling apps are the predominant dapps, since a bet is the root form of a smart contract.

1 Like

Thatās where we need to start, a simple gambling game. It has all the pieces you need for a smart contract supposedly. So like Grin dice is where we start. That would have everything in place for options or anything else youād want to do subsequently.

Grin Dice is step 1. All proceeds minus operational costs go to Grin Development.

Satoshi Dice was per bitcoin wiki:

To determine if a wager is a winner or loser, the site uses a method to produce a number between 0 and 65,535, similar to how a random number generator (RNG) would be used. The service uses a combination of the transaction hash from the wager transaction from the blockchain and performs a 512-bit SHA2 hash for that transaction hash using a secret unknown to the player. The first four bytes of that hash become the lucky number in determining winner or loser.

I think we could do something similar with the next transaction block proof hash. Turn it into a number, userās lucky number is determined from the transaction hash. If userās lucky number less than hash number, the player wins.

Again per Bitcoin wiki on Satoshi Dice:

Each wager address has different odds, and each gives the house an edge of 1.90% (i.e., payouts are 98.1% when including the payout to the losing bets). The website shows the full list of wager addresses and odds.

Doing this would give every piece needed for derivatives or any other smart contract.

So Step 1 is Grin Dice in rust.

If you going down the rabbit hole I suggest the most important work is getting LN friendly swaps going.

1 Like

Iām not finding your descriptions of how options work very clear. Generally, you would buy options to hedge an exposure (a long or short position). That was the point of the original discussion fragment on monkyyyās shitposting thread. For example, if I have sold a security short, then I might buy some calls to hedge that position i.e. if the price of the security does not go down to vindicate my short position, my call options will be in-the-money so at the time the contract expires, I will be able to collect some funds by exercising them which will offset my loss from being short the security. The options donāt cost the full market price of the security. (See Investopedia for simple examples e.g. https://www.investopedia.com/video/play/how-protect-short-position-options/). All the math etc is well documented on how to do all this. I assumed the challenge with an asset like Grin (or more pratically, the fx rate of a currency pair like GRIN/BTC or GRIN/USD) is that no centralized exchange offers options yet but even if they did, folks may want to trade options in a decentralized manner, analogous to over-the-counter trading of conventional securities. I think how this could be actually implemented is the challenge here.

1 Like

If I got it right, you are talking about true decentralized cypherpunk options, which is a great as an idea, but I can only imagine all the hassle associated with this. I have to dig deeper into the Grinās principles and the math behind it, but for now it seems that even a simple implementation of oracle will be a big obstacle.

Another post of yours caught my attention [NEW] Grin peg chain for Cosmos Hub need : [OLD] Can I do atomic swaps between Cosmos (ATOM) and Grin? - #15 by SiriusB
and I think that this is what we really need here.

What might a small business need to accept Grin in a fully non-KYC manner? At the very least a good Grin/BTC spot dex OR/AND liquid derivatives to hedge the exposure. So here we are with 3 possible solutions: (correct me if Iām wrong or forgot something)

1. Atomic SWAPs
2. Rust node running on the Cosmos VM
3. GRIN&BTC Pegs on Tendermint exchange (similar to Binance DEX)

Atomic SWAPs

Sounds like a decent solution, but what I found up to date is a version with 12h lockup which is not acceptable. Can LN solve this?

Full rust node running on a VM (Cosmos)

Is it even possible to implement a decentralized Rust node acting as a collateral agent on the Cosmos network? Unfortunately, my current knowledge does not allow to answer this question.

Tendermint exchange

This seems to be the only practical solution available right now. If you could create a grin peg, I see two possible scenarios:

A. Run an exchange on the existing Cosmos network, with their fees and slow (for modern trading) block time: 7-8 seconds.

B. Fork Tendermint and create a new chain with 1-second block time specifically for Grin-related products. Pegs could be exchanged for real Grins and BTC through atomic swaps (as Binance DEX docs state). In this case, a 12-hour lockup will no longer be a big problem.

This particular solution looks very promising to me, but some important questions arise, such as: āWill there be enough incentives to run a validation node, assuming that they are paid with trading fees?ā

Those are my thoughts. Iām not a blockchain expert but have a decent programming experience. Would like to contribute to this crazy industry.

2 Likes

Monkyyy - you read my mind - Iām right there with you. LN is key. Well said.

Thank you! Youāre very perceptive. Yes, this is why I was talking about Golang. I have always thought Cosmos was key, a peg, of which several already exist as models, for Grin would give any smart contract and swap imaginable.

I was trying to be accomodating and agreeable to the will of others, as this often gives good results in programming, but I thought Cosmos/Atom was the way to go. The Atom validators would be validating Grin or anything being processed through Cosmos. At āinterestā of 12-15% Atom holders are happy to validate anything!

1 Like

OK, the direction seems clear to me.

I need to study Cosmos/Tendermint and then I can come back to the discussion (to avoid stupid questions).

I know the microstructure of markets and whatās good/whatās not in the exchange interfaces (Iāv been trading for several years now), so I think my knowledge can be useful for building āGRINXā (could be the name?)

It would be blazingly cool to have all Grin products in one shop: spot, swap and options.

Given what you know right now how would you estimate how many man hours would it take to make a btc<->grin LN swap over a eth<->grin LN swap?

Eth-grin is almost done. Eth peg exists. Tendermint/Cosmos obviously exists. Remaining task is the Grin to Cosmos peg.

Btc-grin would require a bitcoin peg for cosmos, then the Grin peg for cosmos.

LN is actually just the same as cosmos in some ways. The LN is offchain contracts with penalties for not fulfilling, so itās not actually interoperative, your just sending transactions to the chain later. There would be no reason to use LN, as Cosmos is way faster and actually has proof and security (BFT) - a POS protocol. LN is not secured - they relay on penalties for not fulfilling the off-chain committments. Itās not POW or POS - itās not proof of anything. Only bitcoin (a chain) could actually connect with another chain. LN is actually a side chain to improve bitcoin transaction speed. Cosmos is a side chain to bridge two or more other chains. Plus the ethereum virtual machine would give you smart contracts, dapps, everything

Iām less excited for any specaility coin running a network; by LN I mean pure cross chain swaps without a coin middle man.

The reason Iām excited for the LN^tm is that the āboltsā are defining a protocol for computers to negotiate smart contracts from templates in real time.

Oh fuck the shitcoin ecosystem

not this: http://lightningnetwork.me/

1 Like

What exactly would be the difference between atomic swaps and what youāre asking āpure cross chain swaps without a coin middle manā?

Atomic swaps bitcoin <-> grin are already done?

Cosmos keeps coming up because Iām into Cosmos, obviously, played with the SDK a little. It would be a short hop from a Grin peg to a dex or dapp. But I am not attached to Cosmos for Grin - I think itās easier to see how to get there, but that may not be the best choice. I like the Cosmos idea because then Grin would immediately added to all the iphone wallets that are big that run off cosmos (like imtoken and tens of others). Grin daily volume (and transactions from miningā¦) would triple or more in a week. Most of those apps have a dex built in, grin, once hubbed, would immediately appear on the trading options, without any additional work of coding a wallet.

I feel Grin needs an escape velocity to get away from the hideous emission schedule for a young coin, and users will do this. Thatās my real angle on the cosmos tbh. Common sense would tell you Iām probably Cosmos invested, and Cosmos will also fluff from this. Win-win. I like to make deals.

Form my understanding the btc<-> grin code would have to be wrapped up in āsoftforked featured channelā(see bolt #7) while playing sort of nice with the onion routing (bolt #4)

Sure ok. But this is hardly in the spirit of crypto. A big, centralized, banker rich-dude.

LN has middle men as I understand it. You want atomic swaps, which are coming very soon.

1 Like