Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staker nft #56

Open
wants to merge 69 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
5291f0d
SVGGenerate
elclandestin0 Aug 21, 2024
7df4674
encoding successfully!
elclandestin0 Aug 21, 2024
cd9d089
fix </svg>
elclandestin0 Aug 21, 2024
374959f
add svg foreground
elclandestin0 Aug 22, 2024
ad74121
svg generate
elclandestin0 Aug 22, 2024
7f08d0f
svg update
elclandestin0 Aug 22, 2024
cf08e74
data type updated
elclandestin0 Aug 23, 2024
d81fd92
remove useless number
elclandestin0 Aug 23, 2024
6360ff6
fix with <style>
elclandestin0 Aug 26, 2024
7619ec3
correct style
elclandestin0 Aug 26, 2024
f14646a
format and fix
elclandestin0 Aug 26, 2024
b8f0d9d
generateAdminElement()
elclandestin0 Aug 26, 2024
fe916ae
generateTokenAddressElement()
elclandestin0 Aug 26, 2024
e4cb766
courier new
elclandestin0 Aug 26, 2024
0e49439
Remove lib
elclandestin0 Aug 26, 2024
bd1da72
cp on element functions
elclandestin0 Aug 26, 2024
aa04774
most variables added
elclandestin0 Aug 27, 2024
bd04a8d
symbol
elclandestin0 Aug 27, 2024
bb4f080
fix token address alignment
elclandestin0 Aug 27, 2024
66a9f7a
remove ftw
elclandestin0 Aug 27, 2024
f38ae06
Added DateTime
elclandestin0 Aug 29, 2024
ab48f9c
parse lockupseconds + stakedat to return unlocks at
elclandestin0 Aug 29, 2024
cb546f9
realigned logo and token amount staked
elclandestin0 Aug 29, 2024
ca6a0fe
realigned staking time periods
elclandestin0 Aug 30, 2024
51d1db4
good token alignment
elclandestin0 Aug 30, 2024
9685c7d
update token info
elclandestin0 Sep 2, 2024
6323319
remove useless f'n
elclandestin0 Sep 2, 2024
6a70148
more positioning
elclandestin0 Sep 2, 2024
74a6da6
generate defs
elclandestin0 Sep 2, 2024
dcc1ed6
cut space
elclandestin0 Sep 2, 2024
a7f4a35
Correct casing
elclandestin0 Sep 2, 2024
f0f34ad
erc20 tests
elclandestin0 Sep 2, 2024
819ba5b
erc20, native, 1155 metadata logs
elclandestin0 Sep 2, 2024
89626b6
abstracted svg f'ns
elclandestin0 Sep 2, 2024
26e55df
cleared error
elclandestin0 Sep 3, 2024
a9b16b0
Tests completed and looking good.
elclandestin0 Sep 3, 2024
9484328
arranged defs
elclandestin0 Sep 3, 2024
593fe78
remove defs
elclandestin0 Sep 3, 2024
c4e19bb
increased font size
elclandestin0 Sep 3, 2024
32ff9f0
increased label font sizes
elclandestin0 Sep 4, 2024
04fdd81
remove useless f'n
elclandestin0 Sep 4, 2024
6752562
updated
elclandestin0 Sep 4, 2024
f09fea6
correction
elclandestin0 Sep 4, 2024
bf36159
PR corrections
elclandestin0 Sep 4, 2024
cdb5aa8
re-added envexample
elclandestin0 Sep 4, 2024
7c90149
remove generatedefs
elclandestin0 Sep 4, 2024
9b9580d
PositionMetadata go bindings
elclandestin0 Sep 4, 2024
626a788
DateTime credits
elclandestin0 Sep 4, 2024
c72c67c
updated tests
elclandestin0 Sep 4, 2024
9dad196
rm nativePoolId from wrong test
elclandestin0 Sep 4, 2024
6c6c940
updated DateTime.sol @notice
elclandestin0 Sep 4, 2024
9d01fbd
gradient added
elclandestin0 Sep 5, 2024
a6bae24
clear
elclandestin0 Sep 5, 2024
e2ca984
fix gradient
elclandestin0 Sep 5, 2024
837fc30
Merge branch 'staker-nft' of github.com:G7DAO/protocol into staker-nft
elclandestin0 Sep 5, 2024
64d290a
maker rebuild
elclandestin0 Sep 5, 2024
3c70890
rm optimizer
elclandestin0 Sep 5, 2024
210e60d
update
elclandestin0 Sep 10, 2024
868c1a2
restore files
elclandestin0 Sep 13, 2024
e6bc4ca
mock erc1155
elclandestin0 Sep 13, 2024
41162a1
cp
elclandestin0 Sep 13, 2024
d33e29d
fix tests
elclandestin0 Sep 24, 2024
478f8c0
Merge remote-tracking branch 'origin/main' into staker-nft
elclandestin0 Sep 24, 2024
9af2ade
remove position metadata
elclandestin0 Sep 24, 2024
ee4774f
correct pr errors
elclandestin0 Sep 24, 2024
c11e91b
update hardhat config
elclandestin0 Sep 27, 2024
a28cd39
Merge branch 'staker-nft' of github.com:G7DAO/protocol into staker-nft
elclandestin0 Sep 27, 2024
4499a7a
breaking up f'ns
elclandestin0 Sep 27, 2024
9728522
break down stakingPeriodElements
elclandestin0 Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 80 additions & 80 deletions bindings/ERC20/ERC20.go

