These steps initialize Unicorn Power farming:
- Approve staking 1INCH for 1inch contract.
- Stake 1INCH to gain Unicorn Power.
- Add a delegation pod to enable power delegation.
- Register yourself to be a resolver.
- (Optional) Change the default farm to a new farm.
- Delegate available Unicorn Power to yourself.
- Register a resolver at the whitelist.
- Set up a worker to settle orders.
Setup script example
JavaScript
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
const { ether, time } = require('@1inch/solidity-utils');
const { ethers } = require('hardhat');
// Setup environment
const inch = await ethers.getContractAt(
'IERC20',
'0x111111111117dc0aa78b770fa6a738034120c302',
);
const st1inch = await ethers.getContractAt(
'IERC20',
'0x9a0c8ff858d273f57072d714bca7411d717501d7',
);
const powerPod = await ethers.getContractAt(
'IERC20',
'0xaccfac2339e16dc80c50d2fa81b5c2b049b4f947',
);
const whitelist = await ethers.getContractAt(
'WhitelistRegistry',
'0xF55684BC536487394B423e70567413faB8e45E26',
);
const stakeAmount = ether('1000000');
const lockTime = time.duration.years('2');
const myShareToken = {
name: 'MyShareTokenName',
symbol: 'MST',
};
const worker = '...'; // Address of wallet which send transaction
const [resolver] = await ethers.getSigners();
// Ethers setup script
// approve 1inch staking
await await inch.connect(resolver).approve(st1inch.address, stakeAmount);
// stake 1inch token
await (await st1inch.connect(resolver).deposit(stakeAmount, lockTime)).wait();
// add delegation pod to
// 1. make it possible for any user to delegate staking power to
// the resolver's account
// 2. make it possible for a resolver to allocate its staking power for itself
await (await st1inch.connect(resolver).addPod(powerPod.address)).wait();
// register resolver's delegation token to count stakers' shares and rewards
await (
await powerPod
.connect(resolver)
.functions[
'register(string,string)'
](myShareToken.name, myShareToken.symbol)
).wait();
// Delegate staked power to self
await (await powerPod.connect(resolver).delegate(resolver.address)).wait();
// Whitelist resolver (there should be enough unicorn power to be in top 10)
await (await whitelist.connect(resolver).register()).wait();
// Add worker address from which order settlement will be executed
await (await whitelist.connect(resolver).promote(1, worker)).wait();