Support supplying keys for referral rebates on upcoming markets

This commit is contained in:
Nishad 2020-09-22 14:49:29 +08:00
parent dbab8d3b90
commit 3821147103
6 changed files with 43 additions and 10 deletions

2
.env Normal file
View File

@ -0,0 +1,2 @@
REACT_APP_USDT_REFERRAL_FEES_ADDRESS=''
REACT_APP_USDC_REFERRAL_FEES_ADDRESS=''

View File

@ -6,7 +6,7 @@
"dependencies": {
"@ant-design/icons": "^4.2.1",
"@craco/craco": "^5.6.4",
"@project-serum/serum": "^0.12.17",
"@project-serum/serum": "^0.12.19",
"@project-serum/sol-wallet-adapter": "^0.1.0",
"@solana/web3.js": "^0.71.10",
"@testing-library/jest-dom": "^4.2.4",

View File

@ -87,7 +87,6 @@ export function useAccountInfo(publicKey) {
cacheKey,
{ refreshInterval: 60_000 },
);
let id = publicKey?.toBase58();
useEffect(() => {
if (!publicKey) {
return;

View File

@ -595,7 +595,12 @@ export function useBalances() {
openOrders && openOrders.baseTokenTotal && openOrders.baseTokenFree;
const quoteExists =
openOrders && openOrders.quoteTokenTotal && openOrders.quoteTokenFree;
if (baseCurrency === 'UNKNOWN' || quoteCurrency === 'UNKNOWN') {
if (
baseCurrency === 'UNKNOWN' ||
quoteCurrency === 'UNKNOWN' ||
!baseCurrency ||
!quoteCurrency
) {
return [];
}
return [

View File

@ -1,7 +1,12 @@
import { notify } from './notifications';
import { getDecimalCount, sleep } from './utils';
import { Account, SystemProgram, Transaction } from '@solana/web3.js';
import { TokenInstructions } from '@project-serum/serum';
import {
Account,
SystemProgram,
Transaction,
PublicKey,
} from '@solana/web3.js';
import { TOKEN_MINTS, TokenInstructions } from '@project-serum/serum';
export async function createTokenAccountTransaction({
connection,
@ -75,7 +80,28 @@ export async function settleFunds({
createAccountTransaction = result?.transaction;
createAccountSigner = result?.signer;
}
let referrerQuoteWallet = null;
if (market.supportsReferralFees) {
if (
process.env.REACT_APP_USDT_REFERRAL_FEES_ADDRESS &&
market.quoteMintAddress.equals(
TOKEN_MINTS.find(({ name }) => name === 'USDT').address,
)
) {
referrerQuoteWallet = new PublicKey(
process.env.REACT_APP_USDT_REFERRAL_FEES_ADDRESS,
);
} else if (
process.env.REACT_APP_USDC_REFERRAL_FEES_ADDRESS &&
market.quoteMintAddress.equals(
TOKEN_MINTS.find(({ name }) => name === 'USDC').address,
)
) {
referrerQuoteWallet = new PublicKey(
process.env.REACT_APP_USDC_REFERRAL_FEES_ADDRESS,
);
}
}
const {
transaction: settleFundsTransaction,
signers: settleFundsSigners,
@ -84,6 +110,7 @@ export async function settleFunds({
openOrders,
baseCurrencyAccountPubkey,
quoteCurrencyAccountPubkey,
referrerQuoteWallet,
);
let transaction = mergeTransactions([

View File

@ -1467,10 +1467,10 @@
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==
"@project-serum/serum@^0.12.17":
version "0.12.17"
resolved "https://registry.yarnpkg.com/@project-serum/serum/-/serum-0.12.17.tgz#f22dbfd4ef659a722f7720ef87a8f4d4bc929a9f"
integrity sha512-4Tkzg+Hx3F6YvKGDyR5bQ3PlMLf2fLwvWjRhjIeJWAUqyX7ZiGqvZz+NJ2VTFESo9wRoMcBPZccd52E/pkSUXQ==
"@project-serum/serum@^0.12.19":
version "0.12.19"
resolved "https://registry.yarnpkg.com/@project-serum/serum/-/serum-0.12.19.tgz#a86ed3590bdbd51380f6062810c40734c1bfe548"
integrity sha512-QWy6mw2Swm1eqs1rLWhjqHYIg0mAsjnye8kcW5Ko1QeDcSfkj9asgxPK7ft7IS+npSbbSBAO4IZdm189FBOV6Q==
dependencies:
"@solana/web3.js" "^0.71.10"
bn.js "^5.1.2"