Manual Unstaking from the deprecated AST Staking contract
I wrote this tutorial as a guide to those who are stuck on the deprecated AST contract.Manual UnstakingNavigate to the deprecated staking contract in etherscan (or the V2 contract) -> contract -> read contractCheck the AST balance in the contractUnder balanceOf, input your address and click query (querying the chain does not require gas) Check to ensure that the amount tallies with the amount of AST you have staked Note: The amount displayed is multiplied by 10,000 to account for the decimal ...
Hello World
Starting up a mirror account to explore using this medium as a way to write down some thoughts. Generally interested in building on the web3 space. So far, I’ve helped to build a new community-based DEX with other contributors on AirSwap. You can also find me helping out the Zapper community. I’m also currently exploring the world of coding and generative art, and most likely going to be using this as a way to journal some tutorials and learnings from my experiments. Will also leave some of m...

Dying of the Lights
Dying of the Lights envisions a futurescape where ancient civilizations have built megalithic structures to harness the power of the stars. These civilizations have long since passed away, but the ruins of these structures remain forever locked in a state of uncompletion. The project explores the relationship of structure and color to create otherworldly scenes. The code generates systems of swirling particles, with relationships first being defined by an underlying data structure tying both ...
<100 subscribers
Manual Unstaking from the deprecated AST Staking contract
I wrote this tutorial as a guide to those who are stuck on the deprecated AST contract.Manual UnstakingNavigate to the deprecated staking contract in etherscan (or the V2 contract) -> contract -> read contractCheck the AST balance in the contractUnder balanceOf, input your address and click query (querying the chain does not require gas) Check to ensure that the amount tallies with the amount of AST you have staked Note: The amount displayed is multiplied by 10,000 to account for the decimal ...
Hello World
Starting up a mirror account to explore using this medium as a way to write down some thoughts. Generally interested in building on the web3 space. So far, I’ve helped to build a new community-based DEX with other contributors on AirSwap. You can also find me helping out the Zapper community. I’m also currently exploring the world of coding and generative art, and most likely going to be using this as a way to journal some tutorials and learnings from my experiments. Will also leave some of m...

Dying of the Lights
Dying of the Lights envisions a futurescape where ancient civilizations have built megalithic structures to harness the power of the stars. These civilizations have long since passed away, but the ruins of these structures remain forever locked in a state of uncompletion. The project explores the relationship of structure and color to create otherworldly scenes. The code generates systems of swirling particles, with relationships first being defined by an underlying data structure tying both ...
Share Dialog
Share Dialog


Too often I get asked, “How do you start contributing to a DAO?“ Most people assume you need to be a dev to contribute to a DAO, but code is just one of the many things which DAOs need. Crucial to DAO operations is figuring out what needs to be done to get our functions as decentralized, as autonomous, and as organized as possible. One such task was to design the AirSwap V4 staking contract.
The AirSwap protocols consist of DAO and DEX components. The DAO builds the DEX, which then funds the DAO. Core to the AirSwap DAO protocol is the staking contract. By staking AST, members signal their intent to participate in governance and help steer the protocol to become the standard peer-to-peer trading system. A good staking contract design needs to be intuitive and accessible (gas-wise) to enable smaller stakers to participate in the AirSwap ecosystem as well.

Staking in AirSwap is a linear vesting over a period of 20 weeks. This logic is pretty simple, until you consider multiple stakes being vested at the same time. For example, Alice stakes 100 AST at week 0, 200 AST at week 1 and 500 AST at week 7. How many tokens are unlocked at week 10?

To allow the contract to unlock the correct number of tokens would require looping over each stake and calculating how much tokens are vested as a function of
Initial staked amount
Initial time of stake
Current block time
Each loop requires additional gas each time the function is called. This means small stakers cannot slowly accumulate their positions without requiring a huge amount of gas to unstake later.
Over the course of spring 2023, I worked with smartcontrart to radically redesigned the staking contract based on a set of heuristics that the user would expect.
Max duration = 20 weeks.
Deposits should not change available staking balance.
Deposits should increase the time left to unstake.
Withdrawals should decrease the available staking balance.
Withdrawals should NOT change the time left to unstake.
Our final design tracked 3 variables for each staking address (vs 2 variables per staking tx): Staked balance, time of initial stake, time of full vest. Instead of creating a new stake for each tx, additional stakes simply increase the time to full vest (up to 20 weeks) based on the additional amount staked relative to its current balance.

With the changes, we no longer need to loop over every single staking tx made but can simply update 3 variables. Our new dynamic staking contract has now been implemented in AirSwap V4, resulting in significant gas savings to DAO members!
You don’t need to be a dev to help out in DAOs! In AirSwap we had marketers, operations, designers, and devs all working together to promote our mission of fully decentralized peer-to-peer swap protocols.
It’s fun and you get to learn loads! If anyone wants to check out what AirSwap is doing, head over to our discord and just chat with the folks there
Too often I get asked, “How do you start contributing to a DAO?“ Most people assume you need to be a dev to contribute to a DAO, but code is just one of the many things which DAOs need. Crucial to DAO operations is figuring out what needs to be done to get our functions as decentralized, as autonomous, and as organized as possible. One such task was to design the AirSwap V4 staking contract.
The AirSwap protocols consist of DAO and DEX components. The DAO builds the DEX, which then funds the DAO. Core to the AirSwap DAO protocol is the staking contract. By staking AST, members signal their intent to participate in governance and help steer the protocol to become the standard peer-to-peer trading system. A good staking contract design needs to be intuitive and accessible (gas-wise) to enable smaller stakers to participate in the AirSwap ecosystem as well.

Staking in AirSwap is a linear vesting over a period of 20 weeks. This logic is pretty simple, until you consider multiple stakes being vested at the same time. For example, Alice stakes 100 AST at week 0, 200 AST at week 1 and 500 AST at week 7. How many tokens are unlocked at week 10?

To allow the contract to unlock the correct number of tokens would require looping over each stake and calculating how much tokens are vested as a function of
Initial staked amount
Initial time of stake
Current block time
Each loop requires additional gas each time the function is called. This means small stakers cannot slowly accumulate their positions without requiring a huge amount of gas to unstake later.
Over the course of spring 2023, I worked with smartcontrart to radically redesigned the staking contract based on a set of heuristics that the user would expect.
Max duration = 20 weeks.
Deposits should not change available staking balance.
Deposits should increase the time left to unstake.
Withdrawals should decrease the available staking balance.
Withdrawals should NOT change the time left to unstake.
Our final design tracked 3 variables for each staking address (vs 2 variables per staking tx): Staked balance, time of initial stake, time of full vest. Instead of creating a new stake for each tx, additional stakes simply increase the time to full vest (up to 20 weeks) based on the additional amount staked relative to its current balance.

With the changes, we no longer need to loop over every single staking tx made but can simply update 3 variables. Our new dynamic staking contract has now been implemented in AirSwap V4, resulting in significant gas savings to DAO members!
You don’t need to be a dev to help out in DAOs! In AirSwap we had marketers, operations, designers, and devs all working together to promote our mission of fully decentralized peer-to-peer swap protocols.
It’s fun and you get to learn loads! If anyone wants to check out what AirSwap is doing, head over to our discord and just chat with the folks there
No comments yet