npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

orai-combinator-bsc-sdk

v1.0.1

Published

- [Table of contents](#table-of-contents) - [TRAVA STATION SDK](#trava-station-sdk) - [Utilities](#utilities) - [Pull token](#pull-token) - [Send token](#send-token) - [Wrap token](#wrap-token) - [Unwrap token](#unwrap-token) - [Swap

Downloads

5

Readme

Table of contents

TRAVA STATION SDK

import {actions} from "trava-station-sdk"

Với các actions:

Utilities

Pull token

const pull_token_action = new actions.basic.PullTokenAction(
    token: String,
    from: String,
    amount: uint256
)

Send token

const send_token_action = new actions.basic.SendTokenAction(
    token: String,
    to: String,
    amount: uint256
)

Wrap token

const pull_token_action = new actions.basic.PullTokenAction()
const wrap_token_action = new actions.basic.WrapBnbAction(
    amount: uint256
)

Unwrap token

const unwrap_token_action = new actions.basic.UnwrapBnbAction(
    amount: uin256,
    to: String
)

Pancake

Swap

const swapUtil = new SwapUtil(web3);
const info = new await swapUtil.getInformationFromInput(tokenAddr1, tokenAddr2, slipparage, amount);
const minimumReceive = info.minimumReceive
const priceImpact = info.priceImpact;
const path = info.path;
const swap_token_action = new actions.pancakeswap.PancakeSwapV2(
    amountIn: uint256,
    amountOutMin: 0,
    path: path,
    to: _to address,
    deadline: timestamp + 30 * 60 * 1000
    from: _from address
)

Orai Liquid Staking

Stake

const orai_ls_stake_action = new actions.OraiLiquidStakingStakeAction(
    amount, 
    from,
    contract address
)

Unstake

const orai_ls_unstake_action = new actions.OraiLiquidStakingUnstakeAction(
    amount,
    from
)

WithdrawUnstake

const orai_ls_withdraw_unstake_action = new actions.OraiLiquidStakingWithdrawUnstakedAction(
    to
)

Execute actions

Sau khi có được các action xong, để execute Freight giả sử kết hợp action supply và borrow, repay và withdraw

import {Recipe} from "trava-station-sdk";

const recipe = new Recipe(
    "ten action = address user + timestamp",
    [
        swap_token_action,
        orai_ls_stake_action,
        orai_ls_unstake_action,
        send_token_action
    ]
)

const encoded = recipe.encodeForDsProxyCall();

//sau đó dùng contract Proxy để execute (abi e để dưới), address của contract này là proxy của người dùng
let tx;
if(co action su dung BNB nhu wrap) {
    tx = await proxyCOntract.execute(encoded[0], encoded[1], {value: total amountBNB});

} else {
    tx = await proxyContract.execute(encoded[0], encoded[1])
}

await tx.wait();

ABI IDSProxy Contract

[
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_target",
          "type": "address"
        },
        {
          "internalType": "bytes",
          "name": "_data",
          "type": "bytes"
        }
      ],
      "name": "execute",
      "outputs": [
        {
          "internalType": "bytes",
          "name": "",
          "type": "bytes"
        }
      ],
      "stateMutability": "payable",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "owner",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_cacheAddr",
          "type": "address"
        }
      ],
      "name": "setCache",
      "outputs": [
        {
          "internalType": "bool",
          "name": "",
          "type": "bool"
        }
      ],
      "stateMutability": "payable",
      "type": "function"
    }
  ]

Approve token

Approve BEP20 token

ABI contract BEP20 token

[ { "anonymous": false, "inputs": [ { "indexed": true, "internalType": "address", "name": "_owner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "_spender", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "_value", "type": "uint256" } ], "name": "Approval", "type": "event" }, { "inputs": [ { "internalType": "address", "name": "_owner", "type": "address" }, { "internalType": "address", "name": "_spender", "type": "address" } ], "name": "allowance", "outputs": [ { "internalType": "uint256", "name": "remaining", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "_spender", "type": "address" }, { "internalType": "uint256", "name": "_value", "type": "uint256" } ], "name": "approve", "outputs": [ { "internalType": "bool", "name": "success", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "_owner", "type": "address" } ], "name": "balanceOf", "outputs": [ { "internalType": "uint256", "name": "balance", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "decimals", "outputs": [ { "internalType": "uint256", "name": "digits", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "name", "outputs": [ { "internalType": "string", "name": "", "type": "string" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "symbol", "outputs": [ { "internalType": "string", "name": "", "type": "string" } ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "totalSupply", "outputs": [ { "internalType": "uint256", "name": "supply", "type": "uint256" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "_to", "type": "address" }, { "internalType": "uint256", "name": "_value", "type": "uint256" } ], "name": "transfer", "outputs": [ { "internalType": "bool", "name": "success", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "_from", "type": "address" }, { "internalType": "address", "name": "_to", "type": "address" }, { "internalType": "uint256", "name": "_value", "type": "uint256" } ], "name": "transferFrom", "outputs": [ { "internalType": "bool", "name": "success", "type": "bool" } ], "stateMutability": "nonpayable", "type": "function" } ]

Cách approve token

gọi hàm approve trong abi ERC20 token tham số truyền vào là:

  • address token
  • lượng amount cần approve

Approve token trong các Action

Cách approve

  • Trừ đồng BNB, các đồng token khác cần approve
  • Contract gọi hàm approve trong abi là address BEP20 token
  • 2 tham số trong approve là:
    • tham số đầu tiên là address _to
    • tham số thứ 2 là amount đang dùng
  • tham số đầu tiên của approve luôn là smartWallet
  • Chỉ khi from là wallet mới cần approve, from là smart wallet thì không cần

Các actions cần approve

Pull token: approve token cần pull

Swap token: approve token cần swap

Orai LS Stake: approve orai token

publish orchai-combinator-bsc-sdk to npm

go to file tsconfig.json, if module != "ESNext", change module to "ESNext"

delete two folder /esm /umd if they exist

run

npm run build

after build, to publish repo on npm, change version repo in package.json (can't publish a repo have same version with repo existing on npm), if you use repo for test, please add "testnet" before each version and increase version after each time publish

if you don't login npm, please create account npm on website https://www.npmjs.com/, then login npm in terminal by running command

npm login

after you login success, you can publish repo on npm by following command

npm publish