Options for Grin

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


I didn’t realize smart contracts were possible on Grin. I’m gonna have to read up before commenting too much…


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. :slight_smile:


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

THIS: https://github.com/lightningnetwork/lightning-rfc/blob/master/00-introduction.md

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