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

ADD: aime contract #26

Open
wants to merge 74 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
dcb9a86
ADD: aime contract
cctv2206 Sep 5, 2023
7f6a9bc
MOD: aime contract v2
cctv2206 Sep 18, 2023
0eaa468
FIX: bid id when refund
cctv2206 Sep 18, 2023
ec52908
MOD: refund after new bid
cctv2206 Sep 19, 2023
e68bfcd
FIX: SafeMath
cctv2206 Sep 19, 2023
49bae75
ADD: AIME contract for TG AMA
cctv2206 Oct 16, 2023
0a7df82
MOD: aime contract deploy script
cctv2206 Oct 16, 2023
d07c9be
ADD: aime contract v3
cctv2206 Oct 26, 2023
33d2a45
MOD: aime swap contract
cctv2206 Oct 31, 2023
c8e9b79
ADD: aime pool liquidity contract
cctv2206 Nov 1, 2023
b6a0ac7
MOD: l2 chains config
cctv2206 Dec 20, 2023
1ef43c2
ADD: aime v5
cctv2206 Dec 20, 2023
3b42906
FIX: cannot refer self
cctv2206 Dec 20, 2023
df170ac
MOD: aime power v5 change price curve
cctv2206 Dec 21, 2023
9149351
ADD: tests for aime power v5
cctv2206 Dec 21, 2023
ce56fe6
MOD: gpt miner contract
cctv2206 Dec 28, 2023
2557812
FIX: bugs
cctv2206 Dec 28, 2023
b3571c3
MOD: remove comments
cctv2206 Dec 28, 2023
dfe1ca5
MOD: gpt miner nft collection
cctv2206 Jan 2, 2024
2b8b94a
MOD: remove SafeMath
cctv2206 Jan 3, 2024
ab81266
MOD: gptminer duration 5 days
cctv2206 Jan 5, 2024
91da5c2
ADD: verify sig
cctv2206 Jan 8, 2024
6ed2981
MOD: gptminer inscription nft collection
cctv2206 Jan 8, 2024
696fcf0
MOD: update contracts
cctv2206 Jan 8, 2024
677ab4d
MOD: get reward only after mining finished
cctv2206 Jan 9, 2024
e62bd62
MOD: boost amount cap
cctv2206 Jan 16, 2024
f5a3dc5
ADD: mining start and miners count
cctv2206 Jan 17, 2024
2d3291f
MOD: total reward amount
cctv2206 Jan 17, 2024
da9a53b
MOD: sepolia
cctv2206 Jan 26, 2024
2ab32f3
MOD: gptminer v2
cctv2206 Jan 30, 2024
df0678e
MOD: intel boost amount
cctv2206 Jan 30, 2024
dc80c6a
MOD: gptminer v2 naming
cctv2206 Jan 30, 2024
f0b74bc
ADD: aime factory contract
cctv2206 Feb 22, 2024
d4cab44
MOD: create aime with sig and nonce
cctv2206 Feb 23, 2024
ef51ab2
MOD: token uri svg
cctv2206 Mar 5, 2024
4c67183
MOD: aime nft token uri
cctv2206 Mar 7, 2024
0a3370a
MOD: buy and sell power on nft
cctv2206 Mar 11, 2024
03dca95
FIX: safe math
cctv2206 Mar 11, 2024
cb3f926
MOD: nft collection name and nft url
cctv2206 Mar 13, 2024
6c147d0
MOD: buy and sell nft
cctv2206 Mar 13, 2024
6ff2fa5
MOD: update NFT data
cctv2206 Mar 13, 2024
5ab1d2b
FIX: address to string
cctv2206 Mar 13, 2024
9d16a3e
MOD: contract mod and tests for AIMeFactory
cctv2206 Mar 14, 2024
3493e6a
MOD: tests for AIMe NFT contract
cctv2206 Mar 15, 2024
e84439a
MOD: new signature logic
cctv2206 Mar 20, 2024
a2a3cc0
MOD: remove unused contract
cctv2206 Mar 21, 2024
25838c7
ADD: aime contract v2
cctv2206 Mar 22, 2024
b97a8eb
MOD: transfer powers to user
cctv2206 Mar 25, 2024
b13abc4
MOD: aime with permit2
cctv2206 Mar 27, 2024
6b41dc3
MOD: aime with swap in power contract
cctv2206 Mar 28, 2024
ae63e57
MOD: v3 stuff
cctv2206 Apr 1, 2024
e8510a2
MOD: remove uniswap contracts
cctv2206 Apr 2, 2024
e3b3491
MOD: base config
cctv2206 Apr 2, 2024
b06c1ed
MOD: split create and create with token
cctv2206 Apr 4, 2024
16a7ca6
MOD: aime v4
cctv2206 Apr 8, 2024
3223b67
ADD: aime power fair launch v2
cctv2206 Apr 11, 2024
c17a2c1
MOD: power launcher
cctv2206 Apr 12, 2024
f9167be
MOD: nft min price
cctv2206 Apr 12, 2024
0739d9d
MOD: aime creator contract
cctv2206 Apr 15, 2024
f0d0e13
FIX: aime factory nonce
cctv2206 Apr 16, 2024
fe8d97a
MOD: separate aime and power
cctv2206 Apr 23, 2024
9bd8ba5
MOD: create aime with no power
cctv2206 Apr 24, 2024
7e521c1
ADD: tests for aime factory beta
cctv2206 May 7, 2024
ce6c151
MOD: factory and nft v1 prod
cctv2206 May 14, 2024
fd99a84
ADD: FairToken contract
cctv2206 May 24, 2024
a09da7a
MOD: new aime manager
cctv2206 Jun 5, 2024
0dae5d8
MOD: nft bind power
cctv2206 Jun 5, 2024
6c1ec0c
ADD: basic test
cctv2206 Jun 5, 2024
6f229df
MOD: token auto launch when buy enough
cctv2206 Jun 6, 2024
692d7e8
ADD: tests and mod
cctv2206 Jun 12, 2024
7fa9f76
ADD: unit tests
cctv2206 Jun 24, 2024
00f8fe0
MOD: aime power reward contract
cctv2206 Jun 27, 2024
ab235ce
MOD: tests for aime power reward
cctv2206 Jun 27, 2024
601ce06
MOD: aime nft tests
cctv2206 Jun 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
12 changes: 0 additions & 12 deletions contracts/MockNFT.sol

