Skip to content

Commit

Permalink
Staking migration updates (#148)
Browse files Browse the repository at this point in the history
* update contract address, uncomment MigrationModal in App

* updated contract addresses. Added v4.0 and v4.2 balances to header

* update display message on staking modal (ManageStake) if user has v4.1 sAST balance

* useStakesForAccount hoo checks for v4.1 and v4.2 balances and maturity of staked AST

* add checks to see if user can unstake deprecated v4 sAST balance

* update actionsButtonObject with contract write functions for unstaking v4 sAST

* formula to convert staking maturity to days and minutes

* added v4 unstake function to context box in ManageStake

* converted formatted stakingAmount values from numbers to bigints

* fixed stakingAmount formatting. Cleaned up canStake, canUnstake, needsApproval variables in StakingModal.tsx

* fixed decimals in contract write functions. Fixed unstakeV4Sast in TransactionTracker. Removed comments in code

* combined v4 and v4.2 sAST balance in header

* remove comments

* remove unused css class froom button

* undo temp changes in MigrationModal and undo rounding down in formatNumber

* remove styles in piebar

* use BigNumber.js to correctly format max sAST and AST balances

* changed numbers to bigints in contract read functions. Fixed formatting of stakingAmount in StakingModal

* Update v3 staking contract address

* change v4 staking balance and time duration to white text

* fixed NaN when unstaking transaction was cancelled from content box

* set form to 0 if unstaking from legacy v4 contract

* fixed Numberinput from NaN to 0 after unstaking v4 deprecated sAST

* fixed rendering of contentBox on staking modal. Added official announcement link to pending v4 stake box

* Fix checking v3 available when no v3 balance

* Only simulate a transaciton when there's an amount

* Only run sim for current tab

* update contract addresses to latest, update piebar to include deprecated v4 balances, update content boxes in ManageStake.tsx

* added variable to useStakingModalStore hook to handle v4 unstaking balance in TransactionTracker after user successfully unstakes v4

* changed v4UnstakingBalance in stakingModalStore from bigint to number to fix useEffect error

* disable useUnstakeSast for v4 if maturity of stake is not 0

* add punctuation to contentBox

* Fix unstake enable

---------

Co-authored-by: greypixel <greypixel@gpxl.tech>
  • Loading branch information
mikestarrdev and gpxl-dev committed Feb 8, 2024
1 parent 11b1370 commit d1a49f9
Show file tree
Hide file tree
Showing 24 changed files with 576 additions and 384 deletions.
3 changes: 2 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useAccount } from "wagmi";
import { MigrationModal } from "./features/staking/MigrationModal";
import { DisconnectedState } from "./features/structure/DisconnectedState";
import { Header } from "./features/structure/Header";
import { ClaimFloat } from "./features/votes/ClaimFloat";
Expand All @@ -17,7 +18,7 @@ function App() {
<main className="mx-auto flex w-[808px] p-0 xs:p-2 max-w-full flex-col flex-1">
{isConnected ? <VoteList /> : <DisconnectedState />}
</main>
{/* <MigrationModal /> */}
<MigrationModal />
<ClaimFloat onClaimClicked={() => setShowClaimModal(true)} />
</div>
);
Expand Down
29 changes: 22 additions & 7 deletions src/config/ContractAddresses.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
export enum ContractTypes {
AirSwapToken,
AirSwapStaking,
AirSwapStaking_latest,
AirSwapPool,
AirSwapV3Staking_deprecated,
AirSwapV4Staking_deprecated,
}

type ContractList = { [k in ContractTypes]?: `0x${string}` };

