tulipv2 vaults and v1 lending program sdk & examples

Overview

tulipv2-sdk

Warning

Unaudited, possibly untested sdk Tulip Protocol takes no responsibility for any (financial, physical, emotional, etc..) damage that results from usage of this sdk, nor makes any guarantee as to the correctness of the sdk. Users of these crates take full responsibility for any mishaps that results from the usage of this sdk.

all crate versions before 0.9.17 are broken and will not work

Overview

tulipv2-sdk is a set of crates for interacting with Tulip V2 vaults, and V1 lending programs via CPI, however it is also usable with off-chain rust clients. The goal of this crate is to provide an easy to use sdk for working with the Tulip Protocol, while also serving as a sort of "configuration file".

There are 4 main crates which are detailed below

Crates

common

The common crate bundles together common functionality used by all the other crates, while also containing a module called config which contains many sub-modules, each containing all configuration information needed for interacting with a particular vault. For example common/config/lending/usdc.rs contains all needed accounts for working with the Tulip V2 USDC lending optimizer vault.

deposit_tracking module

The "Deposit Tracking" account is a user owned account which serves two main purposes, the first acting as a "lockup" account whenever a user deposits assets, locking withdrawal for 10 minutes allowing one or more compounding cycles to take place before a user withdraw, ensuring that compounding rewards can't be gamed via quickly depositing and exiting a vault. Second is providing the ability for users to track their rewards over time.

farms

The farms crate provides an enum named Farm, which is used to describe different platforms (ie Raydium) and farms within those platforms (ie RAY-USDC). In addition to this the farm key itself is used to enable deterministic derivation of vault addresses that are self describing.

The wire representation of the farm type / farm key, is a 2 element slice of u64's, where the first element (farm identifier) is the protocol, and the second element is the particular vault for that protocol.

lending

Provides very basic support for creating instructions, and issuing CPI calls to Tulip's V1 lending program. It allows for the lending of assets through the Obligation account, while also allowing the caller to refresh obligations and refresh reserves.

vaults

Provides all v2 vault account types, and associated helper functions, etc..

V1 Support

Within the v1 folder you will find a single tulipv1-sdk crate, which provides selected functions, accounts, etc... of v1

Examples

For now the only usage examples are in the examples folder which contains a basic program to register a deposit trackign account for the USDC lending optimizer, and for depositing into the USDC lending optimizer, and withdrawing from the lending optimizer.

Due to the architecture of Tulip's V2 vaults program, the deposit instructions will fail on localnet as there are some sweeping mechanisms used to sweep funds internally between the various protocols that a single optimizer vault supports.

Additionally the localnet setup clones mainnet state to provide a stable set of accounts, etc.. that are used for testing. For instance at the time the snapshot was taken, the USDC lending optimizer was deposited into Solend only. As such the instructions for tulip/mango deposits fail to execute correctly.

These erros have been caught so that when running anchor test all tests pass.

