-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathwasabee_test.go
More file actions
49 lines (45 loc) · 1.55 KB
/
Copy pathwasabee_test.go
File metadata and controls
49 lines (45 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package protocols
import (
"math/big"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/rs/zerolog"
"github.com/shopspring/decimal"
"github.com/infrared-dao/protocols/internal/sc"
"github.com/infrared-dao/protocols/multicall3"
)
func TestWasabee_BatchPathMatchesLegacy(t *testing.T) {
t.Parallel()
p0, _ := decimal.NewFromString("1.00")
p1, _ := decimal.NewFromString("2.00")
w := &WasabeeLPPriceProvider{
address: common.HexToAddress("0xdddddddddddddddddddddddddddddddddddddddd"),
logger: zerolog.Nop(),
config: &WasabeeConfig{
Token0: "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
Token1: "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
LPTDecimals: 18,
},
priceMap: map[string]Price{
"0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa": {Decimals: 18, Price: p0},
"0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb": {Decimals: 18, Price: p1},
},
}
totalSupply := new(big.Int).Mul(big.NewInt(100), bigPow10(18))
a0 := new(big.Int).Mul(big.NewInt(50), bigPow10(18))
a1 := new(big.Int).Mul(big.NewInt(50), bigPow10(18))
wantDirect, _ := w.computeLPPriceFromReads(totalSupply, a0, a1)
abi, _ := sc.WasabeeVaultMetaData.GetAbi()
encTS, _ := abi.Methods["totalSupply"].Outputs.Pack(totalSupply)
encGTA, _ := abi.Methods["getTotalAmounts"].Outputs.Pack(a0, a1)
got, err := w.ComputePrice([]multicall3.Result3{
{Success: true, ReturnData: encTS},
{Success: true, ReturnData: encGTA},
})
if err != nil {
t.Fatalf("ComputePrice: %v", err)
}
if !got.Equal(wantDirect) {
t.Errorf("batch %s != direct %s", got, wantDirect)
}
}