Large diffs are not rendered by default.

506 changes: 253 additions & 253 deletions bindings/MockERC1155/MockERC1155.go

Large diffs are not rendered by default.

290 changes: 145 additions & 145 deletions bindings/MockERC20/MockERC20.go

Large diffs are not rendered by default.

210 changes: 105 additions & 105 deletions bindings/MockERC721/MockERC721.go

Large diffs are not rendered by default.

989 changes: 978 additions & 11 deletions bindings/PositionMetadata/PositionMetadata.go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the only bindings that should remain committed.

Large diffs are not rendered by default.

1,610 changes: 805 additions & 805 deletions bindings/Staker/Staker.go

Large diffs are not rendered by default.

409 changes: 260 additions & 149 deletions bindings/TokenFaucet/TokenFaucet.go

Large diffs are not rendered by default.

332 changes: 166 additions & 166 deletions bindings/WrappedNativeToken/WrappedNativeToken.go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elclandestin0 : Can you remove these changes from your branch? You should be able to do this using the following commands (not tested):

git checkout main -- bindings/WrappedNativeToken/WrappedNativeToken.go
git add bindings/WrappedNativeToken/WrappedNativeToken.go
git commit # type an appropriate commit message into your editor, and hit save

I assume you didn't touch the WrappedNativeToken contract so regenerating the bindings has no meaning.

Do this for all bindings you didn't touch, please.

Large diffs are not rendered by default.

328 changes: 318 additions & 10 deletions web3/contracts/staking/PositionMetadata.sol
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to also commit the corresponding changes to bindings/PositionMetadata/PositionMetadats.go.

Large diffs are not rendered by default.

219 changes: 219 additions & 0 deletions web3/contracts/utils/DateTime.sol
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was taken from here: https://github.com/pipermerriam/ethereum-datetime/blob/master/contracts/DateTime.sol

But it has been taken without attribution. I am not ok with this. Either import it as a dependency or put a comment in this file explaining where the code was taken from.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to import it - is there a reason we can't do so (e.g. solidity version issues in the original file)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fairpoint. Thanks for adding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From our slack conversation: it's best to keep our compiler uniform! The original file has 0.4.16

Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

/**
* @title DateTime
* @author @pipermerriam on GitHub
* @notice This Solidity library is not written by Game7. It is written by @pipermerriam.
* You can find the full code here: https://github.com/pipermerriam/ethereum-datetime/blob/master/contracts/DateTime.sol
* Modifications made:
* - Changed into a library
* - Solidity version changed to fit our compiler
*/


library DateTime {
/*
* Date and Time utilities for Ethereum contracts
*
*/
struct _DateTime {
uint16 year;
uint8 month;
uint8 day;
uint8 hour;
uint8 minute;
uint8 second;
uint8 weekday;
}

uint constant DAY_IN_SECONDS = 86400;
uint constant YEAR_IN_SECONDS = 31536000;
uint constant LEAP_YEAR_IN_SECONDS = 31622400;

uint constant HOUR_IN_SECONDS = 3600;
uint constant MINUTE_IN_SECONDS = 60;

uint16 constant ORIGIN_YEAR = 1970;

function isLeapYear(uint16 year) internal pure returns (bool) {
if (year % 4 != 0) {
return false;
}
if (year % 100 != 0) {
return true;
}
if (year % 400 != 0) {
return false;
}
return true;
}

function leapYearsBefore(uint year) internal pure returns (uint) {
year -= 1;
return year / 4 - year / 100 + year / 400;
}

function getDaysInMonth(uint8 month, uint16 year) internal pure returns (uint8) {
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
return 31;
} else if (month == 4 || month == 6 || month == 9 || month == 11) {
return 30;
} else if (isLeapYear(year)) {
return 29;
} else {
return 28;
}
}

