Skip to main content

Contract interaction

1. Stake 1inch#

Repositorylimit-order-settlement
Contractst1inch.sol
Contract address0x9A0C8Ff858d273f57072D714bca7411D717501D7
Methods
  • deposit(uint256 amount, uint256 duration)
  • depositWithPermit(uint256 amount, uint256 duration, bytes calldata permit)
  • depositFor(address account, uint256 amount, uint256 duration)
  • depositForWithPermit(address account, uint256 amount, uint256 duration, bytes calldata permit)
DescriptionStakes 1inch to get staking power according to the lock time
//Deposits 100 1inch with 1 day lockawait st1inch.deposit(ether('100'), time.duration.days('1'));

2. Register as a Resolver#

2.1 Register delegation pod#

Repositorylimit-order-settlement
ContractPowerPod.sol
Contract address0x9A0C8Ff858d273f57072D714bca7411D717501D7
MethodsaddPod(address pod)
DescriptionRegister pod usage for the tx sender. Needed for
  • Resolvers to enable resolver’s and delegated staking power usage for whitelisting
  • Stakers to enable staking power delegation
// register `delegation` pod usage a `resolver`await st1inch.connect(resolver).addPod(delegation.address);

2.2. Register delegation share token#

Repositorylimit-order-settlement
Contractst1inch.sol
Contract address0xAccfAc2339e16DC80c50d2fa81b5c2B049B4f947
Methodsregister(string memory name, string memory symbol, uint256 maxUserFarms)
DescriptionCreates a resolvers share token to count delegated staked power shares and accrue rewards
// Register resolver's token with name 'resolver token share' and symbol 'RTS'// allowing the maximum 3 farms runningawait delegation.register('resolver token share', 'RTS');

2.3. Set default farm#

Repositorylimit-order-settlement
ContractPowerPod.sol
Contract address0xAccfAc2339e16DC80c50d2fa81b5c2B049B4f947
MethodssetDefaultFarm(address farm)
DescriptionSetups the default farm to which all users delegating to this resolver are automatically joined
// Setups the default farm to which all users delegating to this resolver// are automatically joinedawait delegation.connect(resolver).setDefaultFarm(farm.address);

2.4. Delegate resolver’s staking power to self#

Repositorylimit-order-settlement
ContractPowerPod.sol
Contract address0xDAf782667d98d5069eE7ba139932945C4D08fDE9
Methodsdelegate(address delegatee)
Descriptiondelegate(address delegatee)
// Delegates all staking power to selfawait delegation.connect(resolver).delegate(resolver.address);

2.5. Whitelist resolver#

Repositorylimit-order-settlement
ContractWhitelistRegistry.sol
Contract address0xcb8308fcB7BC2f84ed1bEa2C016991D34de5cc77
Methodsregister()
DescriptionChecks if sender is eligible to be whitelisted and put it into the whitelist sorted by staking power descending
// Try to put the sender to the whitelistawait whitelist.connect(resolver).register();

3. FeeBank#

Repositorylimit-order-settlement
ContractFeeBank.sol
Contract address0xa0844e046a5B7Db55Bb8DcdFfbF0bBF9c6dc6546
Methods
  • deposit(uint256 amount)
  • depositFor(address account, uint256 amount)
  • depositWithPermit(uint256 amount, bytes calldata permit)
  • depositForWithPermit
DescriptionDeposits 1inch for fee deduction when filling orders
// Deposit fees to fee bankawait feeBank.connect(resolver).deposit(amount)

4. Resolving#

struct Order {        uint256 salt;        address makerAsset;        address takerAsset;        address maker;        address receiver;        address allowedSender;  // equals to Zero address on public orders        uint256 makingAmount;        uint256 takingAmount;        uint256 offsets;        // bytes makerAssetData;        // bytes takerAssetData;        // bytes getMakingAmount; // this.staticcall(abi.encodePacked(bytes, swapTakerAmount)) => (swapMakerAmount)        // bytes getTakingAmount; // this.staticcall(abi.encodePacked(bytes, swapMakerAmount)) => (swapTakerAmount)        // bytes predicate;       // this.staticcall(bytes) => (bool)        // bytes permit;          // On first fill: permit.1.call(abi.encodePacked(permit.selector, permit.2))        // bytes preInteraction;        // bytes postInteraction;        bytes interactions; // concat(makerAssetData, takerAssetData, getMakingAmount, getTakingAmount, predicate, permit, preIntercation, postInteraction)    }
Repositorylimit-order-settlement
ContractSettlement.sol
Contract address0xA88800CD213dA5Ae406ce248380802BD53b47647
Methods.settleOrders(bytes calldata data)
DescriptionSettles an order