-
Notifications
You must be signed in to change notification settings - Fork 2
/
market_exec.go
87 lines (75 loc) · 1.83 KB
/
market_exec.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package market
import (
"context"
"github.com/frostornge/terra-go"
cosmostypes "github.com/cosmos/cosmos-sdk/types"
)
var _ Executor = (*market)(nil)
type Executor interface {
BorrowStable(
ctx context.Context,
acc terra.Account,
amount cosmostypes.Int,
to *cosmostypes.AccAddress,
) (cosmostypes.TxResponse, error)
RepayStable(
ctx context.Context,
acc terra.Account,
amount cosmostypes.Coin,
) (cosmostypes.TxResponse, error)
DepositStable(
ctx context.Context,
acc terra.Account,
amount cosmostypes.Coin,
) (cosmostypes.TxResponse, error)
RedeemStable(
ctx context.Context,
acc terra.Account,
amount cosmostypes.Int,
) (cosmostypes.TxResponse, error)
}
func (m market) BorrowStable(
ctx context.Context,
acc terra.Account,
amount cosmostypes.Int,
to *cosmostypes.AccAddress,
) (cosmostypes.TxResponse, error) {
msgs, err := m.BorrowStableMsg(acc, amount, to)
if err != nil {
return cosmostypes.TxResponse{}, err
}
return m.Execute(ctx, acc, msgs, nil, nil)
}
func (m market) RepayStable(
ctx context.Context,
acc terra.Account,
amount cosmostypes.Coin,
) (cosmostypes.TxResponse, error) {
msgs, err := m.RepayStableMsg(acc, amount)
if err != nil {
return cosmostypes.TxResponse{}, err
}
return m.Execute(ctx, acc, msgs, nil, nil)
}
func (m market) DepositStable(
ctx context.Context,
acc terra.Account,
amount cosmostypes.Coin,
) (cosmostypes.TxResponse, error) {
msgs, err := m.DepositStableMsg(acc, amount)
if err != nil {
return cosmostypes.TxResponse{}, err
}
return m.Execute(ctx, acc, msgs, nil, nil)
}
func (m market) RedeemStable(
ctx context.Context,
acc terra.Account,
amount cosmostypes.Int,
) (cosmostypes.TxResponse, error) {
msgs, err := m.RedeemStableMsg(acc, amount)
if err != nil {
return cosmostypes.TxResponse{}, err
}
return m.Execute(ctx, acc, msgs, nil, nil)
}