Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
fix fusion script
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelkurmacheff committed Dec 26, 2022
1 parent b44f89b commit 7fce71a
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions docs/fusion-swap/contracts-interaction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ sidebar_position: 3
## Setup script example

```javascript
const { ether, time } = require('@1inch/solidity-utils');
const { ethers } = require('hardhat');

// Setup envirement
const inch = await ethers.getContractAt('IERC20', '0x111111111117dc0aa78b770fa6a738034120c302');
const st1inch = await ethers.getContractAt('IERC20', '0x9a0c8ff858d273f57072d714bca7411d717501d7');
const powerPod = await ethers.getContractAt('IERC20', '0xdaf782667d98d5069ee7ba139932945c4d08fde9');
const whitelist = await ethers.getContractAt('WhitelistRegistry', '0xa49ecb28cc8ab39659be2bfb6f7b86f0c4461a0b');

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
Expand All @@ -17,30 +35,34 @@ await (await st1inch.connect(resolver).deposit(stakeAmount, lockTime)).wait();
// 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(delegation.address)).wait();
await (await st1inch.connect(resolver).addPod(powerPod.address)).wait();

// register resolver's delegation token to count stakers' shares and rewards
await (
await delegation
await powerPod
.connect(resolver)
.functions['register(string,string)'](
'MyShareTokenName',
'MST',
myShareToken.name,
myShareToken.symbol,
)
).wait();

// Set default rewards farm
// Optional, needed to incentivize staker for delegation
await (await delegation.connect(resolver).setDefaultFarm(farm.address)).wait();
const shareTokenAddress = await powerPod.registration(resolver.address);
const FarmingPod = await ethers.getContractFactory('FarmingPod');
const gift = await ethers.getContractAt('IERC20', '...'); // Your gift token address
const farm = await FarmingPod.deploy(shareTokenAddress.address, gift.address);
await (await powerPod.connect(resolver).setDefaultFarm(farm.address)).wait();

// Delegate staked power to self
await (await delegation.connect(resolver).delegate(resolver.address)).wait();
await (await powerPod.connect(resolver).delegate(resolver.address)).wait();

// Whitelist resolver (there should be enough staked power to be in top 5)
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.address)).wait();
await (await whitelist.connect(resolver).promote(1, worker)).wait();
```


Expand Down

0 comments on commit 7fce71a

Please sign in to comment.