Comments
  • [WIP] LYF Examples

    [WIP] LYF Examples

    TODO

    • add instructions [x]
    • add remaining accounts [x]
      • add_liquidity_stats [x]
      • close_position_info [x]
      • create_user_farm_obligation [x]
      • create_user_farm [x]
      • deposit_borrow_dual [x]
      • deposit_raydium_vault [x]
      • orca_add_liquidity_queue [x]
      • swap_tokens_orca_stats [x]
      • swap_tokens_raydium_stats [x]
      • top_up_position_stats [x]
      • withdraw_orca_vault_dd_close [x]
      • withdraw_orca_vault [x]
      • withdraw_raydium_vault_close [x]
    • add examples [ ]
      • raydium [ ]
      • orca [ ]
    opened by bonedaddy 1
  • Remove ACL Check From Rebase Instructions & Add Rebase Examples

    Remove ACL Check From Rebase Instructions & Add Rebase Examples

    Overview

    To make integrations easier, I've included a version of the v2 vaults program that has the whitelisted address check in the rebase instructions disabled. This will allow developers to trigger interest accrual in localnet environments without any hacky work arounds.

    opened by bonedaddy 0
  • add new switchboard oracle addresses

    add new switchboard oracle addresses

    switchboard oracle address change

    USDC: change from CZx29wKMUxaJDq6aLVQTdViPL754tTR64NAgQBUGxxHb => BjUgj6YCnFBZ49wF54ddBVA9qu8TeqkFtkbqmZcee8uW
    RAY: change from CppyF6264uKZkGua1brTUa2fSVdMFSCszwzDs76HCuzU => 2oALNZVi5czyHvKbnjE4Jf2gR7dNp1FBpEGaq4PzVAf7
    USDT: change from 5mp8kbkTYwWWCsKSte8rURjTuyinsqBpJ9xAQsewPDD => ETAaeeuQBwsh9mC2gCov9WdhJENZuffRMXY2HgjCcSL9
    SOL: change from AdtRGGhmqvom3Jemp5YNrxd9q9unX36BZk1pujkkXijL => GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR
    
    opened by bonedaddy 0
  • [WIP] Add Traits For Strategy Vault Configuration

    [WIP] Add Traits For Strategy Vault Configuration

    Overview

    Adds trait based configuration for multi deposit / strategy vaults to enable easier integration, and reduce boilerplate code.

    Before:

                    // requires specific code due to namespaces for each strategy vault
                    let registration_trait = tulipv2_sdk_common::config::strategy::usdc::multi_deposit::ProgramConfig::register_deposit_tracking_ix(
                            *ctx.accounts.authority.key,
                        );
    

    Now

                    // can be reused for any strategy vault avoiding specific code, long namespaces, etc..
                    let strat_vault: StrategyVaults =
                        tulipv2_sdk_vaults::into_strategy_vault(&ctx.accounts.vault);
                    let conf = strat_vault.multi_deposit_config();
                    let registration_trait =
                        conf.register_deposit_tracking(*ctx.accounts.authority.key);
    

    Changes

    • Adds a MultiVaultProgramConfig trait which can be used to access the main configuration for a multi deposit vault, which in turn can be used to access configurations for standalone vaults
    • Adds a StandaloneVaultProgramConfig trait which can be used to access configuration for a standalone vault
    • Adds a SolendProgramConfig trait which can be used to access solend configuration used by solend standalone vaults
    • Adds a MangoProgramConfig trait which can be used to access mango configuration used by mango standalone vaults
    • Adds a TulipProgramConfig trait which can be used to access tulip configuration used by tulip standalone vaults
    • Adds a StrategyVaults enum
    • Updates example program to use the newly added traits
    opened by bonedaddy 0
  • Refactor Common Crate

    Refactor Common Crate

    • adds traits for instructions, and accounts for code reusability
    • refactors logic to remove duplicated code
    • adds full support for lending optimizer deposit/withdraw
    • adds fully support deposit tracking registration, shares issuance, and withdrawal
    opened by bonedaddy 0
  • Helper Functions To Add

    Helper Functions To Add

    • parse anchor instruction data for the sighash

    add hex = "0.4.3" to cargo.toml

        pub fn anchor_instruction_data_to_sighash(ix_data: &str) -> Result<[u8; 8]> {
            let ix_data_decoded = match hex::decode(ix_data)?;
            let mut sighash: [u8; 8] = [0_u8; 8];
            for (idx, val) in ix_data_decoded.iter().enumerate() {
                if idx >= 8 {
                    break;
                }
                sighash[idx] = *val;
            }
            Ok(sighash)
        }
    
    opened by bonedaddy 2
  • ℹ️ Localnet Deployment Assets ℹ️

    ℹ️ Localnet Deployment Assets ℹ️

    For running the V2 sdk in a localnet environment you will need to clone a number of different mainnet programs, and modify some of them to bypass checks which fail in localnet environments. This issue contains all the links for programs needed to test against Tulip V2 (and subsequently Tulip Protocol lending, as well as Solend lending and Mango lending)

    Programs

    Each of the links below contains a zipfile containing a directory with the various programs and sha256sum hashes of the programs that need to be deployed to your localnet environment in order to be able to test against Solend, Mango V3, and Tulip Protocol lending programs.

    zip hashes

    23ee5adc2c6f6c8ed180dafee38a81256846cf5220d5c7005abed8603568c61c  tulip_compiled_lending_program_for_localnet_usage.zip
    dd9d814467a0c228e4779ff9d8f1bed6bd3913d3fb3e76ae7bc542fef03d363f  solend_compiled_lending_and_oracle_programs_for_localnet_usage.zip
    5bc2dd506da9dd977cbd205703332c1ad471a046d3b50ad5a5666d54b3b1bee1  mango_compiled_lending_programs_for_localnet_usage.zip
    
    
    opened by bonedaddy 0
