collateral.gno
0.65 Kb · 24 lines
1package lastcall
2
3import "gno.land/p/nt/grc20/v0"
4
5// tUSD is the test-USD collateral token. 6 decimals, so one tUSD unit is
6// 1_000000 and token amounts line up 1:1 with micro-USD price quotes.
7var (
8 usd *grc20.Token
9 usdLedger *grc20.PrivateLedger
10)
11
12func initUSD(cur realm) {
13 usd, usdLedger = grc20.NewToken("Test USD", "tUSD", 6, nextTokID.Next(), cur)
14}
15
16// FaucetUSD mints 10,000 tUSD to the caller. Open faucet — demo only.
17func FaucetUSD(cur realm) {
18 caller := cur.Previous().Address()
19 if err := usdLedger.Mint(caller, 10_000_000000); err != nil {
20 panic(err.Error())
21 }
22}
23
24func BalanceUSD(owner address) int64 { return usd.BalanceOf(owner) }