Created
April 20, 2020 20:22
-
-
Save mariano-aguero/231f4687a2cd7bd8e17d0a36b67f8534 to your computer and use it in GitHub Desktop.
pool.ligo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function depositImp(var store: store): return is | |
block { | |
if amount = 0mutez | |
then failwith("No tez transferred!"); | |
else skip; | |
// Setting the deposit to the sender | |
store := updateDeposit(amount, store); | |
// TODO: try to get the decimals property from the token contract | |
// The user receives a quantity of pTokens equal to the underlying tokens supplied, divided by the current Exchange Rate. | |
const amountToMint: int = natToInt(tezToNatWithTz(amount) / getExchangeRateInternal(store)) * pow(10, natToInt(store.token.tokenDecimals)); | |
const amountToMintInNat: nat = intToNat(amountToMint); | |
// Increment token supply | |
const newTokenSupply :nat = store.token.tokenSupply + amountToMintInNat; | |
patch store.token with record [tokenSupply = newTokenSupply]; | |
// mintTo tokens to the senderAddress | |
const tokenProxyMintToOperation: operation = tokenProxy(MintTo(sender, amountToMintInNat), store); | |
const operations : list (operation) = list [tokenProxyMintToOperation]; | |
} with(operations, store); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment