LogoLogo
  • Welcome!
  • The Protocol
    • Overview
    • Stakeholders
    • SecretTokens
    • Viewing Keys
    • Bridges
    • SEFI Token
    • CSHBK Token
    • Governance
  • User Guide
    • Swapping
    • Liquidity Providing
    • Tutorials
      • How to Buy SCRT in the U.S. Tutorial - Coinbase and Osmosis
      • Secret Ethereum Bridge (Video Tutorial)
      • Secret BSC Bridge (Video Tutorial)
      • Secret Monero Bridge (Video Tutorial) (1 of 4)
      • Secret Monero Bridge (Written Tutorial)
      • SecretSwap Full Length (Video Tutorial)
      • Trade & Earn Yield on SecretSwap (Written Tutorial)
      • Provide Liquidity on SecretSwap (Written Tutorial)
      • SEFI Governance (Written Tutorial)
    • Frequently Asked Questions
    • Glossary
  • Developer Guide
    • Create a New Pair
    • Factory
    • Query
    • Pair
  • Resources
    • Contract Addresses
Powered by GitBook
On this page
  • Transaction
  • Provide liquidity
  • Swap
  • Query
  • Pool
  • Simulation
  • Reverse Simulation
  1. Developer Guide

Pair

Transaction

Provide liquidity

Send user's assets to SecretSwap contract and provide liquidity.

Assets can be both SNIP20 and native tokens. It can be distinguished with the key under info.token or info.native_token.

{
  "provide_liquidity": {
    "assets": [
      {
        "info": {
          "token": {
            "contract_addr": "<HumanAddr>",
            "token_code_hash": "<HASH>",
            "viewing_key": "" // empty
          }
        },
        "amount": "10"
      },
      {
        "info": {
          "native_token": {
            "denom": "uscrt"
          }
        },
        "amount": "10"
      }
    ],
    "slippage_tolerance": 0.1 // optinonal
  }
}

For SNIP20 assets, you first have to set an allowance for the pair to spend the token.

For SCRT, you have to send the SCRT amount to the provide_liquidity contract call.

Swap

Swap between the given two tokens. offer_asset is your source asset and to is your destination token contract.

{
  "swap": {
    "offer_asset": {
      "info": {
        "native_token": {
          "denom": "uluna"
        }
      },
      "amount": "10"
    },
    "expected_return": "13", // optional
    "belief_price": 0.1, // optional
    "max_spread": 0.1, // optional
    "to": "<HumanAddr>" // optional
  }
}
{
  "swap": {
    "offer_asset": {
      "info": {
        "token": {
          "contract_addr": "<HumanAddr>",
          "token_code_hash": "<HASH>",
          "viewing_key": "" // empty
        }
      },
      "amount": "10"
    },
    "expected_return": "13", // optional
    "belief_price": 0.1, // optional
    "max_spread": 0.1, // optional
    "to": "<HumanAddr>" // optional
  }
}

Query

Pool

{
  "pool": {}
}

Simulation

{
  "simulation": {
    "offer_asset": {
      "info": {
        "token": {
          "contract_addr": "<HumanAddr>",
          "token_code_hash": "<HASH>",
          "viewing_key": "" // empty
        }
      },
      "amount": "10"
    }
  }
}

Reverse Simulation

{
  "reverse_simulation": {
    "ask_asset": {
      "info": {
        "token": {
          "contract_addr": "<HumanAddr>",
          "token_code_hash": "<HASH>",
          "viewing_key": "" // empty
        }
      },
      "amount": "10"
    }
  }
}
PreviousQueryNextContract Addresses

Last updated 3 years ago