Skip to content

Instantly share code, notes, and snippets.

@j-mueller
j-mueller / staked-ada.md
Created March 10, 2023 09:15
A solution to the Big-Address staking problem

A solution to the Big-Address staking problem

Many DeFi apps on Cardano keep all of the funds they control at a single address. The funds are locked not just by the same Plutus script but allocated to the same staking credential. Whoever controls the staking credential can claim the rewards of the staked Ada and, by delegating to a stake pool of their choice, has considerable power within the consensus mechanism that is securing the entire Cardano network. If all of an app's staking rewards are controlled by a single entity, then how decentralised can the app really claim to be?

Another issue arises if the amount of Ada at the app's address exceeds the maximum amount that can be allocated to a single stake pool. In that case the excess Ada will not count towards staking rewards and some rewards will be forfeited. This makes it less attractive for liquidity providers to send their Ada to popular applications.

In this blog post we propose a novel, algorithmic, decentralised Ada stablecoin that solves the "

@j-mueller
j-mueller / Playground.hs
Created August 4, 2021 12:09
Plutus Playground Smart Contract
-- Vesting scheme as a PLC contract
import Control.Monad (void, when)
import Data.Default (Default (def))
import qualified Data.Map as Map
import qualified Data.Text as T
import Ledger (Address, POSIXTime, POSIXTimeRange, PubKeyHash, Validator)
import qualified Ledger
import qualified Ledger.Ada as Ada
import Ledger.Constraints (TxConstraints, mustBeSignedBy, mustPayToTheScript, mustValidateIn)
@j-mueller
j-mueller / Playground.hs
Created January 27, 2021 08:10
Plutus Playground Smart Contract
-- Vesting scheme as a PLC contract
import Control.Monad (void, when)
import qualified Data.Map as Map
import qualified Data.Text as T
import Language.Plutus.Contract hiding (when)
import qualified Language.Plutus.Contract.Typed.Tx as Typed
import qualified Language.PlutusTx as PlutusTx
import Language.PlutusTx.Prelude hiding (Semigroup (..), fold)
import Ledger (Address, PubKeyHash, Slot (Slot), Validator, pubKeyHash)
@j-mueller
j-mueller / ausgaben.json
Created August 23, 2020 12:46
Ausgaben VG Wachenheim 2020 einzelne Leistungen
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "Anteile der Produkte an den Ausgaben",
"data": {
"values": [
{
"Leistung": 31301,
"Gruppe": "3 - Soziales",
"Name": "Hilfen für Asylbewerber",
"Typ": "Ertrag",
@j-mueller
j-mueller / Salad.hs
Last active August 20, 2020 10:13
Fruit salad
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
module Salad where
@j-mueller
j-mueller / Prompt.hs
Last active May 5, 2020 14:29
Prompt.hs
{-# LANGuAGE NamedFieldPuns #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE MonoLocalBinds #-}
{-# LANGUAGE FlexibleContexts #-}
module Language.Plutus.Contract.NewContract where
import Control.Applicative
import Data.Map (Map)
import Data.Bifunctor
@j-mueller
j-mueller / MultiSigStateMachine.hs
Created December 9, 2019 15:17
Playground MultiSigStateMachine
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE MultiParamTypeClasses #-}
import Control.Lens (makeClassyPrisms)
import qualified Ledger.Interval as Interval
import GHC.Generics (Generic)
import Ledger.Validation (PendingTx, PendingTx'(..))
import qualified Ledger.Validation as Validation
import qualified Ledger.Typed.Scripts as Scripts
import Ledger.Value (Value)
@j-mueller
j-mueller / plutus-use-cases-test.prof
Created December 5, 2019 12:45
use-cases profiling
This file has been truncated, but you can view the full file.
Thu Dec 5 13:26 2019 Time and Allocation Profiling Report (Final)
plutus-use-cases-test +RTS -p -RTS
total time = 103.89 secs (103889 ticks @ 1000 us, 1 processor)
total alloc = 135,255,702,776 bytes (excludes profiling overheads)
COST CENTRE MODULE SRC %time %alloc
renameTypeM Language.PlutusCore.Rename.Internal src/Language/PlutusCore/Rename/Internal.hs:(47,1)-(55,49) 12.8 12.4
@j-mueller
j-mueller / Contract.hs
Created November 14, 2019 15:44
Vesting (new playground)
{-# LANGUAGE FlexibleContexts #-}
-- A game with two players. Player 1 thinks of a secret word
-- and uses its hash, and the game validator script, to lock
-- some funds (the prize) in a pay-to-script transaction output.
-- Player 2 guesses the word by attempting to spend the transaction
-- output. If the guess is correct, the validator script releases the funds.
-- If it isn't, the funds stay locked.
import Control.Applicative ((<|>), Applicative(..))
import Control.Lens
import Control.Monad (when, void)
@j-mueller
j-mueller / Sample event log
Last active October 29, 2019 09:37
Sample event log
Events for W2:
• {contribute: (PubKey {getPubKey = fc51cd8e6218a1a38da47ed00230f0580816ed13ba3303ac5deb911548908025},Value {getValue = Map {unMap = [(,Map {unMap = [(,10)]})]}})}
• {tx: WriteTxSuccess: TxIdOf {getTxId = 380fbc4c5efc421c4c6759c1cd07910cc83451f6adbbd1b08341a2679a55f34b}}
• {address: ( 9f0318d20018a8181e18e018fe18ac18e818fb1884185e185e18c9185018a618f918ad18d81837091824184f187b1881131846185413189f184118a4ff
, Tx TxId: 9f18380f18bc184c185e18fc1842181c184c1867185918c118cd0718910c18c81834185118f618ad18bb18d118b01883184118a21867189a185518f3184bff:
{inputs: TxInOf {txInRef = TxOutRefOf {txOutRefId = TxIdOf {getTxId = 60ea4aabc8bee7b68555c4655e3a0e76f734b8f8725a13158157f6c97eafe284}, txOutRefIdx = 8}, txInType = ConsumePublicKeyAddress (PubKey {getPubKey = fc51cd8e6218a1a38da47ed00230f0580816ed13ba3303ac5deb911548908025})}
outputs: PayToPubKey: PubKey: fc51cd8e6218a1a38da47ed00230f0580816ed13ba3303ac5deb911548908025, PayToScript: "\252Q\20