1package amm23import (4 "testing"56 "gno.land/p/nt/testutils/v0"7 "gno.land/p/nt/uassert/v0"8)910// A fixed four-step profile, declared in order so `gno test -v` reports one11// `--- GAS:` figure per operation. The same four steps exist verbatim in v1,12// so the difference between the two runs is the cost of the share accounting13// and nothing else. See moul/gno-contracts#135.1415var (16 gasAlice = testutils.TestAddress("gas-alice")17 gasBob = testutils.TestAddress("gas-bob")18)1920// TestGas0Fund keeps the fixture cost (minting and approving both tokens for21// both actors) out of the four measured numbers.22func TestGas0Fund(t *testing.T) {23 reset()24 fund(gasAlice, 10_000_000)25 fund(gasBob, 10_000_000)26}2728func TestGas1Seed(cur realm, t *testing.T) {29 testing.SetRealm(testing.NewUserRealm(gasAlice))30 uassert.Equal(t, int64(1_000_000), AddLiquidity(cross(cur), keyAAA, keyBBB, 1_000_000, 4_000_000))31}3233func TestGas2Swap(cur realm, t *testing.T) {34 testing.SetRealm(testing.NewUserRealm(gasAlice))35 uassert.Equal(t, int64(362_644), Swap(cross(cur), keyAAA, keyBBB, 100_000, 1))36}3738func TestGas3Join(cur realm, t *testing.T) {39 testing.SetRealm(testing.NewUserRealm(gasBob))40 uassert.Equal(t, int64(90_908), AddLiquidity(cross(cur), keyAAA, keyBBB, 100_000, 1_000_000))41}4243func TestGas4Exit(cur realm, t *testing.T) {44 testing.SetRealm(testing.NewUserRealm(gasBob))45 held := SharesOf(keyAAA, keyBBB, gasBob)46 uassert.Equal(t, int64(90_908), held)47 RemoveLiquidity(cross(cur), keyAAA, keyBBB, held)48 uassert.Equal(t, int64(0), SharesOf(keyAAA, keyBBB, gasBob))49}50AddLiquidity(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, keyA string, keyB string, maxA int64, maxB int64) int64
AllowanceLP(keyA string, keyB string, owner string, spender string) int64
AmountOut(amountIn int64, reserveIn int64, reserveOut int64) int64
ApproveLP(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, keyA string, keyB string, spender string, amount int64)
LPToken(keyA string, keyB string) string
PoolCount() int
Quote(keyIn string, keyOut string, amountIn int64) int64
RemoveLiquidity(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, keyA string, keyB string, shares int64) (int64, int64)
Render(path string) string
Reserves(keyA string, keyB string) (int64, int64)
SharesOf(keyA string, keyB string, owner string) int64
Swap(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, keyIn string, keyOut string, amountIn int64, minOut int64) int64
TotalShares(keyA string, keyB string) int64
TransferFromLP(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, keyA string, keyB string, from string, to string, amount int64)
TransferLP(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, keyA string, keyB string, to string, amount int64)
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.