user1983: adaOf encodes Lovelace/Ada ratio in phantom type Micro
adaOf :: Micro -> Ada
type Micro = Fixed E6
newtype Fixed (a :: k) = MkFixed Integer

Question: Being that the ratio is already encoded in the type, can I somehow get it, such that I can have a function that takes actual Ada token quantity -- not Lovelace quantity -- and gives back Ada, without hardcoding?
f :: Integer -> Ada
f adaQty = Lovelace (1_000_000 * n) -- don't really want to do this

I actually found the constant in the plutus repo:
lovelacePerAda = Constant 1000000


user387: Use adaOf
In a GHCi session with plutus-ledger-api in scope:
> import Plutus.V1.Ledger.Ada
> adaOf 1
Lovelace {getLovelace = 1000000}


1983: <p><code>adaOf</code> encodes Lovelace/Ada ratio in <a href="https://github.com/input-output-hk/plutus/blob/12099239d5bae033c914387257cb8d2c268838b3/plutus-ledger-api/src/Plutus/V1/Ledger/Ada.hs#L100" rel="nofollow noreferrer">phantom type <code>Micro</code></a></p>
<pre><code>adaOf :: Micro -&gt; Ada
type Micro = Fixed E6
newtype Fixed (a :: k) = MkFixed Integer
</code></pre>
<p>Question: Being that the ratio is already encoded in the type, can I somehow get it, such that I can have a function that takes actual <code>Ada</code> token quantity -- not <code>Lovelace</code> quantity -- and gives back <code>Ada</code>, <strong>without</strong> hardcoding?</p>
<pre><code>f :: Integer -&gt; Ada
f adaQty = Lovelace (1_000_000 * n) -- don't really want to do this
</code></pre>
<p>I actually found <a href="https://github.com/input-output-hk/plutus/blob/cc953b36ec9681cc28edf1accf08f48a31238e69/marlowe-playground-server/contracts/Swap.hs#L15" rel="nofollow noreferrer">the constant</a> in the <code>plutus</code> repo:</p>
<pre><code>lovelacePerAda = Constant 1000000
</code></pre>
 387: <p>Use <code>adaOf</code></p>
<p>In a GHCi session with <code>plutus-ledger-api</code> in scope:</p>
<pre><code>&gt; import Plutus.V1.Ledger.Ada
&gt; adaOf 1
Lovelace {getLovelace = 1000000}
</code></pre>