Releases(v0.9.22)
  • v0.9.22(Oct 4, 2022)

    Switchboard oracle address changes

    USDC: change from CZx29wKMUxaJDq6aLVQTdViPL754tTR64NAgQBUGxxHb => BjUgj6YCnFBZ49wF54ddBVA9qu8TeqkFtkbqmZcee8uW
    RAY: change from CppyF6264uKZkGua1brTUa2fSVdMFSCszwzDs76HCuzU => 2oALNZVi5czyHvKbnjE4Jf2gR7dNp1FBpEGaq4PzVAf7
    USDT: change from 5mp8kbkTYwWWCsKSte8rURjTuyinsqBpJ9xAQsewPDD => ETAaeeuQBwsh9mC2gCov9WdhJENZuffRMXY2HgjCcSL9
    SOL: change from AdtRGGhmqvom3Jemp5YNrxd9q9unX36BZk1pujkkXijL => GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR
    
    Source code(tar.gz)
    Source code(zip)
  • v0.9.21(Jul 31, 2022)

  • v0.9.20(Jul 22, 2022)

    What's Changed

    • add tag helper functions and address derivation example by @bonedaddy in https://github.com/sol-farm/tulipv2-sdk/pull/29

    Full Changelog: https://github.com/sol-farm/tulipv2-sdk/compare/v0.9.19...v0.9.20

    Source code(tar.gz)
    Source code(zip)
  • v0.9.19(Jul 20, 2022)

    What's Changed

    • add lending reserve deposit and withdraw by @bonedaddy in https://github.com/sol-farm/tulipv2-sdk/pull/20
    • fix: typo Uknown by @katopz in https://github.com/sol-farm/tulipv2-sdk/pull/22
    • fix: comment and doc typo by @katopz in https://github.com/sol-farm/tulipv2-sdk/pull/23
    • fix: typo underlying by @katopz in https://github.com/sol-farm/tulipv2-sdk/pull/24
    • fix: typo by @katopz in https://github.com/sol-farm/tulipv2-sdk/pull/26
    • Add Example Logging Exchange Rate On-Chain by @bonedaddy in https://github.com/sol-farm/tulipv2-sdk/pull/27
    • [WIP] V2 Vaults Integration Examples by @bonedaddy in https://github.com/sol-farm/tulipv2-sdk/pull/25
    • v0.9.19 by @bonedaddy in https://github.com/sol-farm/tulipv2-sdk/pull/28

    New Contributors

    • @katopz made their first contribution in https://github.com/sol-farm/tulipv2-sdk/pull/22

    Full Changelog: https://github.com/sol-farm/tulipv2-sdk/compare/v0.9.17...v0.9.19

    Source code(tar.gz)
    Source code(zip)
  • v0.9.17(Jun 11, 2022)

    What's Changed

    • Fix SDK And Add Example by @bonedaddy in https://github.com/sol-farm/tulipv2-sdk/pull/18

    Full Changelog: https://github.com/sol-farm/tulipv2-sdk/compare/v0.9.10...v0.9.17

    Source code(tar.gz)
    Source code(zip)
  • v0.9.9(Jun 9, 2022)

    What's Changed

    • Add Configs For All V2 Lending Optimizers by @bonedaddy in https://github.com/sol-farm/tulipv2-sdk/pull/15
    • Refactor Common Crate by @bonedaddy in https://github.com/sol-farm/tulipv2-sdk/pull/16

    Full Changelog: https://github.com/sol-farm/tulipv2-sdk/compare/v0.9.8...v0.9.9

    Source code(tar.gz)
    Source code(zip)
  • v0.9.8(Jun 1, 2022)

  • v0.9.7(May 4, 2022)

    What's Changed

    • Add functions to return addresses for strategy ix by @therealssj in https://github.com/sol-farm/tulipv2-sdk/pull/10
    • Compilation Fixes by @bonedaddy in https://github.com/sol-farm/tulipv2-sdk/pull/11
    • Apply Formatting/Linting by @bonedaddy in https://github.com/sol-farm/tulipv2-sdk/pull/12
    • Bump All Crates To v0.9.7 by @bonedaddy in https://github.com/sol-farm/tulipv2-sdk/pull/13
    Source code(tar.gz)
    Source code(zip)
  • v0.9.6(May 4, 2022)

    • Adds the ability to read v1 leveraged farm information using the accessor method made popular by anchor_spl. This is an inherently unsafe function that must be used with caution.
    • Updates the required anchor version to 0.24.2
    Source code(tar.gz)
    Source code(zip)
  • v0.9.2(Mar 12, 2022)

  • v0.9.1(Mar 12, 2022)

  • v0.9.0(Mar 2, 2022)

    • supports deposit tracking account registration
    • supports share issuance
    • supports deposit tracking withdrawals
    • supports lending optimizer (multi deposit vault) share burning
    Source code(tar.gz)
    Source code(zip)
Owner
Tulip Protocol
The Efficient Solana Yield Aggregator
Tulip Protocol
Examples and helpers to build NFT contracts on CosmWasm

CosmWasm NFTS This repo is the official repository to work on all NFT standard and examples in the CosmWasm ecosystem. cw721 and cw721-base were moved

