Skip to content

A contract that uses Chainlink Automation to monitor withdrawals from the Chainlink Staking Pool and immediately deposit when space is available.

Notifications You must be signed in to change notification settings

67-6f-64/chainlink-auto-stake

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chainlink Auto Stake

This is a smart contract that monitors the Chainlink staking pool for withdrawals and uses Chainlink Automation to make deposits.

Video Demonstration

Tutorial video

Table of Contents

Overview

The Chainlink v0.2 Community Staking Pool recently opened for early access and filled up in a matter of hours. Unlike the v0.1 iteration, v0.2 gives participants the option to unstake their tokens, freeing up space for other participants.

Chainlink Auto Stake is a contract that uses Chainlink Automation to monitor the Community Staking Pool contract for available space and immediately deposit LINK tokens into it when that space appears.

Custom Logic Automation is used.

The checkUpkeep() function returns true if the amount returned by the staking pool contract's getTotalPrincipal() function returns less than its getMaxPoolSize() function.

The performUpkeep() function calls the transferAndCall() function on the LINK token contract to stake LINK tokens with the staking pool contract. The amount of tokens staked depends on the available space in the staking pool and the balance of the contract. If the available space is less than the balance, an amount equivalent to the available space will be staked. Whereas if the available space is more than the balance, the full balance will be staked.

An ICommunityStakingPool interface is used for interacting with the staking pool contract.

onlyOwner modifiers are used to ensure only the owner of a contract can migrate, unstake and withdraw their LINK tokens.

Usage

To use this contract it must be funded with LINK tokens and registered with Chainlink Custom Logic Automation.

Deployment Instructions

Please provide a .env file that includes a $PRIVATE_KEY and $RPC_URL.

Then to deploy the Chainlink Auto Stake contract run the following command:

forge script script/DeployChainlinkAutoStake.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast

The Mock Staking Pool contract can be deployed for testing purposes with the following command:

forge script script/DeployMockStakingPool.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast

Deployments/Transactions

MockStakingPool on Sepolia

ChainlinkAutoStake on Sepolia

Tx of Automation depositing into staking pool when space available

Automation registration

License

This project is licensed under the MIT License.

About

A contract that uses Chainlink Automation to monitor withdrawals from the Chainlink Staking Pool and immediately deposit when space is available.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Solidity 100.0%