-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathOpdexStakingMarket.cs
More file actions
47 lines (36 loc) · 1.47 KB
/
OpdexStakingMarket.cs
File metadata and controls
47 lines (36 loc) · 1.47 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
using Stratis.SmartContracts;
/// <summary>
/// Staking market contract used for managing available staking pools.
/// </summary>
public class OpdexStakingMarket : OpdexMarket, IOpdexStakingMarket
{
/// <summary>
/// Constructor initializing the staking market.
/// </summary>
/// <param name="state">Smart contract state.</param>
/// <param name="transactionFee">The market transaction fee, 0-10 equal to 0-1%.</param>
/// <param name="stakingToken">The address of the staking token.</param>
public OpdexStakingMarket(ISmartContractState state, uint transactionFee, Address stakingToken) : base(state, transactionFee)
{
StakingToken = stakingToken;
}
/// <inheritdoc />
public Address StakingToken
{
get => State.GetAddress(MarketStateKeys.StakingToken);
private set => State.SetAddress(MarketStateKeys.StakingToken, value);
}
/// <inheritdoc />
public override Address CreatePool(Address token)
{
Assert(State.IsContract(token), "OPDEX: INVALID_TOKEN");
var pool = GetPool(token);
Assert(pool == Address.Zero, "OPDEX: POOL_EXISTS");
var poolResponse = Create<OpdexStakingPool>(0, new object[] {token, TransactionFee, StakingToken});
Assert(poolResponse.Success, "OPDEX: INVALID_POOL");
pool = poolResponse.NewContractAddress;
SetPool(token, pool);
Log(new CreateLiquidityPoolLog { Token = token, Pool = pool });
return pool;
}
}