Code Monkey home page Code Monkey logo

mango-v4's Introduction

work in progress

License

See the LICENSE file.

The majority of this repo is MIT licensed, but some parts needed for compiling the solana program are under GPL.

All GPL code is gated behind the enable-gpl feature. If you use the mango-v4 crate as a dependency with the client or cpi features, you use only MIT parts of it.

The intention is for you to be able to depend on the mango-v4 crate for building closed-source tools and integrations, including other solana programs that call into the mango program.

But deriving a solana program with similar functionality to the mango program from this codebase would require the changes and improvements to stay publicly available under GPL.

Development

See DEVELOPING.md and FAQ-DEV.md

Dependencies

  • rust version 1.70.0
  • solana-cli 1.16.7
  • anchor-cli 0.28.0
  • npm 8.1.2
  • node v16.13.1

Deployments

  • devnet: 4MangoMjqJ2firMokCjjGgoK8d4MXcrgL7XJaL3w6fVg
  • mainnet-beta: 4MangoMjqJ2firMokCjjGgoK8d4MXcrgL7XJaL3w6fVg
  • primary mango group on mainnet-beta: 78b8f4cGCwmZ9ysPFMWLaLTkkaYnUjwMJYStWe5RTSSX

Release

For program deployment, see RELEASING.md.

Here are steps followed while performing a npm package release note: the UI currently uses code directly from github, pointing to the ts-client branch

  • use yarn publish to release a new package, ensure compatibility with program release to mainnet-beta
  • fix the tag auto added by yarn to match our internal convention, see script fix-npm-tag.sh, tags should look like this e.g.npm-v0.0.1, note: the npm package version/tag should not necessarily match the latest program deployment

mango-v4's People

Contributors

abrzezinski94 avatar brittcyr avatar chen-robert avatar ckamm avatar conj0iner avatar dafyddd avatar farnyser avatar github-actions[bot] avatar godmodegalactus avatar gooddaisy avatar grooviegermanikus avatar hgarrereyn avatar lou-kamades avatar microwavedcola1 avatar mschneider avatar nicholasgodfreyclarke avatar riordanp avatar shuoer86 avatar silas-x avatar thibaultosec avatar tlrjs avatar vovacodes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mango-v4's Issues

Dependency openbook v2 problem

Greetings, I want to use your project and I get the openbook v2 dependencies error.

workspace Cargo.toml:

[workspace]
members = [ "lib/*",
    "programs/*"
]
resolver = "2"

[workspace.dependencies]
anchor-client = "=0.28.0"
anchor-spl = "=0.28.0"
anchor-lang = "=0.28.0"

solana-address-lookup-table-program = "~1.16.7"
solana-account-decoder = "~1.16.7"
solana-client = "~1.16.7"
solana-logger = "~1.16.7"
solana-program = "~1.16.7"
solana-program-test = "~1.16.7"
solana-rpc = "~1.16.7"
solana-sdk = { version = "~1.16.7", default-features = false }
solana-transaction-status = { version = "~1.16.7" }
serum_dex = { git = "https://github.com/openbook-dex/program.git", default-features=false }

openbook-v2 = { git = "https://github.com/openbook-dex/openbook-v2.git", rev = "270b2d2d473862bd4e3aa213feb970af81f4b3e2", features = ["no-entrypoint", "cpi", "enable-gpl"] }
mango-v4 = { path = "/Users/a1111/SolProject/mango-v4/programs/mango-v4", features = ["client"] }

[profile.release]
overflow-checks = true

[patch.crates-io]
anchor-lang = { git = "https://github.com/coral-xyz/anchor", tag = "v0.28.0" }
anchor-spl = { git = "https://github.com/coral-xyz/anchor", tag = "v0.28.0" }
anchor-client = { git = "https://github.com/coral-xyz/anchor", tag = "v0.28.0" }

Programs Cargo.toml:

[package]
name = "solana-project"
version = "0.1.0"
description = "Created with Anchor"
edition = "2021"

[lib]
crate-type = ["cdylib", "lib"]
name = "solana_project"

