-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdflow.mo
92 lines (89 loc) · 3.25 KB
/
dflow.mo
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
88
89
90
91
92
import Result "mo:base/Result";
module {
public type FlowType = {
#Constant;
};
public type Flow = {
id : Text;
startTime : Nat64;
deposit : Nat;
sender : Principal;
flowRate : Nat;
flowType : FlowType;
settleFunds : Nat;
receiver : Principal;
settleTime : Nat64;
};
public type InitArgs = {
cap : ?Principal;
fee : Nat;
decimals : Nat8;
owner : ?Principal;
logo : Text;
name : Text;
underlyingToken : ?Principal;
symbol : Text;
};
public type Metadata = {
fee : Nat;
decimals : Nat8;
owner : Principal;
logo : Text;
name : Text;
totalSupply : Nat;
symbol : Text;
};
public type TxReceipt = { #Ok : Nat; #Err : TxError };
public type TxError = {
#InsufficientAllowance;
#InsufficientBalance;
#ErrorOperationStyle;
#Unauthorized;
#LedgerTrap;
#ErrorTo;
#Other : Text;
#BlockUsed;
#AmountTooSmall;
};
public type UserFlowsResponse = {
receiveFlows : [Flow];
sendFlows : [Flow];
};
public type UserInfoResponse = {
balance : Nat;
receiveFlows : [Flow];
liquidationDate : Nat64;
flowRate : Int;
sendFlows : [Flow];
};
public type DToken = actor {
addApp : shared(app: Principal) -> async TxReceipt;
addAuth : shared(user: Principal) -> async TxReceipt;
addOperator : shared(op: Principal) -> async TxReceipt;
allowance : (owner: Principal, spender: Principal) -> async Nat;
approve : shared(spender: Principal, value: Nat) -> async TxReceipt;
balanceOf : (user: Principal) -> async Nat;
burn : shared(user: Principal, value: Nat) -> async TxReceipt;
createFlow : shared(flowType: FlowType, sender: Principal, receiver: Principal, flowRate: Nat) -> async Result.Result<Text, TxError>;
deleteFlow : shared(id: Text) -> async TxReceipt;
getApps : () -> async [Principal];
getFlow : (id: Text) -> async ?Flow;
getLiquidationUser : () -> async [Principal];
getMetadata : () -> async [Metadata];
getUnderlyingToken : () -> async ?Principal;
getUserFlowRate : (user: Principal) -> async Int;
getUserFlows : (user: Principal) -> async UserFlowsResponse;
getUserInfo : (user: Principal) -> async UserInfoResponse;
getUserLiquidationDate : (user: Principal) -> async Nat64;
isOperator : (owner: Principal, spender: Principal) -> async Bool;
liquidateUser : shared(user: Principal) -> async TxReceipt;
mint : shared(user: Principal, value: Nat) -> async TxReceipt;
removeApp : shared(app: Principal) -> async TxReceipt;
removeAuth : shared(user: Principal) -> async TxReceipt;
removeOperator : shared(user: Principal) -> async TxReceipt;
setUnderlyingToken : shared(token: ?Principal) -> async ();
transfer : shared(to: Principal, value: Nat) -> async TxReceipt;
transferFrom : shared(from: Principal, to: Principal, value: Nat) -> async TxReceipt;
updateFlow : shared(id: Text, flowRate: Nat) -> async TxReceipt;
};
}