function parseTimestamp(uint timestamp) internal pure returns (_DateTime memory dt) {
uint secondsAccountedFor = 0;
uint buf;
uint8 i;

// Year
dt.year = getYear(timestamp);
buf = leapYearsBefore(dt.year) - leapYearsBefore(ORIGIN_YEAR);

secondsAccountedFor += LEAP_YEAR_IN_SECONDS * buf;
secondsAccountedFor += YEAR_IN_SECONDS * (dt.year - ORIGIN_YEAR - buf);

// Month
uint secondsInMonth;
for (i = 1; i <= 12; i++) {
secondsInMonth = DAY_IN_SECONDS * getDaysInMonth(i, dt.year);
if (secondsInMonth + secondsAccountedFor > timestamp) {
dt.month = i;
break;
}
secondsAccountedFor += secondsInMonth;
}

// Day
for (i = 1; i <= getDaysInMonth(dt.month, dt.year); i++) {
if (DAY_IN_SECONDS + secondsAccountedFor > timestamp) {
dt.day = i;
break;
}
secondsAccountedFor += DAY_IN_SECONDS;
}

// Hour
dt.hour = getHour(timestamp);

// Minute
dt.minute = getMinute(timestamp);

// Second
dt.second = getSecond(timestamp);

// Day of week
dt.weekday = getWeekday(timestamp);
}

function getYear(uint timestamp) internal pure returns (uint16) {
uint secondsAccountedFor = 0;
uint16 year;
uint numLeapYears;

// Year
year = uint16(ORIGIN_YEAR + timestamp / YEAR_IN_SECONDS);
numLeapYears = leapYearsBefore(year) - leapYearsBefore(ORIGIN_YEAR);

secondsAccountedFor += LEAP_YEAR_IN_SECONDS * numLeapYears;
secondsAccountedFor += YEAR_IN_SECONDS * (year - ORIGIN_YEAR - numLeapYears);

while (secondsAccountedFor > timestamp) {
if (isLeapYear(uint16(year - 1))) {
secondsAccountedFor -= LEAP_YEAR_IN_SECONDS;
} else {
secondsAccountedFor -= YEAR_IN_SECONDS;
}
year -= 1;
}
return year;
}

function getMonth(uint timestamp) internal pure returns (uint8) {
return parseTimestamp(timestamp).month;
}

function getDay(uint timestamp) internal pure returns (uint8) {
return parseTimestamp(timestamp).day;
}

function getHour(uint timestamp) internal pure returns (uint8) {
return uint8((timestamp / HOUR_IN_SECONDS) % 24);
}

function getMinute(uint timestamp) internal pure returns (uint8) {
return uint8((timestamp / MINUTE_IN_SECONDS) % 60);
}

function getSecond(uint timestamp) internal pure returns (uint8) {
return uint8(timestamp % 60);
}

function getWeekday(uint timestamp) internal pure returns (uint8) {
return uint8((timestamp / DAY_IN_SECONDS + 4) % 7);
}

function toTimestamp(uint16 year, uint8 month, uint8 day) internal pure returns (uint timestamp) {
return toTimestamp(year, month, day, 0, 0, 0);
}

function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour) internal pure returns (uint timestamp) {
return toTimestamp(year, month, day, hour, 0, 0);
}

function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute) internal pure returns (uint timestamp) {
return toTimestamp(year, month, day, hour, minute, 0);
}

function toTimestamp(uint16 year, uint8 month, uint8 day, uint8 hour, uint8 minute, uint8 second) internal pure returns (uint timestamp) {
uint16 i;

// Year
for (i = ORIGIN_YEAR; i < year; i++) {
if (isLeapYear(i)) {
timestamp += LEAP_YEAR_IN_SECONDS;
} else {
timestamp += YEAR_IN_SECONDS;
}
}

// Month
uint8[12] memory monthDayCounts = [
31, // January
isLeapYear(year) ? 29 : 28, // February
31, // March
30, // April
31, // May
30, // June
31, // July
31, // August
30, // September
31, // October
30, // November
31 // December
];

for (i = 1; i < month; i++) {
timestamp += DAY_IN_SECONDS * monthDayCounts[i - 1];
}

// Day
timestamp += DAY_IN_SECONDS * (day - 1);

// Hour
timestamp += HOUR_IN_SECONDS * hour;

// Minute
timestamp += MINUTE_IN_SECONDS * minute;

// Second
timestamp += second;

return timestamp;
}
}
117 changes: 58 additions & 59 deletions web3/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,71 +1,70 @@
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import * as dotenv from 'dotenv'
import { ChainId, NetworkExplorer, NetworkName, rpcUrls } from "./constants/network";
import "@nomicfoundation/hardhat-foundry";
import { HardhatUserConfig } from 'hardhat/config';
import '@nomicfoundation/hardhat-toolbox';
import * as dotenv from 'dotenv';
import { ChainId, NetworkExplorer, NetworkName, rpcUrls } from './constants/network';
import '@nomicfoundation/hardhat-foundry';

