-
Notifications
You must be signed in to change notification settings - Fork 36
/
insurance.go
53 lines (41 loc) · 1.4 KB
/
insurance.go
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
50
51
52
53
package types
import (
"fmt"
"time"
"github.com/ethereum/go-ethereum/common"
oracletypes "github.com/InjectiveLabs/sdk-go/chain/oracle/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
var InsuranceFundInitialSupply = sdk.NewIntWithDecimal(1, 18)
func NewInsuranceFund(
marketID common.Hash,
depositDenom, poolTokenDenom string,
redemptionNoticePeriodDuration time.Duration,
ticker, oracleBase, oracleQuote string, oracleType oracletypes.OracleType, expiry int64,
) *InsuranceFund {
return &InsuranceFund{
DepositDenom: depositDenom,
InsurancePoolTokenDenom: poolTokenDenom,
RedemptionNoticePeriodDuration: redemptionNoticePeriodDuration,
Balance: sdk.ZeroInt(),
TotalShare: sdk.ZeroInt(),
MarketId: marketID.Hex(),
MarketTicker: ticker,
OracleBase: oracleBase,
OracleQuote: oracleQuote,
OracleType: oracleType,
Expiry: expiry,
}
}
func (fund InsuranceFund) ShareDenom() string {
return fund.InsurancePoolTokenDenom
}
func (fund *InsuranceFund) AddTotalShare(amt sdk.Int) {
fund.TotalShare = fund.TotalShare.Add(amt)
}
func (fund *InsuranceFund) SubTotalShare(amt sdk.Int) {
fund.TotalShare = fund.TotalShare.Sub(amt)
}
func ShareDenomFromId(id uint64) string {
return fmt.Sprintf("share%d", id)
}