This file was deleted.

43 changes: 43 additions & 0 deletions contracts/aime/AIMeFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./AIMeNFT.sol";

struct AIMeParams {
address creator;
string name;
string avatar;
string bio;
string image;
string socialKey;
string socialId;
uint256 minPrice;
uint256 priceIncrement;
}

interface IAIMeFactory {
function createAIMe(AIMeParams memory params) external returns (address);
}

/**
* AIMeFactory v1.0
* This contract is used for deploying new AIMeNFT contracts
*/
contract AIMeFactory is IAIMeFactory {

function createAIMe(
AIMeParams memory params
) public returns (address) {
AIMeNFT aime = new AIMeNFT(
string(abi.encodePacked("EMIA:", params.name)),
params.name,
params.avatar,
params.bio,
params.image,
params.minPrice,
params.priceIncrement,
msg.sender
);
return address(aime);
}
}
234 changes: 234 additions & 0 deletions contracts/aime/AIMeManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "./AIMeNFT.sol";
import "./AIMePowerLauncher.sol";
import "./AIMePowerChanger.sol";
import "./AIMePowerChangeProposal.sol";
import "./AIMeFactory.sol";

contract AIMeManager is Ownable {
uint256 public protocolFee = 0.00001 ether;
address private _signer;

IAIMeFactory public aimeFactory;
IAIMePowerLauncher public aimePowerLauncher;
IAIMePowerChanger public aimePowerChanger;
address public aimePowerReward;

mapping(address => uint256) public addressNonce;
mapping(string => address) public aimeAddresses;
mapping(address => address) public aimeCreators;

mapping(address => address) public powerChangeProposals;

// events
event AIMeCreated(address creator, address aimeAddress);
event PowerChangeProposed(address proposal);

constructor() {}

function updateSigner(address signer) public onlyOwner {
_signer = signer;
}

function updateProtocolFee(uint256 _protocolFee) public onlyOwner {
protocolFee = _protocolFee;
}

function updateAIMeFactory(IAIMeFactory _aimeFactory) public onlyOwner {
aimeFactory = _aimeFactory;
}

function updateAIMePowerLauncher(
IAIMePowerLauncher _aimePowerLauncher
) public onlyOwner {
aimePowerLauncher = _aimePowerLauncher;
}

function updateAIMePowerChanger(
IAIMePowerChanger _aimePowerChanger
) public onlyOwner {
aimePowerChanger = _aimePowerChanger;
}

function updateAIMePowerReward(address _aimePowerReward) public onlyOwner {
aimePowerReward = _aimePowerReward;
}

function _createAIME(AIMeParams memory params) internal returns (address) {
require(msg.value >= protocolFee * 10, "Insufficient payment");
require(
aimeAddresses[params.name] == address(0),
"AIME already exists"
);
address aimeAddress = aimeFactory.createAIMe(params);

if (
bytes(params.socialKey).length != 0 &&
bytes(params.socialId).length != 0
) {
IAIMeNFT(aimeAddress).mint(
aimeAddress,
params.socialKey,
"static",
params.socialId,
params.image,
0
);
}

aimeAddresses[params.name] = aimeAddress;

return aimeAddress;
}

function _checkSignature(
AIMeParams memory params,
address tokenAddress,
bytes memory signature
) internal returns (bool) {
uint256 nonce = addressNonce[params.creator];
bytes32 _msgHash = ECDSA.toEthSignedMessageHash(
keccak256(
abi.encodePacked(
params.creator,
params.name,
params.avatar,
params.bio,
params.image,
abi.encodePacked(
params.socialKey,
params.socialId,
params.minPrice,
params.priceIncrement,
tokenAddress,
nonce
)
)
)
);
require(
ECDSA.recover(_msgHash, signature) == _signer,
"Invalid signature"
);
addressNonce[params.creator] = nonce + 1;
return true;
}

function createAIME(AIMeParams memory params, bytes memory signature) public payable {
_checkSignature(params, address(0), signature);
address aimeAddress = _createAIME(params);
address power = aimePowerLauncher.launchPower(
params.name,
params.name,
aimePowerReward
);
IAIMeNFT(aimeAddress).setAIMePower(power);
aimeCreators[aimeAddress] = params.creator;

emit AIMeCreated(params.creator, aimeAddress);
}

function createAIMeWithToken(
AIMeParams memory params,
address tokenAddress,
bytes memory signature
) public payable {
_checkSignature(params, tokenAddress, signature);
address aimeAddress = _createAIME(params);
IAIMeNFT(aimeAddress).setAIMePower(tokenAddress);
aimeCreators[aimeAddress] = params.creator;

emit AIMeCreated(params.creator, aimeAddress);
}

function mintAIMeNFT(
address aimeAddress,
string memory key,
string memory dataType,
string memory data,
string memory image,
uint256 amount,
bytes memory signature
) public payable {
require(msg.value >= protocolFee, "Insufficient payment");
bytes32 _msgHash = ECDSA.toEthSignedMessageHash(
keccak256(
abi.encodePacked(
msg.sender,
aimeAddress,
key,
dataType,
data,
image,
amount,
addressNonce[msg.sender]
)
)
);
require(
ECDSA.recover(_msgHash, signature) == _signer,
"Invalid signature"
);
addressNonce[msg.sender] += 1;

IAIMeNFT aime = IAIMeNFT(aimeAddress);
aime.mint(msg.sender, key, dataType, data, image, amount);
}

function updateAIMeNFT(
address aimeAddress,
uint256 tokenId,
string memory data,
string memory image,
bytes memory signature
) public payable {
require(msg.value >= protocolFee, "Insufficient payment");
bytes32 _msgHash = ECDSA.toEthSignedMessageHash(
keccak256(
abi.encodePacked(
msg.sender,
aimeAddress,
tokenId,
data,
image,
addressNonce[msg.sender]
)
)
);
require(
ECDSA.recover(_msgHash, signature) == _signer,
"Invalid signature"
);
addressNonce[msg.sender] += 1;

IAIMeNFT aime = IAIMeNFT(aimeAddress);
aime.updateAIMeInfo(tokenId, msg.sender, data, image);
}

function proposePowerChange(address aimeAddress, address to) public {
require(aimeCreators[aimeAddress] != address(0), "Invalid AIME");
address proposal = aimePowerChanger.createProposal(aimeAddress, to);
powerChangeProposals[proposal] = msg.sender;
emit PowerChangeProposed(proposal);
}

function executePowerChange() public {
require(powerChangeProposals[msg.sender] != address(0), "Invalid proposal");
IAIMePowerChangeProposal proposal = IAIMePowerChangeProposal(
msg.sender
);
IAIMeNFT(proposal.getAIME()).setAIMePower(proposal.getTo());
}

receive() external payable {}

function withdrawFee() public onlyOwner {
uint256 amount = address(this).balance;
(bool success, ) = owner().call{value: amount}("");
require(success, "Failed to send Ether");
}
}
Loading
Loading