export const contractAddressesByChain: Record<number, ContractList> = {
1: {
[ContractTypes.AirSwapToken]: "0x27054b13b1B798B345b591a4d22e6562d47eA75a",
[ContractTypes.AirSwapStaking]:
"0x9fc450F9AfE2833Eb44f9A1369Ab3678D3929860",
[ContractTypes.AirSwapStaking_latest]:
"0x8Bf384296A009723435aD5E8203DA5736b895038",
[ContractTypes.AirSwapV3Staking_deprecated]:
"0x6d88B09805b90dad911E5C5A512eEDd984D6860B",
[ContractTypes.AirSwapV4Staking_deprecated]:
"0x9fc450F9AfE2833Eb44f9A1369Ab3678D3929860",
[ContractTypes.AirSwapPool]: "0xbbcec987e4c189fcbab0a2534c77b3ba89229f11",
},
5: {
// goerli
[ContractTypes.AirSwapToken]: "0x1a1ec25DC08e98e5E93F1104B5e5cdD298707d31",
[ContractTypes.AirSwapToken]: "0x4092D6DBA9abB7450B9d91aA7ED2712935D63b39",
[ContractTypes.AirSwapV3Staking_deprecated]:
"0x51F372bE64F0612532F28142cECF8F204B272622",
[ContractTypes.AirSwapStaking]:
"0x3BeC6526366cb2C2A609eb2bCeC8A696C141a33e",
"0xd913469D9FCdB84a6a8fF049765e99f4C9146B4F",
[ContractTypes.AirSwapV4Staking_deprecated]:
"0x20aaebad8c7c6ffb6fdaa5a622c399561562beea",
[ContractTypes.AirSwapStaking_latest]:
"0xaCfd509f5785E57257B2eAc3AE4Ef080074d37c3",
[ContractTypes.AirSwapPool]: "0xbbcec987e4c189fcbab0a2534c77b3ba89229f11",
},
56: {
Expand All @@ -33,8 +38,18 @@ export const contractAddressesByChain: Record<number, ContractList> = {
// polygon
[ContractTypes.AirSwapPool]: "0xbbcec987e4c189fcbab0a2534c77b3ba89229f11",
},
17000: {
// holesky
[ContractTypes.AirSwapStaking_latest]:
"0x8Bf384296A009723435aD5E8203DA5736b895038",
},
43114: {
// avax
[ContractTypes.AirSwapPool]: "0xbbcec987e4c189fcbab0a2534c77b3ba89229f11",
},
111555111: {
// sepolia
[ContractTypes.AirSwapStaking_latest]:
"0x8Bf384296A009723435aD5E8203DA5736b895038",
},
};
83 changes: 39 additions & 44 deletions src/contracts/stakingAbi.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
export const stakingAbi = [
{
inputs: [
{ internalType: "contract ERC20", name: "_token", type: "address" },
{ internalType: "string", name: "_name", type: "string" },
{ internalType: "string", name: "_symbol", type: "string" },
{ internalType: "uint256", name: "_duration", type: "uint256" },
{ internalType: "uint256", name: "_minDelay", type: "uint256" },
{
internalType: "contract ERC20",
name: "_stakingToken",
type: "address",
},
{ internalType: "uint256", name: "_stakingDuration", type: "uint256" },
{
internalType: "uint256",
name: "_minDurationChangeDelay",
type: "uint256",
},
],
stateMutability: "nonpayable",
type: "constructor",
Expand Down Expand Up @@ -61,12 +69,7 @@ export const stakingAbi = [
{ inputs: [], name: "TimelockActive", type: "error" },
{ inputs: [], name: "TimelockInactive", type: "error" },
{ inputs: [], name: "Timelocked", type: "error" },
{
anonymous: false,
inputs: [],
name: "CancelDurationChange",
type: "event",
},
{ anonymous: false, inputs: [], name: "CancelDurationChange", type: "event" },
{
anonymous: false,
inputs: [
Expand Down Expand Up @@ -153,18 +156,8 @@ export const stakingAbi = [
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "from",
type: "address",
},
{
indexed: true,
internalType: "address",
name: "to",
type: "address",
},
{ indexed: true, internalType: "address", name: "from", type: "address" },
{ indexed: true, internalType: "address", name: "to", type: "address" },
{
indexed: false,
internalType: "uint256",
Expand All @@ -183,14 +176,14 @@ export const stakingAbi = [
type: "function",
},
{
inputs: [{ internalType: "address", name: "account", type: "address" }],
inputs: [{ internalType: "address", name: "_account", type: "address" }],
name: "available",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
{
inputs: [{ internalType: "address", name: "account", type: "address" }],
inputs: [{ internalType: "address", name: "_account", type: "address" }],
name: "balanceOf",
outputs: [{ internalType: "uint256", name: "total", type: "uint256" }],
stateMutability: "view",
Expand Down Expand Up @@ -218,14 +211,7 @@ export const stakingAbi = [
type: "function",
},
{
inputs: [],
name: "duration",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
{
inputs: [{ internalType: "address", name: "account", type: "address" }],
inputs: [{ internalType: "address", name: "_account", type: "address" }],
name: "getStakes",
outputs: [
{
Expand All @@ -236,7 +222,7 @@ export const stakingAbi = [
{ internalType: "uint256", name: "maturity", type: "uint256" },
],
internalType: "struct IStaking.Stake",
name: "accountStake",
name: "_accountStake",
type: "tuple",
},
],
Expand All @@ -258,7 +244,7 @@ export const stakingAbi = [
type: "function",
},
{
inputs: [{ internalType: "address", name: "delegate", type: "address" }],
inputs: [{ internalType: "address", name: "_delegate", type: "address" }],
name: "proposeDelegate",
outputs: [],
stateMutability: "nonpayable",
Expand All @@ -279,21 +265,23 @@ export const stakingAbi = [
type: "function",
},
{
inputs: [{ internalType: "uint256", name: "delay", type: "uint256" }],
inputs: [{ internalType: "uint256", name: "_delay", type: "uint256" }],
name: "scheduleDurationChange",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [{ internalType: "address", name: "account", type: "address" }],
inputs: [{ internalType: "address", name: "_account", type: "address" }],
name: "setDelegate",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [{ internalType: "uint256", name: "_duration", type: "uint256" }],
inputs: [
{ internalType: "uint256", name: "_stakingDuration", type: "uint256" },
],
name: "setDuration",
outputs: [],
stateMutability: "nonpayable",
Expand All @@ -310,16 +298,16 @@ export const stakingAbi = [
type: "function",
},
{
inputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
inputs: [{ internalType: "uint256", name: "_amount", type: "uint256" }],
name: "stake",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{ internalType: "address", name: "account", type: "address" },
{ internalType: "uint256", name: "amount", type: "uint256" },
{ internalType: "address", name: "_account", type: "address" },
{ internalType: "uint256", name: "_amount", type: "uint256" },
],
name: "stakeFor",
outputs: [],
Expand All @@ -328,18 +316,25 @@ export const stakingAbi = [
},
{
inputs: [],
name: "symbol",
outputs: [{ internalType: "string", name: "", type: "string" }],
name: "stakingDuration",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "token",
name: "stakingToken",
outputs: [{ internalType: "contract ERC20", name: "", type: "address" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "symbol",
outputs: [{ internalType: "string", name: "", type: "string" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "totalSupply",
Expand All @@ -355,14 +350,14 @@ export const stakingAbi = [
type: "function",
},
{
inputs: [{ internalType: "address", name: "delegate", type: "address" }],
inputs: [{ internalType: "address", name: "_delegate", type: "address" }],
name: "unsetDelegate",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
inputs: [{ internalType: "uint256", name: "_amount", type: "uint256" }],
name: "unstake",
outputs: [],
stateMutability: "nonpayable",
Expand Down
32 changes: 0 additions & 32 deletions src/features/settings/SettingsMenuButton.tsx

This file was deleted.

Loading

0 comments on commit d1a49f9

Please sign in to comment.