dotenv.config()
dotenv.config();

const yes = ["true", "t", "yes", "y", "1"]
const GAS_PROFILER = yes.includes((process.env.GAS_PROFILER || "").toLowerCase());
const yes = ['true', 't', 'yes', 'y', '1'];
const GAS_PROFILER = yes.includes((process.env.GAS_PROFILER || '').toLowerCase());

const {
ETHSCAN_API_KEY,
ARB_SCAN_API_KEY,
} = process.env
const { ETHSCAN_API_KEY, ARB_SCAN_API_KEY } = process.env;

const config: HardhatUserConfig = {
solidity: "0.8.24",
gasReporter: {
enabled: GAS_PROFILER,
},
etherscan: {
apiKey: {
[NetworkName.Ethereum]: ETHSCAN_API_KEY || '',
[NetworkName.ArbitrumOne]: ARB_SCAN_API_KEY || '',
[NetworkName.ArbitrumSepolia]: ARB_SCAN_API_KEY || '',
solidity: {
version: '0.8.24',
},
customChains: [
{
network: NetworkName.Game7OrbitArbSepolia,
chainId: ChainId.Game7OrbitArbSepolia,
urls: {
apiURL: `${NetworkExplorer.Game7OrbitArbSepolia}/api`,
browserURL: NetworkExplorer.Game7OrbitArbSepolia,
},
},
{
network: NetworkName.Game7OrbitBaseSepolia,
chainId: ChainId.Game7OrbitBaseSepolia,
urls: {
apiURL: `${NetworkExplorer.Game7OrbitBaseSepolia}/api`,
browserURL: NetworkExplorer.Game7OrbitBaseSepolia,
},
},
],
},
networks: {
[NetworkName.Ethereum]: {
chainId: ChainId.Ethereum,
url: rpcUrls[ChainId.Ethereum],
gasReporter: {
enabled: GAS_PROFILER,
},
[NetworkName.ArbitrumOne]: {
chainId: ChainId.ArbitrumOne,
url: rpcUrls[ChainId.ArbitrumOne],
etherscan: {
apiKey: {
[NetworkName.Ethereum]: ETHSCAN_API_KEY || '',
[NetworkName.ArbitrumOne]: ARB_SCAN_API_KEY || '',
[NetworkName.ArbitrumSepolia]: ARB_SCAN_API_KEY || '',
},
customChains: [
{
network: NetworkName.Game7OrbitArbSepolia,
chainId: ChainId.Game7OrbitArbSepolia,
urls: {
apiURL: `${NetworkExplorer.Game7OrbitArbSepolia}/api`,
browserURL: NetworkExplorer.Game7OrbitArbSepolia,
},
},
{
network: NetworkName.Game7OrbitBaseSepolia,
chainId: ChainId.Game7OrbitBaseSepolia,
urls: {
apiURL: `${NetworkExplorer.Game7OrbitBaseSepolia}/api`,
browserURL: NetworkExplorer.Game7OrbitBaseSepolia,
},
},
],
},
[NetworkName.Game7OrbitArbSepolia]: {
url: rpcUrls[ChainId.Game7OrbitArbSepolia],
chainId: ChainId.Game7OrbitArbSepolia,
networks: {
[NetworkName.Ethereum]: {
chainId: ChainId.Ethereum,
url: rpcUrls[ChainId.Ethereum],
},
[NetworkName.ArbitrumOne]: {
chainId: ChainId.ArbitrumOne,
url: rpcUrls[ChainId.ArbitrumOne],
},
[NetworkName.Game7OrbitArbSepolia]: {
url: rpcUrls[ChainId.Game7OrbitArbSepolia],
chainId: ChainId.Game7OrbitArbSepolia,
},
[NetworkName.Game7OrbitBaseSepolia]: {
url: rpcUrls[ChainId.Game7OrbitBaseSepolia],
chainId: ChainId.Game7OrbitBaseSepolia,
},
[NetworkName.ArbitrumSepolia]: {
url: rpcUrls[ChainId.ArbitrumSepolia],
chainId: ChainId.ArbitrumSepolia,
},
},
[NetworkName.Game7OrbitBaseSepolia]: {
url: rpcUrls[ChainId.Game7OrbitBaseSepolia],
chainId: ChainId.Game7OrbitBaseSepolia,
},
[NetworkName.ArbitrumSepolia]: {
url: rpcUrls[ChainId.ArbitrumSepolia],
chainId: ChainId.ArbitrumSepolia,
}
},
};

export default config;
Loading
Loading