-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.rsh
80 lines (64 loc) · 1.58 KB
/
index.rsh
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
"reach 0.1";
const InitialStateObj = {
stakeToken: Token,
rewardToken: Token,
underlyingFarmId: Contract,
creatorFee: UInt,
};
export const main = Reach.App(() => {
const Common = {
...hasConsoleLogger,
deployed: Fun([], Null),
};
const Creator = Participant("Creator", {
...Common,
getParams: Fun(
[],
Object({
...InitialStateObj,
})
),
});
const User = Participant("User", {
...Common,
});
void User;
const Api = API({
stake: Fun([UInt], Null),
});
init();
Creator.only(() => {
const { stakeToken, rewardToken, underlyingFarmId, creatorFee } =
declassify(interact.getParams());
assume(stakeToken != rewardToken);
});
Creator.publish(stakeToken, rewardToken, underlyingFarmId, creatorFee);
const FarmLocalState = Struct([
["staked", UInt],
["reward", UInt],
]);
const underlyingFarmCtc = remote(underlyingFarmId, {
stake: Fun([UInt], FarmLocalState),
claim: Fun([], FarmLocalState),
});
each([Creator, User], () => {
interact.deployed();
});
const [totalStaked, lastUpdateBlock] = parallelReduce([0, 0])
.invariant(true)
.while(true)
.paySpec([stakeToken, rewardToken])
.api(
Api.stake,
(_) => {
assume(true);
}, // TODO
(toStake) => [0, [toStake, stakeToken], [0, rewardToken]],
(toStake, callback) => {
callback(null);
const stateOfUnderlyingFarm = underlyingFarmCtc.claim.withBill([rewardToken])();
return [totalStaked + toStake, lastUpdateBlock + 1];
}
)
commit();
});