Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into man0s/sdk-prep-2
Browse files Browse the repository at this point in the history
  • Loading branch information
losman0s committed Sep 3, 2023
2 parents 9be7ef3 + ea61c4b commit dcbd18d
Show file tree
Hide file tree
Showing 22 changed files with 65 additions and 87 deletions.
2 changes: 1 addition & 1 deletion apps/marginfi-landing-page/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint-fix": "yarn lint --fix"
},
"dependencies": {
"@coral-xyz/borsh": "^0.26.0",
"@coral-xyz/borsh": "^0.28.0",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@mrgnlabs/mrgn-common": "*",
Expand Down
2 changes: 1 addition & 1 deletion apps/marginfi-v2-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint-fix": "yarn lint --fix"
},
"dependencies": {
"@coral-xyz/borsh": "^0.26.0",
"@coral-xyz/borsh": "^0.28.0",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@mrgnlabs/lip-client": "*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@ const AssetRow: FC<{
style={{ fontWeight: 300 }}
>
{isInLendingMode
? bank.info.rawBank.config.assetWeightMaint.toNumber() > 0
? (bank.info.rawBank.config.assetWeightMaint.toNumber() * 100).toFixed(0) + "%"
? bank.info.rawBank.config.assetWeightInit.toNumber() > 0
? (bank.info.rawBank.config.assetWeightInit.toNumber() * 100).toFixed(0) + "%"
: "-"
: ((1 / bank.info.rawBank.config.liabilityWeightInit.toNumber()) * 100).toFixed(0) + "%"}
</TableCell>
Expand Down
7 changes: 2 additions & 5 deletions apps/marginfi-v2-ui/src/components/CampaignWizard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { FC, useCallback, useEffect, useMemo, useState } from "react";
import { Keypair, SystemProgram, Transaction } from "@solana/web3.js";
import { associatedAddress } from "@project-serum/anchor/dist/cjs/utils/token";
import BN from "bn.js";
import {
uiToNative,
Expand All @@ -11,6 +10,7 @@ import {
createAssociatedTokenAccountIdempotentInstruction,
createSyncNativeInstruction,
NATIVE_MINT,
getAssociatedTokenAddressSync,
} from "@mrgnlabs/mrgn-common";
import { useLipClient } from "~/context";
import { useWallet } from "@solana/wallet-adapter-react";
Expand Down Expand Up @@ -133,10 +133,7 @@ const CampaignWizard: FC<CampaignWizardProps> = () => {

const campaignKeypair = Keypair.generate();
console.log("creating campaign", campaignKeypair.publicKey.toBase58());
const userTokenAtaPk = await associatedAddress({
mint: campaignBank.mint,
owner: lipClient.wallet.publicKey,
});
const userTokenAtaPk = getAssociatedTokenAddressSync(campaignBank.mint, lipClient.wallet.publicKey);

const tx = new Transaction();

Expand Down
2 changes: 1 addition & 1 deletion apps/marginfi-v2-xnft/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"clean": "rimraf dist node_modules .expo web-build"
},
"dependencies": {
"@coral-xyz/anchor": "^0.28.0",
"@coral-xyz/anchor": "^0.28.1-beta.2",
"@coral-xyz/common": "^0.6.6-latest.5027",
"@expo-google-fonts/dev": "*",
"@expo/vector-icons": "^13.0.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/omni/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"lint-fix": "yarn lint --fix"
},
"dependencies": {
"@coral-xyz/anchor": "^0.27.0",
"@coral-xyz/borsh": "^0.26.0",
"@coral-xyz/anchor": "^0.28.1-beta.2",
"@coral-xyz/borsh": "^0.28.0",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@google-cloud/bigquery": "^6.2.0",
Expand Down
4 changes: 1 addition & 3 deletions apps/omni/src/api/ai/tools/decodedAccounts.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Tool } from "langchain/tools";
import { Wallet } from "@coral-xyz/anchor";
import { inflate } from "pako";
import { AccountInfo, Connection, PublicKey } from "@solana/web3.js";
import { AnchorProvider, BorshAccountsCoder, Program, translateAddress } from "@coral-xyz/anchor";
import { AnchorProvider, BorshAccountsCoder, Program, translateAddress, Wallet, Idl } from "@coral-xyz/anchor";
import { decodeIdlAccount, idlAddress } from "@coral-xyz/anchor/dist/cjs/idl";
import { utf8 } from "@coral-xyz/anchor/dist/cjs/utils/bytes";
import { Idl } from "@project-serum/anchor";
import { MARGINFI_IDL } from "@mrgnlabs/marginfi-client-v2";

const SUPPORTED_PROGRAMS: { [programId: string]: string } = {
Expand Down
4 changes: 2 additions & 2 deletions packages/lip-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"build": "tsc -p tsconfig.json"
},
"dependencies": {
"@coral-xyz/anchor": "^0.26.0",
"@coral-xyz/anchor": "^0.28.1-beta.2",
"@mrgnlabs/marginfi-client-v2": "*",
"@mrgnlabs/mrgn-common": "*",
"@project-serum/anchor": "^0.26.0",
"@solana/wallet-adapter-base": "^0.9.20",
"@solana/web3.js": "^1.71.0",
"bignumber.js": "^9.1.1",
"bs58": "^5.0.0",
"decimal.js": "^10.4.3",
"superstruct": "^1.0.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/lip-client/src/account.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address, BN, BorshCoder, translateAddress } from "@project-serum/anchor";
import { Address, BN, BorshCoder, translateAddress } from "@coral-xyz/anchor";
import { Keypair, PublicKey, Transaction } from "@solana/web3.js";
import BigNumber from "bignumber.js";
import { LIP_IDL } from ".";
Expand Down
16 changes: 6 additions & 10 deletions packages/lip-client/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { AnchorProvider, Program } from "@project-serum/anchor";
import { associatedAddress } from "@project-serum/anchor/dist/cjs/utils/token";
import { bs58 } from "@project-serum/anchor/dist/cjs/utils/bytes";
import { AnchorProvider, Program, Address, translateAddress } from "@coral-xyz/anchor";
import {
ConfirmOptions,
Connection,
Expand All @@ -18,19 +16,20 @@ import { LIP_IDL } from "./idl";
import instructions from "./instructions";
import { DEPOSIT_MFI_AUTH_SIGNER_SEED, MARGINFI_ACCOUNT_SEED } from "./constants";
import { Bank, MarginfiClient } from "@mrgnlabs/marginfi-client-v2";
import { Address, translateAddress } from "@coral-xyz/anchor";
import { Campaign, DepositData } from "./account";
import {
Amount,
createAssociatedTokenAccountIdempotentInstruction,
createSyncNativeInstruction,
DEFAULT_CONFIRM_OPTS,
getAssociatedTokenAddressSync,
InstructionsWrapper,
NATIVE_MINT,
TransactionOptions,
uiToNative,
Wallet,
} from "@mrgnlabs/mrgn-common";
import base58 from "bs58";
/**
* Entrypoint to interact with the LIP contract.
*/
Expand Down Expand Up @@ -151,10 +150,7 @@ class LipClient {
async makeDepositIx(campaign: PublicKey, amount: Amount, bank: Bank): Promise<InstructionsWrapper> {
const depositKeypair = Keypair.generate();
const tempTokenAccountKeypair = Keypair.generate();
const userTokenAtaPk = await associatedAddress({
mint: bank.mint,
owner: this.mfiClient.provider.wallet.publicKey,
});
const userTokenAtaPk = getAssociatedTokenAddressSync(bank.mint, this.mfiClient.provider.wallet.publicKey);
const amountNative = uiToNative(amount, bank.mintDecimals);

const ixs = [];
Expand Down Expand Up @@ -236,7 +232,7 @@ class LipClient {

const versionedMessage = new TransactionMessage({
instructions: transaction.instructions,
payerKey: this.mfiClient.provider.publicKey,
payerKey: this.mfiClient.provider.wallet.publicKey,
recentBlockhash: blockhash,
});

Expand All @@ -257,7 +253,7 @@ class LipClient {
console.log(response.value.logs);

const signaturesEncoded = encodeURIComponent(
JSON.stringify(versionedTransaction.signatures.map((s) => bs58.encode(s)))
JSON.stringify(versionedTransaction.signatures.map((s) => base58.encode(s)))
);
const messageEncoded = encodeURIComponent(
Buffer.from(versionedTransaction.message.serialize()).toString("base64")
Expand Down
4 changes: 2 additions & 2 deletions packages/marginfi-client-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"src"
],
"dependencies": {
"@coral-xyz/anchor": "^0.26.0",
"@coral-xyz/anchor": "^0.28.1-beta.2",
"@mrgnlabs/mrgn-common": "*",
"@project-serum/anchor": "^0.26.0",
"@solana/wallet-adapter-base": "^0.9.20",
"@solana/web3.js": "^1.71.0",
"bignumber.js": "^9.1.1",
"bs58": "^5.0.0",
"decimal.js": "^10.4.3",
"superstruct": "^1.0.3"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/marginfi-client-v2/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Address, AnchorProvider, BorshAccountsCoder, Program, translateAddress } from "@project-serum/anchor";
import { bs58 } from "@project-serum/anchor/dist/cjs/utils/bytes";
import { Address, AnchorProvider, BorshAccountsCoder, Program, translateAddress } from "@coral-xyz/anchor";
import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes";
import {
Commitment,
ConfirmOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/marginfi-client-v2/src/models/account/wrapper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Amount, DEFAULT_COMMITMENT, InstructionsWrapper, shortenAddress } from "@mrgnlabs/mrgn-common";
import { Address, BorshCoder, translateAddress } from "@project-serum/anchor";
import { Address, BorshCoder, translateAddress } from "@coral-xyz/anchor";
import { AccountMeta, Commitment, PublicKey, Transaction } from "@solana/web3.js";
import BigNumber from "bignumber.js";
import { MarginfiClient, MarginfiGroup } from "../..";
Expand Down
5 changes: 3 additions & 2 deletions packages/marginfi-client-v2/src/models/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PublicKey } from "@solana/web3.js";
import BigNumber from "bignumber.js";
import { OraclePrice, MarginRequirementType, PriceBias } from "..";
import { Bank } from "./bank";
import BN from "bn.js";

// ----------------------------------------------------------------------------
// On-chain types
Expand All @@ -14,7 +15,7 @@ interface BalanceRaw {
assetShares: WrappedI80F48;
liabilityShares: WrappedI80F48;
emissionsOutstanding: WrappedI80F48;
lastUpdate: number;
lastUpdate: BN;
}

export type { BalanceRaw };
Expand Down Expand Up @@ -53,7 +54,7 @@ class Balance {
const assetShares = wrappedI80F48toBigNumber(balanceRaw.assetShares);
const liabilityShares = wrappedI80F48toBigNumber(balanceRaw.liabilityShares);
const emissionsOutstanding = wrappedI80F48toBigNumber(balanceRaw.emissionsOutstanding);
const lastUpdate = balanceRaw.lastUpdate;
const lastUpdate = balanceRaw.lastUpdate.toNumber();

return new Balance(active, bankPk, assetShares, liabilityShares, emissionsOutstanding, lastUpdate);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/marginfi-client-v2/src/models/group.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BorshCoder } from "@project-serum/anchor";
import { BorshCoder } from "@coral-xyz/anchor";
import { PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import { MARGINFI_IDL } from "../idl";
Expand Down
2 changes: 0 additions & 2 deletions packages/marginfi-client-v2/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ import {
} from "./constants";
import { BankVaultType } from "./types";
import {
Amount,
NATIVE_MINT,
createAssociatedTokenAccountIdempotentInstruction,
uiToNative,
createSyncNativeInstruction,
createCloseAccountInstruction,
getAssociatedTokenAddressSync,
} from "@mrgnlabs/mrgn-common";
import { associatedAddress } from "@project-serum/anchor/dist/cjs/utils/token";
import BigNumber from "bignumber.js";

export function getBankVaultSeeds(type: BankVaultType): Buffer {
Expand Down
3 changes: 1 addition & 2 deletions packages/marginfi-v2-ui-state/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
"build": "tsc -p tsconfig.json"
},
"dependencies": {
"@coral-xyz/anchor": "^0.26.0",
"@coral-xyz/anchor": "^0.28.1-beta.2",
"@mrgnlabs/marginfi-client-v2": "*",
"@project-serum/anchor": "^0.26.0",
"@solana/buffer-layout-utils": "^0.2.0",
"@solana/wallet-adapter-base": "^0.9.20",
"@solana/web3.js": "^1.71.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/mrgn-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"build": "tsc -p tsconfig.json"
},
"dependencies": {
"@coral-xyz/anchor": "^0.26.0",
"@project-serum/anchor": "^0.26.0",
"@coral-xyz/anchor": "^0.28.1-beta.2",
"@solana/buffer-layout-utils": "^0.2.0",
"@solana/wallet-adapter-base": "^0.9.20",
"@solana/web3.js": "^1.71.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/mrgn-common/src/conversion.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address, BN } from "@project-serum/anchor";
import { Address, BN } from "@coral-xyz/anchor";
import BigNumber from "bignumber.js";
import { Decimal } from "decimal.js";
import { Amount } from "./types";
Expand Down
2 changes: 1 addition & 1 deletion packages/mrgn-common/src/misc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnchorProvider } from "@project-serum/anchor";
import { AnchorProvider } from "@coral-xyz/anchor";
import { ConfirmOptions, Connection, Keypair, Signer, Transaction, TransactionSignature } from "@solana/web3.js";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/mrgn-common/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnchorProvider, BN, Program as AnchorProgram } from "@project-serum/anchor";
import { AnchorProvider, BN, Program as AnchorProgram } from "@coral-xyz/anchor";
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
import { ConfirmOptions, Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js";
import BigNumber from "bignumber.js";
Expand Down
Loading

0 comments on commit dcbd18d

Please sign in to comment.