Fix client usage

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
microwavedcola1 2022-06-18 16:46:46 +02:00
parent 4864562ff3
commit 0a5ba2d4f4
2 changed files with 98 additions and 5 deletions

View File

@ -208,6 +208,12 @@ export type MangoV4 = {
"name": "name",
"type": "string"
},
{
"name": "oracleConfig",
"type": {
"defined": "OracleConfig"
}
},
{
"name": "interestRateParams",
"type": {
@ -1446,6 +1452,12 @@ export type MangoV4 = {
"name": "name",
"type": "string"
},
{
"name": "oracleConfig",
"type": {
"defined": "OracleConfig"
}
},
{
"name": "baseTokenIndexOpt",
"type": {
@ -1900,6 +1912,12 @@ export type MangoV4 = {
"name": "oracle",
"type": "publicKey"
},
{
"name": "oracleConfig",
"type": {
"defined": "OracleConfig"
}
},
{
"name": "depositIndex",
"type": {
@ -2330,6 +2348,12 @@ export type MangoV4 = {
"name": "oracle",
"type": "publicKey"
},
{
"name": "oracleConfig",
"type": {
"defined": "OracleConfig"
}
},
{
"name": "bids",
"type": "publicKey"
@ -2779,6 +2803,20 @@ export type MangoV4 = {
]
}
},
{
"name": "OracleConfig",
"type": {
"kind": "struct",
"fields": [
{
"name": "confFilter",
"type": {
"defined": "I80F48"
}
}
]
}
},
{
"name": "AnyNode",
"type": {
@ -2999,11 +3037,17 @@ export type MangoV4 = {
"type": {
"kind": "enum",
"variants": [
{
"name": "Pyth"
},
{
"name": "Stub"
},
{
"name": "Pyth"
"name": "SwitchboardV1"
},
{
"name": "SwitchboardV2"
}
]
}
@ -3397,6 +3441,12 @@ export const IDL: MangoV4 = {
"name": "name",
"type": "string"
},
{
"name": "oracleConfig",
"type": {
"defined": "OracleConfig"
}
},
{
"name": "interestRateParams",
"type": {
@ -4635,6 +4685,12 @@ export const IDL: MangoV4 = {
"name": "name",
"type": "string"
},
{
"name": "oracleConfig",
"type": {
"defined": "OracleConfig"
}
},
{
"name": "baseTokenIndexOpt",
"type": {
@ -5089,6 +5145,12 @@ export const IDL: MangoV4 = {
"name": "oracle",
"type": "publicKey"
},
{
"name": "oracleConfig",
"type": {
"defined": "OracleConfig"
}
},
{
"name": "depositIndex",
"type": {
@ -5519,6 +5581,12 @@ export const IDL: MangoV4 = {
"name": "oracle",
"type": "publicKey"
},
{
"name": "oracleConfig",
"type": {
"defined": "OracleConfig"
}
},
{
"name": "bids",
"type": "publicKey"
@ -5968,6 +6036,20 @@ export const IDL: MangoV4 = {
]
}
},
{
"name": "OracleConfig",
"type": {
"kind": "struct",
"fields": [
{
"name": "confFilter",
"type": {
"defined": "I80F48"
}
}
]
}
},
{
"name": "AnyNode",
"type": {
@ -6188,11 +6270,17 @@ export const IDL: MangoV4 = {
"type": {
"kind": "enum",
"variants": [
{
"name": "Pyth"
},
{
"name": "Stub"
},
{
"name": "Pyth"
"name": "SwitchboardV1"
},
{
"name": "SwitchboardV2"
}
]
}

View File

@ -48,7 +48,7 @@ async function main() {
let amount = 0.001;
let token = 'BTC';
console.log(`Depositing...${amount} 'BTC'`);
await user1Client.deposit(group, user1MangoAccount, token, amount);
await user1Client.tokenDeposit(group, user1MangoAccount, token, amount);
await user1MangoAccount.reload(user1Client);
console.log(`${user1MangoAccount.toString(group)}`);
@ -78,7 +78,7 @@ async function main() {
/// user2 deposits some collateral and borrows BTC
console.log(`Depositing...${300} 'USDC'`);
await user2Client.deposit(group, user2MangoAccount, 'USDC', 300);
await user2Client.tokenDeposit(group, user2MangoAccount, 'USDC', 300);
await user2MangoAccount.reload(user2Client);
console.log(`${user2MangoAccount.toString(group)}`);
amount = amount / 10;
@ -107,7 +107,12 @@ async function main() {
const adminWallet = new Wallet(admin);
console.log(`Admin ${adminWallet.publicKey.toBase58()}`);
const adminProvider = new AnchorProvider(connection, adminWallet, options);
const client = await MangoClient.connect(adminProvider, true);
const client = await MangoClient.connect(
adminProvider,
'devnet',
MANGO_V4_ID['devnet'],
false,
);
await client.setStubOracle(group, group.banksMap.get('USDC')?.oracle!, 0.5);
process.exit();