forked from mito-systems/sol-mem-gen
Round up MTM prices to nearest integer
This commit is contained in:
parent
107a1bf154
commit
df914a7f39
11
.env.example
11
.env.example
@ -3,8 +3,8 @@ FAL_AI_KEY=
|
|||||||
|
|
||||||
NEXT_PUBLIC_MTM_TOKEN_MINT=97RggLo3zV5kFGYW4yoQTxr4Xkz4Vg2WPHzNYXXWpump
|
NEXT_PUBLIC_MTM_TOKEN_MINT=97RggLo3zV5kFGYW4yoQTxr4Xkz4Vg2WPHzNYXXWpump
|
||||||
NEXT_PUBLIC_PAYMENT_RECEIVER_ADDRESS=FFDx3SdAEeXrp6BTmStB4BDHpctGsaasZq4FFcowRobY
|
NEXT_PUBLIC_PAYMENT_RECEIVER_ADDRESS=FFDx3SdAEeXrp6BTmStB4BDHpctGsaasZq4FFcowRobY
|
||||||
NEXT_PUBLIC_SOLANA_RPC_URL=https://young-radial-orb.solana-mainnet.quiknode.pro/67612b364664616c29514e551bf5de38447ca3d4
|
NEXT_PUBLIC_SOLANA_RPC_URL=https://skilled-prettiest-seed.solana-mainnet.quiknode.pro/eeecfebd04e345f69f1900cc3483cbbfea02a158
|
||||||
NEXT_PUBLIC_SOLANA_WEBSOCKET_URL=wss://young-radial-orb.solana-mainnet.quiknode.pro/67612b364664616c29514e551bf5de38447ca3d4
|
NEXT_PUBLIC_SOLANA_WEBSOCKET_URL=wss://skilled-prettiest-seed.solana-mainnet.quiknode.pro/eeecfebd04e345f69f1900cc3483cbbfea02a158
|
||||||
NEXT_PUBLIC_USDC_MINT=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
|
NEXT_PUBLIC_USDC_MINT=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
|
||||||
|
|
||||||
# Generate a key at https://app.pinata.cloud/developers/api-keys
|
# Generate a key at https://app.pinata.cloud/developers/api-keys
|
||||||
@ -17,3 +17,10 @@ PINATA_GATEWAY=
|
|||||||
# For development: SITE_URL=http://localhost:3000
|
# For development: SITE_URL=http://localhost:3000
|
||||||
SITE_URL=https://memes.markto.market
|
SITE_URL=https://memes.markto.market
|
||||||
NEXT_PUBLIC_ACCOUNT_HANDLE=
|
NEXT_PUBLIC_ACCOUNT_HANDLE=
|
||||||
|
|
||||||
|
WSOL_LOCKER_PRIVATE_KEY=
|
||||||
|
WSOL_MINT=So11111111111111111111111111111111111111112
|
||||||
|
|
||||||
|
# Duration in seconds that WSOL will be locked for
|
||||||
|
CLIFF_TIME=172800 # 48 hours
|
||||||
|
REWARD_MULTIPLIER=4
|
||||||
|
@ -27,13 +27,13 @@ async function extractInfo(transactionSignature: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function createRewardLock(authority: string, amount: string) {
|
async function createRewardLock(authority: string, amount: string) {
|
||||||
const { USER_PRIVATE_KEY, CLIFF_TIME, WSOL_MINT, NEXT_PUBLIC_MTM_TOKEN_MINT, REWARD_MULTIPLIER } = process.env;
|
const { WSOL_LOCKER_PRIVATE_KEY, CLIFF_TIME, WSOL_MINT, NEXT_PUBLIC_MTM_TOKEN_MINT, REWARD_MULTIPLIER } = process.env;
|
||||||
if (!USER_PRIVATE_KEY || !CLIFF_TIME || !WSOL_MINT || !NEXT_PUBLIC_MTM_TOKEN_MINT || !REWARD_MULTIPLIER) {
|
if (!WSOL_LOCKER_PRIVATE_KEY || !CLIFF_TIME || !WSOL_MINT || !NEXT_PUBLIC_MTM_TOKEN_MINT || !REWARD_MULTIPLIER) {
|
||||||
throw new Error('Missing required environment variables');
|
throw new Error('Missing required environment variables');
|
||||||
}
|
}
|
||||||
|
|
||||||
const duration = new BN(CLIFF_TIME).add(new BN(Math.floor(Date.now() / 1000)));
|
const duration = new BN(CLIFF_TIME).add(new BN(Math.floor(Date.now() / 1000)));
|
||||||
const tokenLockerKeypair = Keypair.fromSecretKey(bs58.decode(USER_PRIVATE_KEY));
|
const tokenLockerKeypair = Keypair.fromSecretKey(bs58.decode(WSOL_LOCKER_PRIVATE_KEY));
|
||||||
const recipientPublicKey = new PublicKey(authority);
|
const recipientPublicKey = new PublicKey(authority);
|
||||||
|
|
||||||
const url = `https://api.jup.ag/price/v2?ids=${NEXT_PUBLIC_MTM_TOKEN_MINT}&vsToken=${WSOL_MINT}`;
|
const url = `https://api.jup.ag/price/v2?ids=${NEXT_PUBLIC_MTM_TOKEN_MINT}&vsToken=${WSOL_MINT}`;
|
||||||
|
@ -21,11 +21,11 @@ interface GenerationState {
|
|||||||
error: string | null
|
error: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
const baseUnitToDecimalFormat = (value: BN, decimals: number): string => {
|
const baseUnitToWholeNumber = (value: BN, decimals: number): string => {
|
||||||
const bigValue = new Big(value.toString());
|
const bigValue = new Big(value.toString());
|
||||||
const factor = new Big(10).pow(decimals);
|
const factor = new Big(10).pow(decimals);
|
||||||
|
|
||||||
return bigValue.div(factor).toFixed(decimals);
|
return bigValue.div(factor).round(0, Big.roundUp).toFixed(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const AIServiceCard: React.FC<AIServiceCardProps> = ({
|
const AIServiceCard: React.FC<AIServiceCardProps> = ({
|
||||||
@ -93,11 +93,11 @@ const AIServiceCard: React.FC<AIServiceCardProps> = ({
|
|||||||
const generateTwitterShareUrl = (imageUrl: string, transactionSignature: string): string => {
|
const generateTwitterShareUrl = (imageUrl: string, transactionSignature: string): string => {
|
||||||
const baseUrl = window.location.href;
|
const baseUrl = window.location.href;
|
||||||
const cid = imageUrl.split("/image/")[1];
|
const cid = imageUrl.split("/image/")[1];
|
||||||
const memeUrl = `${baseUrl}memes/${cid}`;
|
const memePageUrl = `${baseUrl}memes/${cid}`;
|
||||||
|
|
||||||
const tweetText = `Check out this meme that I generated! \n TX Hash: '${transactionSignature}' \n @${process.env.NEXT_PUBLIC_ACCOUNT_HANDLE} \n`;
|
const tweetText = `Check out this meme that I generated! \n TX Hash: '${transactionSignature}' \n @${process.env.NEXT_PUBLIC_ACCOUNT_HANDLE} \n`;
|
||||||
|
|
||||||
return `https://twitter.com/intent/tweet?text=${encodeURIComponent(tweetText)}&url=${encodeURIComponent(memeUrl)}`;
|
return `https://twitter.com/intent/tweet?text=${encodeURIComponent(tweetText)}&url=${encodeURIComponent(memePageUrl)}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -109,7 +109,7 @@ const AIServiceCard: React.FC<AIServiceCardProps> = ({
|
|||||||
</h2>
|
</h2>
|
||||||
<p className="text-gray-400 mt-2">{description}</p>
|
<p className="text-gray-400 mt-2">{description}</p>
|
||||||
<div className="mt-2 inline-block px-3 py-1 bg-green-500/20 rounded-full text-green-300 text-sm">
|
<div className="mt-2 inline-block px-3 py-1 bg-green-500/20 rounded-full text-green-300 text-sm">
|
||||||
Cost: {priceMTM ? baseUnitToDecimalFormat(priceMTM, 6) : '...'} MTM
|
Cost: {priceMTM ? baseUnitToWholeNumber(priceMTM, 6) : '...'} MTM
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ const AIServiceCard: React.FC<AIServiceCardProps> = ({
|
|||||||
transition-all duration-200 shadow-lg hover:shadow-green-500/25
|
transition-all duration-200 shadow-lg hover:shadow-green-500/25
|
||||||
disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none"
|
disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none"
|
||||||
>
|
>
|
||||||
{generationState.loading ? 'Processing...' : `Pay ${priceMTM ? baseUnitToDecimalFormat(priceMTM, 6) : '...'} MTM & Generate`}
|
{generationState.loading ? 'Processing...' : `Pay ${priceMTM ? baseUnitToWholeNumber(priceMTM, 6) : '...'} MTM & Generate`}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ import {
|
|||||||
RemainingAccountsType,
|
RemainingAccountsType,
|
||||||
} from './token-2022/remaining-accounts';
|
} from './token-2022/remaining-accounts';
|
||||||
|
|
||||||
assert(process.env.RPC_ENDPOINT);
|
assert(process.env.NEXT_PUBLIC_SOLANA_RPC_URL);
|
||||||
|
|
||||||
const connection = new Connection(process.env.RPC_ENDPOINT);
|
const connection = new Connection(process.env.NEXT_PUBLIC_SOLANA_RPC_URL);
|
||||||
|
|
||||||
const ESCROW_USE_SPL_TOKEN = 0;
|
const ESCROW_USE_SPL_TOKEN = 0;
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ export async function createVestingPlanV2(params: CreateVestingPlanParams) {
|
|||||||
ASSOCIATED_TOKEN_PROGRAM_ID
|
ASSOCIATED_TOKEN_PROGRAM_ID
|
||||||
);
|
);
|
||||||
|
|
||||||
let remainingAccountsInfo = null;
|
let remainingAccountsInfo;
|
||||||
let remainingAccounts: AccountMeta[] = [];
|
let remainingAccounts: AccountMeta[] = [];
|
||||||
if (tokenProgram == TOKEN_2022_PROGRAM_ID) {
|
if (tokenProgram == TOKEN_2022_PROGRAM_ID) {
|
||||||
let inputTransferHookAccounts =
|
let inputTransferHookAccounts =
|
||||||
@ -225,7 +225,7 @@ export async function claimTokenV2(params: ClaimTokenParamsV2) {
|
|||||||
ASSOCIATED_TOKEN_PROGRAM_ID
|
ASSOCIATED_TOKEN_PROGRAM_ID
|
||||||
);
|
);
|
||||||
|
|
||||||
let remainingAccountsInfo = null;
|
let remainingAccountsInfo;
|
||||||
let remainingAccounts: AccountMeta[] | undefined = [];
|
let remainingAccounts: AccountMeta[] | undefined = [];
|
||||||
if (tokenProgram == TOKEN_2022_PROGRAM_ID) {
|
if (tokenProgram == TOKEN_2022_PROGRAM_ID) {
|
||||||
let claimTransferHookAccounts =
|
let claimTransferHookAccounts =
|
||||||
|
@ -11,16 +11,15 @@ import { Connection, PublicKey } from "@solana/web3.js";
|
|||||||
|
|
||||||
import { createVestingPlanV2 } from '../locker-utils';
|
import { createVestingPlanV2 } from '../locker-utils';
|
||||||
|
|
||||||
assert(process.env.RPC_ENDPOINT);
|
assert(process.env.NEXT_PUBLIC_SOLANA_RPC_URL);
|
||||||
assert(process.env.USER_PRIVATE_KEY);
|
assert(process.env.WSOL_LOCKER_PRIVATE_KEY);
|
||||||
//assert(process.env.RECIPIENT_PUBLIC_KEY);
|
|
||||||
assert(process.env.WSOL_MINT);
|
assert(process.env.WSOL_MINT);
|
||||||
|
|
||||||
const RPC_ENDPOINT= process.env.RPC_ENDPOINT;
|
const RPC_ENDPOINT= process.env.NEXT_PUBLIC_SOLANA_RPC_URL;
|
||||||
const WSOL_MINT = process.env.WSOL_MINT;
|
const WSOL_MINT = process.env.WSOL_MINT;
|
||||||
const USER_PRIVATE_KEY = process.env.USER_PRIVATE_KEY;
|
const WSOL_LOCKER_PRIVATE_KEY = process.env.WSOL_LOCKER_PRIVATE_KEY;
|
||||||
|
|
||||||
const userKP = anchor.web3.Keypair.fromSecretKey(bs58.decode(USER_PRIVATE_KEY));
|
const userKP = anchor.web3.Keypair.fromSecretKey(bs58.decode(WSOL_LOCKER_PRIVATE_KEY));
|
||||||
|
|
||||||
const connection = new Connection(RPC_ENDPOINT);
|
const connection = new Connection(RPC_ENDPOINT);
|
||||||
const token = new PublicKey(WSOL_MINT);
|
const token = new PublicKey(WSOL_MINT);
|
||||||
|
Loading…
Reference in New Issue
Block a user