CosmWasm 147 Jan 4, 2023
CosmWasm-Examples is a collection of example contracts and applications built using the CosmWasm framework

CosmWasm-Examples is a collection of example contracts and applications built using the CosmWasm framework. CosmWasm is a secure and efficient smart contract platform designed specifically for the Cosmos ecosystem.

Vitalii Tsyhulov 20 Jun 9, 2023
Examples of Solana on-chain programs

spl-examples List of Solana on-chain programs which demonstrate different aspects of Solana architecture. 01__state It's a counter program. Each user

Max Block 51 Dec 6, 2022
Examples of cw20 usage, extracted from cw-plus, maintained by the community

CosmWasm Tokens This is a collection of cw20-related contracts extracted from cw-plus. These serve as examples of what is possible to build and as sta

CosmWasm 59 Jan 2, 2023
Helper library for interacting with Terra assets (SDK coins and CW20 tokens)

terra-asset Helpers for interacting with Terra assets, including native coins and CW20 tokens Usage This crate contains two struct types: AssetInfo st

larry 9 Jan 3, 2022
Kryptokrona SDK in Rust for building decentralized private communication and payment systems.

Kryptokrona Rust SDK Kryptokrona is a decentralized blockchain from the Nordic based on CryptoNote, which forms the basis for Monero, among others. Cr

null 5 May 25, 2023
A library facilitating the signing and broadcasting of transactions on Cosmos SDK-based blockchains

txf Transaction factory - a library facilitating the signing and broadcasting of transactions (txs) on Cosmos SDK-based blockchains. How to use Exampl

larry 5 Jun 29, 2023
A Software Development Kit (SDK) for Zero-Knowledge Transactions

Aleo SDK The Aleo SDK is a developer framework to make it simple to create a new account, craft a transaction, and broadcast it to the network. Table

Aleo 270 Jan 5, 2023
A Minimal Windows SDK.

Minimal Windows 10 SDK Installs only the necessary Windows 10 .lib files to save you having to download the full Visual Studio package. You can either

null 58 Dec 18, 2022
flow-rust-sdk utilizes the Flow gRPC AccessAPI to make requests on the flow blockchain.

Welcome to the Flow-Rust-SDK! We're glad to have you here. There are a few important items that we should cover real quick before you dive in. Version

null 8 Jul 26, 2022
Pokémon TCG SDK - Rust

Pokémon TCG SDK - Rust This is the Pokémon TCG SDK Rust implementation. It is a wrapper around the Pokémon TCG API of pokemontcg.io. Usage Configurati

Pokémon TCG Developers 2 Dec 14, 2022
Rustcoin - A LightWeight SDK For Bitcoin, Ethernum

Rustcoin - A LightWeight SDK For Bitcoin, Ethernum

Rust Coin 6 Jan 24, 2022
A template to build smart contracts in Rust to run inside a Cosmos SDK module on all chains that enable it.

CosmWasm Starter Pack This is a template to build smart contracts in Rust to run inside a Cosmos SDK module on all chains that enable it. To understan

null 1 Mar 7, 2022
Smart Contract built in Rust to run inside Cosmos SDK module on all chains that enable it

CoinSwap is a Smart Contract that is built on the terra blockchain and can be used to swap cryptocurrencies such as LUNA, UST, TerraUSD, Anchor, Mirror Protocol, LUNI and other CW20 tokens. The Project also contains a smart contract which works as a analysis tool for the gas fees on the Terra Blockchain.

Prajjwal Chittori 9 Oct 11, 2022
Lazerpay SDK for Rust 🦀

?? Lazerpay Rust SDK This crate integrates the Lazerpay payment gateway for accepting cryptocurrency payments. Usage Add the following to your cargo d

Lord_Sarcastic 15 Sep 21, 2022
Longbridge OpenAPI SDK Base.

Longbridge OpenAPI SDK Longbridge OpenAPI provides programmatic quote trading interfaces for investors with research and development capabilities and

Longbridge 18 Nov 30, 2022
This crate reimplements Gelato's Relay SDK in Rust

Gelato Relay SDK This crate reimplements Gelato's Relay SDK in Rust. It simply wraps Gelato Relay requests and responses to/from Gelato endpoints with

Nomad 30 Oct 20, 2022
Open-Source Gamestreaming SDK

RhinoStream SDK OpenSource AppStream SDK aims to be (or GameStream) equivalent of FFMpeg or GStreamer aimed for use by developers. Stats for 2560x1440

null 4 Nov 22, 2022
A universal SDK for FDU. Powered by Rust.

libfdu A universal SDK for FDU. Building You need Rust Nightly installed: $ rustup default nightly Build the library by running: $ cargo build or $ ca

旦夕开发组 6 Sep 11, 2022