cleanup
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
b56fd46721
commit
c63d860bc1
|
@ -13,7 +13,7 @@ anchor build --skip-lint
|
|||
./idl-fixup.sh
|
||||
|
||||
# update types in ts client package
|
||||
cp -v ./target/types/mango_v4.ts ./ts/mango_v4.ts
|
||||
cp -v ./target/types/mango_v4.ts ./ts/client/src/mango_v4.ts
|
||||
|
||||
if [[ -z "${NO_DEPLOY}" ]]; then
|
||||
# publish program
|
||||
|
@ -29,13 +29,4 @@ fi
|
|||
|
||||
|
||||
# build npm package
|
||||
tsc
|
||||
# yarn clean && yarn build && cp package.json ./dist/
|
||||
|
||||
# publish the npm package
|
||||
# yarn publish dist
|
||||
|
||||
# echo
|
||||
# echo Remember to commit and push the version update as well as the changes
|
||||
# echo to ts/mango_v4.tx.
|
||||
# echo
|
||||
(cd ./ts/client && tsc)
|
||||
|
|
|
@ -227,13 +227,13 @@ export class MangoClient {
|
|||
{
|
||||
memcmp: {
|
||||
bytes: group.publicKey.toBase58(),
|
||||
offset: 24,
|
||||
offset: 40,
|
||||
},
|
||||
},
|
||||
{
|
||||
memcmp: {
|
||||
bytes: ownerPk.toBase58(),
|
||||
offset: 56,
|
||||
offset: 72,
|
||||
},
|
||||
},
|
||||
])
|
||||
|
|
|
@ -2,34 +2,6 @@ import { PublicKey } from '@solana/web3.js';
|
|||
|
||||
export const DEVNET_GROUP = 'NDLmPdjzm7Tm3gnsZw8EoBbBTR7wfAcyDY8LCqFSGtX';
|
||||
|
||||
export const DEVNET_MINTS = new Map([
|
||||
['USDC', '8FRFC6MoGGkMFQwngccyu69VnYbzykGeez7ignHVAFSN'],
|
||||
['BTC', '3UNBZ6o52WTWwjac2kPUb4FyodhU1vFkRJheu1Sh2TvU'],
|
||||
]);
|
||||
|
||||
export const DEVNET_MINTS_REVERSE = Array.from(DEVNET_MINTS.entries()).reduce(
|
||||
function (map, obj) {
|
||||
map[obj[1]] = obj[0];
|
||||
return map;
|
||||
},
|
||||
{},
|
||||
);
|
||||
|
||||
export const DEVNET_ORACLES = new Map([
|
||||
['BTC', 'HovQMDrbAgAYPCmHVSrezcSmkMtXSSUsLDFANExrZh2J'],
|
||||
]);
|
||||
|
||||
export const DEVNET_SERUM3_MARKETS = new Map([
|
||||
['BTC/USDC', 'DW83EpHFywBxCHmyARxwj3nzxJd7MUdSeznmrdzZKNZB'],
|
||||
]);
|
||||
|
||||
export const DEVNET_SERUM3_MARKETS_REVERSE = Array.from(
|
||||
DEVNET_SERUM3_MARKETS.entries(),
|
||||
).reduce(function (map, obj) {
|
||||
map[obj[1]] = obj[0];
|
||||
return map;
|
||||
}, {});
|
||||
|
||||
export const DEVNET_SERUM3_PROGRAM_ID = new PublicKey(
|
||||
'DESVgJVGajEgKGXhb6XmqDHGz3VjdgP7rEVESBgxmroY',
|
||||
);
|
||||
|
|
|
@ -2,12 +2,18 @@ import { Provider, Wallet } from '@project-serum/anchor';
|
|||
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
|
||||
import fs from 'fs';
|
||||
import { MangoClient } from './client';
|
||||
import {
|
||||
DEVNET_MINTS,
|
||||
DEVNET_ORACLES,
|
||||
DEVNET_SERUM3_MARKETS,
|
||||
DEVNET_SERUM3_PROGRAM_ID,
|
||||
} from './constants';
|
||||
import { DEVNET_SERUM3_PROGRAM_ID } from './constants';
|
||||
|
||||
const DEVNET_SERUM3_MARKETS = new Map([
|
||||
['BTC/USDC', 'DW83EpHFywBxCHmyARxwj3nzxJd7MUdSeznmrdzZKNZB'],
|
||||
]);
|
||||
const DEVNET_MINTS = new Map([
|
||||
['USDC', '8FRFC6MoGGkMFQwngccyu69VnYbzykGeez7ignHVAFSN'],
|
||||
['BTC', '3UNBZ6o52WTWwjac2kPUb4FyodhU1vFkRJheu1Sh2TvU'],
|
||||
]);
|
||||
const DEVNET_ORACLES = new Map([
|
||||
['BTC', 'HovQMDrbAgAYPCmHVSrezcSmkMtXSSUsLDFANExrZh2J'],
|
||||
]);
|
||||
|
||||
//
|
||||
// An example for admins based on high level api i.e. the client
|
||||
|
@ -59,6 +65,7 @@ async function main() {
|
|||
1.4,
|
||||
0.02,
|
||||
);
|
||||
await group.reload(client);
|
||||
} catch (error) {}
|
||||
|
||||
// stub oracle + register token 1
|
||||
|
@ -86,11 +93,11 @@ async function main() {
|
|||
1.4,
|
||||
0.02,
|
||||
);
|
||||
await group.reload(client);
|
||||
} catch (error) {}
|
||||
|
||||
// log tokens/banks
|
||||
const banks = await client.getBanksForGroup(group);
|
||||
for (const bank of banks) {
|
||||
for (const bank of await group.banksMap.values()) {
|
||||
console.log(
|
||||
`Bank ${bank.tokenIndex} ${bank.publicKey}, mint ${bank.mint}, oracle ${bank.oracle}`,
|
||||
);
|
||||
|
@ -106,18 +113,16 @@ async function main() {
|
|||
group,
|
||||
DEVNET_SERUM3_PROGRAM_ID,
|
||||
serumMarketExternalPk,
|
||||
banks[0],
|
||||
banks[1],
|
||||
group.banksMap.get('BTC')!,
|
||||
group.banksMap.get('USDC')!,
|
||||
0,
|
||||
'BTC/USDC',
|
||||
);
|
||||
} catch (error) {}
|
||||
const markets = await client.serum3GetMarket(
|
||||
group,
|
||||
banks.find((bank) => bank.mint.toBase58() === DEVNET_MINTS.get('BTC'))
|
||||
?.tokenIndex,
|
||||
banks.find((bank) => bank.mint.toBase58() === DEVNET_MINTS.get('USDC'))
|
||||
?.tokenIndex,
|
||||
group.banksMap.get('BTC')?.tokenIndex,
|
||||
group.banksMap.get('USDC')?.tokenIndex,
|
||||
);
|
||||
console.log(`Serum3 market ${markets[0].publicKey}`);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Provider, Wallet } from '@project-serum/anchor';
|
||||
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
|
||||
import { Connection, Keypair } from '@solana/web3.js';
|
||||
import fs from 'fs';
|
||||
import {
|
||||
Serum3OrderType,
|
||||
|
@ -7,7 +7,7 @@ import {
|
|||
Serum3Side,
|
||||
} from './accounts/serum3';
|
||||
import { MangoClient } from './client';
|
||||
import { DEVNET_GROUP, DEVNET_SERUM3_PROGRAM_ID } from './constants';
|
||||
import { DEVNET_SERUM3_PROGRAM_ID } from './constants';
|
||||
|
||||
//
|
||||
// An example for users based on high level api i.e. the client
|
||||
|
@ -30,13 +30,14 @@ async function main() {
|
|||
console.log(`User ${userWallet.publicKey.toBase58()}`);
|
||||
|
||||
// fetch group
|
||||
const group = await client.getGroup(new PublicKey(DEVNET_GROUP));
|
||||
const admin = Keypair.fromSecretKey(
|
||||
Buffer.from(
|
||||
JSON.parse(fs.readFileSync(process.env.ADMIN_KEYPAIR!, 'utf-8')),
|
||||
),
|
||||
);
|
||||
const group = await client.getGroupForAdmin(admin.publicKey);
|
||||
console.log(`Group ${group.publicKey.toBase58()}`);
|
||||
|
||||
for (const bank of group.banksMap.values()) {
|
||||
console.log(bank.publicKey.toBase58());
|
||||
}
|
||||
|
||||
// create + fetch account
|
||||
const mangoAccount = await client.getOrCreateMangoAccount(
|
||||
group,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
export { Group } from './client/accounts/group';
|
||||
export * from './client/accounts/I80F48';
|
||||
export { Group } from './accounts/group';
|
||||
export * from './accounts/I80F48';
|
||||
export {
|
||||
MangoAccount,
|
||||
TokenAccount,
|
||||
TokenAccountDto,
|
||||
} from './client/accounts/mangoAccount';
|
||||
export { StubOracle } from './client/accounts/oracle';
|
||||
export { Serum3Market } from './client/accounts/serum3';
|
||||
export * from './client/client';
|
||||
} from './accounts/mangoAccount';
|
||||
export { StubOracle } from './accounts/oracle';
|
||||
export { Serum3Market } from './accounts/serum3';
|
||||
export * from './client';
|
||||
|
|
|
@ -1569,7 +1569,7 @@ export type MangoV4 = {
|
|||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
16
|
||||
32
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -4085,7 +4085,7 @@ export const IDL: MangoV4 = {
|
|||
"type": {
|
||||
"array": [
|
||||
"u8",
|
||||
16
|
||||
32
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
"extends": "@tsconfig/recommended/tsconfig.json",
|
||||
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
|
@ -8,7 +7,9 @@
|
|||
"declarationDir": "dist",
|
||||
"declarationMap": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": ["es2019"],
|
||||
"lib": [
|
||||
"es2019"
|
||||
],
|
||||
"noImplicitAny": false,
|
||||
"outDir": "dist",
|
||||
"resolveJsonModule": true,
|
||||
|
@ -16,6 +17,12 @@
|
|||
"strictNullChecks": true,
|
||||
"target": "es6"
|
||||
},
|
||||
"include": ["./ts/**/*"],
|
||||
"exclude": ["./ts/**/*.test.js", "node_modules", "**/node_modules"]
|
||||
}
|
||||
"include": [
|
||||
"./src/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"./src/**/*.test.js",
|
||||
"node_modules",
|
||||
"**/node_modules"
|
||||
]
|
||||
}
|
|
@ -4,5 +4,4 @@ set -e pipefail
|
|||
|
||||
anchor build --skip-lint
|
||||
./idl-fixup.sh
|
||||
cp -v ./target/types/mango_v4.ts ./ts/mango_v4.ts
|
||||
tsc
|
||||
cp -v ./target/types/mango_v4.ts ./ts/client/src/mango_v4.ts
|
||||
|
|
Loading…
Reference in New Issue