[features]
no-entrypoint = []
no-idl = []
no-log-ix-name = []
cpi = ["no-entrypoint"]
default = ["custom-heap"]
test-bpf = ["client"]
client = ["solana-sdk", "no-entrypoint"]
# Enables GPL-licensed parts of the code. See LICENSE file.
enable-gpl = ["openbook-v2/enable-gpl"]
custom-heap = []

[dependencies]
anchor-lang = { workspace = true }
anchor-spl = { workspace = true }

serum_dex = { workspace = true, features = ["no-entrypoint", "program"] }
solana-address-lookup-table-program = { workspace = true }
solana-program = { workspace = true }
solana-sdk = { workspace = true, default-features = false, optional = true }

openbook-v2 = { workspace = true, features = ["no-entrypoint", "cpi", "enable-gpl"] }

[dev-dependencies]
solana-sdk = { workspace = true, default-features = false }
solana-program-test = { workspace = true }
spl-token = { version = "^3.0.0", features = ["no-entrypoint"] }
spl-associated-token-account = { version = "^1.0.3", features = [
    "no-entrypoint",
] }

Problem:

Full error.docx

   Compiling openbook-v2 v0.1.0 (https://github.com/openbook-dex/openbook-v2.git?rev=270b2d2d473862bd4e3aa213feb970af81f4b3e2#270b2d2d)
error[E0119]: conflicting implementations of trait `Zeroable` for type `AnyEvent`
   --> /Users/a1111/.cargo/git/checkouts/openbook-v2-bb287b4bf73a7086/270b2d2/programs/openbook-v2/src/state/orderbook/heap.rs:220:32

Documention about how to deploy the project

I've compiled the project. Is there documention about how a developer should then properly run and deploy it, on his own? In the future I may need to tweak the settings, rewrite, enable, disable some things.

Borsh 0.9 vs 0.10 issue when updating to Solana 1.16

Goal

Figure out how to deal with the version conflict (scope=mango-v4, solana, anchor, mango-feeds-connector)

Problem

Some types defined in Solana SDK implement the borsh serialization traits of borsh 0.9 while other projects in the ecosystem already updated to borsh 0.10.
This sparks a lot if issues as stated here

Solana Fix for 1.16.7+

Error[E0277]: the trait bound `Pubkey: BorshSerialize` is not satisfied                                                                                                                                                                              
   --> src/system_program.rs:289:10                                                                                                                                                                                                                  
    |                                                                                                                                                                                                                                                
289 | #[derive(Accounts)]                                                                                                                                                                                                                            
    |          ^^^^^^^^ the trait `BorshSerialize` is not implemented for `Pubkey`                                                                                                                                                                   
    |                                                                                                                                                                                                                                                
    = help: the following other types implement trait `BorshSerialize`:                                                                                                                                                                              
              &T                                                                                                                                                                                                                                     
              ()                                                                                                                                                                                                                                     
              (T0, T1)                                                                                                                                                                                                                               
              (T0, T1, T2)                                                                                                                                                                                                                           
              (T0, T1, T2, T3)                                                                                                                                                                                                                       
              (T0, T1, T2, T3, T4)                                                                                                                                                                                                                   
              (T0, T1, T2, T3, T4, T5)                                                                                                                                                                                                               
              (T0, T1, T2, T3, T4, T5, T6)                                                                                                                                                                                                           
            and 121 others                                                                                                                                                                                                                           
    = help: see issue #48214                                                                                                                                                                                                                         
    = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable                                                                                                                                                                      
    = note: this error originates in the derive macro `Accounts` (in Nightly builds, run with -Z macro-backtrace for more info)   

```                                                                          `




type error

$npm run build

node_modules/@blockworks-foundation/mango-v4/dist/types/src/utils.d.ts:32:13 - error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.

32 private [As.$as$];
~~~~~~~~~

node_modules/@switchboard-xyz/sbv2-lite/node_modules/@project-serum/anchor/dist/cjs/program/namespace/types.d.ts:94:11 - error TS2322: Type 'FieldsOfType["name"]' is not assignable to type 'string | number | symbol'.

94 [F in FieldsOfType["name"]]: DecodeType<(FieldsOfType & {
~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@switchboard-xyz/sbv2-lite/node_modules/@project-serum/anchor/dist/cjs/program/namespace/types.d.ts:94:11 - error TS2536: Type '"name"' cannot be used to index type 'FieldsOfType'.

94 [F in FieldsOfType["name"]]: DecodeType<(FieldsOfType & {
~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@switchboard-xyz/sbv2-lite/node_modules/@project-serum/anchor/dist/cjs/program/namespace/types.d.ts:94:48 - error TS2344: Type 'FieldsOfType["type"]' does not satisfy the constraint 'IdlType'.

94 [F in FieldsOfType["name"]]: DecodeType<(FieldsOfType & {
~~~~~~~~~~~~~~~~~~~~
95 name: F;

96     })["type"], Defined>;
~~~~~~~~~~~~~~

node_modules/@switchboard-xyz/sbv2-lite/node_modules/@project-serum/anchor/dist/cjs/program/namespace/types.d.ts:94:48 - error TS2536: Type '"type"' cannot be used to index type 'FieldsOfType<I> & { name: F; }'.

94     [F in FieldsOfType<I>["name"]]: DecodeType<(FieldsOfType<I> & {
                                               ~~~~~~~~~~~~~~~~~~~~
95         name: F;

96 })["type"], Defined>;



Found 5 errors in 2 files.

Errors  Files
  1  node_modules/@blockworks-foundation/mango-v4/dist/types/src/utils.d.ts:32
  4  node_modules/@switchboard-xyz/sbv2-lite/node_modules/@project-serum/anchor/dist/cjs/program/namespace/types.d.ts:94

Liquidations are auctions

Placeholder issue for discussion.

I know little about this topic, but I am guessing that, the goal of this is that - within some pre determined health range, the bidder who offers best deal for the liquee gets to liquidate?

Type errors on trying to use typescript client on `perp-sanity-check.ts` script.

Hi, when I try to use mango-v4 client to run the perp-sanity-check.ts script, I got the following errors:

yarn start
yarn run v1.22.19
$ npm run build && node build/index.js

> [email protected] build
> rimraf ./build && tsc

node_modules/@blockworks-foundation/mango-v4/dist/types/src/utils.d.ts:32:13 - error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type.

32     private [As.$as$];
               ~~~~~~~~~

node_modules/@switchboard-xyz/sbv2-lite/node_modules/@project-serum/anchor/dist/cjs/program/namespace/types.d.ts:94:11 - error TS2322: Type 'FieldsOfType<I>["name"]' is not assignable to type 'string | number | symbol'.

94     [F in FieldsOfType<I>["name"]]: DecodeType<(FieldsOfType<I> & {
             ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@switchboard-xyz/sbv2-lite/node_modules/@project-serum/anchor/dist/cjs/program/namespace/types.d.ts:94:11 - error TS2536: Type '"name"' cannot be used to index type 'FieldsOfType<I>'.

94     [F in FieldsOfType<I>["name"]]: DecodeType<(FieldsOfType<I> & {
             ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@switchboard-xyz/sbv2-lite/node_modules/@project-serum/anchor/dist/cjs/program/namespace/types.d.ts:94:48 - error TS2344: Type 'FieldsOfType<I>["type"]' does not satisfy the constraint 'IdlType'.

94     [F in FieldsOfType<I>["name"]]: DecodeType<(FieldsOfType<I> & {
                                                  ~~~~~~~~~~~~~~~~~~~~
95         name: F;
   ~~~~~~~~~~~~~~~~
96     })["type"], Defined>;
   ~~~~~~~~~~~~~~

node_modules/@switchboard-xyz/sbv2-lite/node_modules/@project-serum/anchor/dist/cjs/program/namespace/types.d.ts:94:48 - error TS2536: Type '"type"' cannot be used to index type 'FieldsOfType<I> & { name: F; }'.

94     [F in FieldsOfType<I>["name"]]: DecodeType<(FieldsOfType<I> & {
                                                  ~~~~~~~~~~~~~~~~~~~~
95         name: F;
   ~~~~~~~~~~~~~~~~
96     })["type"], Defined>;
   ~~~~~~~~~~~~~~


Found 5 errors in 2 files.

Errors  Files
     1  node_modules/@blockworks-foundation/mango-v4/dist/types/src/utils.d.ts:32
     4  node_modules/@switchboard-xyz/sbv2-lite/node_modules/@project-serum/anchor/dist/cjs/program/namespace/types.d.ts:94
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The script I copied from: /mango-v4/ts/client/scripts/perp-sanity-check.ts

My typescript version: Version 4.8.4
My mango-v4 client version: "@blockworks-foundation/mango-v4": "^0.17.0",
My tsconfig:

{
  "compilerOptions": {
    "target": "ESNext",                          
    "module": "commonjs",                    
    "lib": ["es6","ESNext"],                     
    "allowJs": true,
    "outDir": "build",                          
    "rootDir": "src",
    "strict": true,         
    "noImplicitAny": true,
    "esModuleInterop": true,
    "resolveJsonModule": true
  }
}

error: failed to load manifest for workspace member `blockworks/mango-v4/bin/cli`

% cargo build
info: syncing channel updates for '1.65-x86_64-unknown-linux-gnu'
info: latest update on 2022-11-03, rust version 1.65.0 (897e37553 2022-11-02)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'

error: failed to load manifest for workspace member `blockworks/mango-v4/bin/cli`

Caused by:
  failed to load manifest for dependency `fixed`

Caused by:
  failed to read blockworks/mango-v4/3rdparty/fixed/Cargo.toml`

Caused by:
  No such file or directory (os error 2)

Unable to use rust client

 *  Executing task: cargo run --package mango-rs --bin mango-rs 

   Compiling protobuf-src v1.1.0+21.5
   Compiling solana-transaction-status v1.14.17
   Compiling openssl v0.10.50
   Compiling openssl-sys v0.9.85
   Compiling librocksdb-sys v0.8.3+7.4.4
warning: use of deprecated associated function `solana_program::pubkey::Pubkey::new`: Please use 'Pubkey::from' or 'Pubkey::try_from' instead
   --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/3rdparty/anchor/lang/src/lib.rs:308:21
    |
308 |             Pubkey::new(self)
    |                     ^^^
    |
    = note: `#[warn(deprecated)]` on by default

warning: `anchor-lang` (lib) generated 1 warning
   Compiling mango-v4 v0.14.0 (/Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4)
   Compiling solana-storage-proto v1.14.17
   Compiling yellowstone-grpc-proto v1.1.0+solana.1.15.2
   Compiling rocksdb v0.19.0
   Compiling solana-client v1.14.17
error[E0080]: evaluation of constant value failed
   --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/bank.rs:141:1
    |
141 | / const_assert_eq!(
142 | |     size_of::<Bank>(),
143 | |     32 + 16
144 | |         + 32 * 3
...   |
168 | |         + 2118
169 | | );
    | |_^ attempt to compute `0_usize - 1_usize`, which would overflow
    |
    = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
   --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/bank.rs:170:1
    |
170 | const_assert_eq!(size_of::<Bank>(), 3064);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
    |
    = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
  --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/group.rs:93:1
   |
93 | / const_assert_eq!(
94 | |     size_of::<Group>(),
95 | |     32 + 4 + 32 * 2 + 4 + 32 * 2 + 4 + 4 + 20 * 32 + 32 + 8 + 16 + 32 + 8 + 1824
96 | | );
   | |_^ attempt to compute `0_usize - 1_usize`, which would overflow
   |
   = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
  --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/group.rs:97:1
   |
97 | const_assert_eq!(size_of::<Group>(), 2736);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
   |
   = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

   Compiling smpl_jwt v0.7.1
error[E0080]: evaluation of constant value failed
  --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/mango_account_components.rs:49:1
   |
49 | / const_assert_eq!(
50 | |     size_of::<TokenPosition>(),
51 | |     16 + 2 + 1 + 5 + 16 + 8 + 8 + 128
52 | | );
   | |_^ attempt to compute `0_usize - 1_usize`, which would overflow
   |
   = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
  --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/mango_account_components.rs:53:1
   |
53 | const_assert_eq!(size_of::<TokenPosition>(), 184);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
   |
   = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
   --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/mango_account_components.rs:269:1
    |
269 | / const_assert_eq!(
270 | |     size_of::<PerpPosition>(),
271 | |     2 + 2 + 4 + 8 + 8 + 16 + 8 + 16 * 2 + 8 * 2 + 8 * 2 + 8 * 5 + 8 + 2 * 16 + 8 + 16 + 88
272 | | );
    | |_^ attempt to compute `0_usize - 1_usize`, which would overflow
    |
    = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
   --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/mango_account_components.rs:273:1
    |
273 | const_assert_eq!(size_of::<PerpPosition>(), 304);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
    |
    = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
   --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/oracle.rs:104:1
    |
104 | const_assert_eq!(size_of::<StubOracle>(), 32 + 32 + 16 + 8 + 128);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
    |
    = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
   --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/oracle.rs:105:1
    |
105 | const_assert_eq!(size_of::<StubOracle>(), 216);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
    |
    = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
   --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/orderbook/nodes.rs:101:1
    |
101 | const_assert_eq!(size_of::<InnerNode>(), 4 + 4 + 16 + 4 * 2 + 8 * 2 + 72);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
    |
    = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
   --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/orderbook/nodes.rs:102:1
    |
102 | const_assert_eq!(size_of::<InnerNode>(), NODE_SIZE);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
    |
    = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
   --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/orderbook/nodes.rs:187:1
    |
187 | / const_assert_eq!(
188 | |     size_of::<LeafNode>(),
189 | |     4 + 1 + 1 + 1 + 1 + 16 + 32 + 8 + 8 + 8 + 8 + 32
190 | | );
    | |_^ attempt to compute `0_usize - 1_usize`, which would overflow
    |
    = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
   --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/orderbook/nodes.rs:191:1
    |
191 | const_assert_eq!(size_of::<LeafNode>(), NODE_SIZE);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
    |
    = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
   --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/orderbook/nodes.rs:268:1
    |
268 | const_assert_eq!(size_of::<AnyNode>(), size_of::<InnerNode>());
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
    |
    = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
   --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/orderbook/nodes.rs:269:1
    |
269 | const_assert_eq!(size_of::<AnyNode>(), size_of::<LeafNode>());
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
    |
    = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
   --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/perp_market.rs:172:1
    |
172 | / const_assert_eq!(
173 | |     size_of::<PerpMarket>(),
174 | |     32 + 2
175 | |         + 2
...   |
205 | |         + 1888
206 | | );
    | |_^ attempt to compute `0_usize - 1_usize`, which would overflow
    |
    = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0080]: evaluation of constant value failed
   --> /Users/0x4ka5h/Documents/intern/osec/mango/dependencies/programs/mango-v4/src/state/perp_market.rs:207:1
    |
207 | const_assert_eq!(size_of::<PerpMarket>(), 2808);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
    |
    = note: this error originates in the macro `const_assert` which comes from the expansion of the macro `const_assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0080`.
error: could not compile `mango-v4` due to 18 previous errors
warning: build failed, waiting for other jobs to finish...

 *  The terminal process "cargo 'run', '--package', 'mango-rs', '--bin', 'mango-rs'" terminated with exit code: 101. 
 *  Terminal will be reused by tasks, press any key to close it. 

and this is the cargo.toml I had

[package]
name = "mango-rs"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
mango-v4-client = { path = "../dependencies/lib/client"}

Dependencies and compiling problems

Greetings, I want to try your program and I am encountering errors with your repository. My Cargo.toml file uses supported dependencies from the mango-v4 project but when I load the mango dependencies I get a version compatibility error. The dependencies forcibly install version 0.30.0 of anchor, even though I explicitly specify each file.

Problem with dependencies.

My Cargo.toml file:

[workspace.dependencies]
anchor-client = "=0.28.0"
anchor-spl = "=0.28.0"
anchor-lang = "=0.28.0"
solana-program = "~1.16.7"
solana-address-lookup-table-program = "~1.16.7"
mango-v4 = { git = "https://github.com/blockworks-foundation/mango-v4", features = ["client"] }

[profile.release]
overflow-checks = true

[patch.crates-io]
anchor-lang = { git = "https://github.com/coral-xyz/anchor", tag = "v0.28.0" }
anchor-spl = { git = "https://github.com/coral-xyz/anchor", tag = "v0.28.0" }
anchor-client = { git = "https://github.com/coral-xyz/anchor", tag = "v0.28.0" }

When "anchor-lang = "=0.28.0"" I get an incompatibility error with:

"Compiling openbook-v2 v0.1.0 (https://github.com/openbook-dex/openbook-v2.git?rev=270b2d2d473862bd4e3aa213feb970af81f4b3e2#270b2d2d)"

In all cases, the error is related to "openbook-v2" which occurs with version 28 and 29:

"Compiling switchboard-solana v0.28.98
   Compiling openbook-v2 v0.1.0 (https://github.com/openbook-dex/openbook-v2.git?rev=270b2d2d473862bd4e3aa213feb970af81f4b3e2#270b2d2d)
   Compiling anchor-derive-space v0.30.0 (https://github.com/coral-xyz/anchor?tag=v0.30.0#852fcc77)" 

But version 30 gives incompatibility with the Solana program.

Forcing the installation of "openbook-v2" versions above is not successful, mango-v4 still pulls its version.

What to do with this dependency error and how to fix it?
Building errors.docx

PerpMarkets currently can only exist for registered tokens

While each PerpMarket stores its own oracle account, the health code (and possibly other parts of the code) is not able to deal with that. Instead it uses the oracle registered for the base_token_index.

Technically, we can allow creating perp markets for oracles that are not associated with any spot token.

TODO:

  • drop base_token_index in PerpMarket
  • in health, don't use base_token_index to look up the oracle
  • instead, pass an oracle account along with each PerpMarket (this will mean each perp market now requires two accounts for health checking instead of one!)

Update to use Solana 1.16 and Anchor 0.28

Scope

  • Update the mango-v4 project (latest) (including program+client) to use Solana Version 1.16.x and Anchor 0.28
  • Update mango-feeds accordingly (mango-feeds issue)
  • drop support for solana 1.14
  • try to avoid anchor gitref 2af9cc669
  • use appropriate openbook-v2 version
  • use appropriate switchboard version
  • rust 1.69

Acceptance Criteria

  • try to make it work with clean Cargo.lock (cargo generate-lockfile && cargo build)

Misc

ts/client further work

Here is a collection of client improvements

  • should client methods should take amounts in I80F48 type and not as number type e.g. deposit, withdraw, etc. wherever applicable?
  • should client methods should take token indices and not token names as args?
  • support for perps
  • basic perp market maker
  • general ergonomics, imo, we should wait for feedback before making premature style optimisations

How to limit risk, and avoid contamination if we add arbirary number of tokens

This is a placeholder issue for discussing. This comes out of @dafyddd 's notion notes. I think we should discuss this in detail and maybe also survey how other exchanges do this.

3. arbitrary number of tokens and markets, so more MAX_PAIRS
    1. find a way to limit risk โ†’ then we can add any token and not worry about contamination. perhaps limit deposits and borrows. perhaps attach 
    2. limiting deposits might also require separating collateral and lend deposits

localdev/CI: error: toolchain 'sbf' is not installed (or bpf)

Problem

Building or testing the onchain program fails.

cargo +bpf build-bpf --features enable-gpl
or
cargo +bpf build-bpf --features enable-gpl

gives these errors:
error: toolchain 'bpf' is not installed
respectively
error: toolchain 'sbf' is not installed

Solana 1.16.14
Mango-v4 commit fd997e2

Optimal rate would be pegged to oracle to avoid massive spread in borrow and lend rates

daffy from discord: Interest rate pegged to an interest rate oracle, the optimal rate would be pegged to oracle. We can still override it but it makes the lending markets more efficient. For example, the optimal rate of USDC is like 10% or something which causes massive spread in borrow and lend rates right now when market is not really willing to pay 10%.

typescript client banks may be in wrong order in buildHealthRemainingAccounts

Sometimes new token positions will be activated by the instruction. Then these new positions must have the right positioning in the health accounts list.

Currently it just collects them, adds the indexes from banks?: Bank[] and Sets it.

Instead find a free position and use it. (alternatively mutate the mangoAccount and activate a new position on the client side beforehand)

Monorepos yay/nay?

I am a big fan of monorepos, since versioning, and features can be built/tested/reviewed and documented well (github comments etc.) for future contributors.

What can get a bit out of hand usually are CI workflows, but I have also managed those across large projects in previous years, so not an issue imo.

We could have at minimum the program and client here, UI could be separate? python client could also live here maybe? What else?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.