-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from ThalaLabs/thalasdk-monorepo
create thala-sdk monorepo
- Loading branch information
Showing
53 changed files
with
13,860 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@thalalabs/thalaswap-math": major | ||
--- | ||
|
||
Update Readme & move some files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,133 @@ | ||
node_modules | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
.env | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
.DS_Store | ||
.turbo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
bun lint-staged | ||
npx lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# thala-sdk | ||
|
||
- [@thalalabs/thalaswap-math](./packages/thalaswap-math/) | ||
- [@thalalabs/router-sdk](./packages/thalaswap-router/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,33 @@ | ||
{ | ||
"name": "@thalalabs/router-sdk", | ||
"version": "2.1.0", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"sideEffects": false, | ||
"name": "thala-sdk", | ||
"version": "0.0.0", | ||
"private": true, | ||
"workspaces": [ | ||
"packages/*" | ||
], | ||
"main": "index.js", | ||
"scripts": { | ||
"typecheck": "bun run tsc --noEmit", | ||
"build": "bun run tsup ./src/index.ts --dts", | ||
"prepare": "husky", | ||
"typecheck": "turbo typecheck", | ||
"build": "turbo typecheck build", | ||
"test": "turbo typecheck test", | ||
"format": "prettier . --write", | ||
"release": "bun run build && changeset publish", | ||
"prepare": "husky install" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ThalaLabs/thala-router.git" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"devDependencies": { | ||
"@changesets/cli": "^2.26.2", | ||
"@typescript-eslint/eslint-plugin": "^6.10.0", | ||
"@typescript-eslint/parser": "^6.10.0", | ||
"bun-plugin-dts": "^0.2.1", | ||
"bun-types": "^1.0.7", | ||
"eslint": "^8.53.0", | ||
"husky": "^9.0.10", | ||
"lint-staged": "^15.0.2", | ||
"prettier": "3.2.5", | ||
"tsup": "^8.0.2", | ||
"typescript": "^5.2.2", | ||
"@aptos-labs/ts-sdk": "^1.11.0", | ||
"@thalalabs/surf": "^1.3.1", | ||
"@types/lodash": "^4.17.0" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"bignumber.js": "^9.1.2", | ||
"lodash": "^4.17.21" | ||
}, | ||
"peerDependencies": { | ||
"@aptos-labs/ts-sdk": "^1.11.0", | ||
"@thalalabs/surf": "^1.3.1" | ||
"all": "turbo build typecheck test", | ||
"release": "pnpm run all && changeset publish" | ||
}, | ||
"lint-staged": { | ||
"*.{js,jsx,ts,tsx}": [ | ||
"eslint --fix", | ||
"pnpm -r run eslint --fix", | ||
"prettier --write" | ||
], | ||
"*.json": "prettier --write" | ||
} | ||
}, | ||
"devDependencies": { | ||
"@changesets/cli": "^2.27.1", | ||
"husky": "^9.0.11", | ||
"lint-staged": "^15.2.2", | ||
"prettier": "^3.2.5", | ||
"turbo": "^1.13.3" | ||
}, | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# thalaswap-math | ||
|
||
## 1.0.0 | ||
|
||
### Major Changes | ||
|
||
- 9a602ba: Create initial version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Thala Labs | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# thalaswap-math | ||
|
||
SDK to calculate swap amounts and pool price. | ||
|
||
# install | ||
|
||
``` | ||
$ npm i @thalalabs/thalaswap-math | ||
``` | ||
|
||
# example | ||
|
||
```typescript | ||
import { | ||
calcInGivenOutStable, | ||
calcInGivenOutWeighted, | ||
calcOutGivenInStable, | ||
calcOutGivenInWeighted, | ||
} from "@thalalabs/thalaswap-math"; | ||
|
||
// Calculate amount out given amount in: | ||
// A stable pool with three tokens having balances of [100, 200, 300], | ||
// The pool's amplification coefficient is 1. | ||
// And the swap fee is 0.01. | ||
// We use the second token as input and the third token as output. | ||
// And the input token amount is 10. | ||
console.log(calcOutGivenInStable(10, 1, 2, [100, 200, 300], 1, 0.01)); | ||
|
||
// Calculate amount in given amount out: | ||
// A stable pool with three tokens having balances of [100, 200, 300], | ||
// The pool's amplification coefficient is 1. | ||
// And the swap fee is 0.01. | ||
// We use the second token as input and the third token as output. | ||
// And the output token amount is 10. | ||
console.log(calcInGivenOutStable(10, 1, 2, [100, 200, 300], 1, 0.01)); | ||
|
||
// Calculate amount out given amount in: | ||
// A weighted pool has a token whose balance is 100 and weight is 20, | ||
// and the pool also has another token whose balance is 200 and weight is 30. | ||
// The swap fee is 0.01. | ||
// Use the first token as input and the second token as output. | ||
// And the input token amount is 10. | ||
console.log(calcOutGivenInWeighted(100, 20, 200, 30, 10, 0.01)); | ||
|
||
// Calculate amount out given amount out: | ||
// A weighted pool has a token whose balance is 100 and weight is 20, | ||
// and the pool also has another token whose balance is 200 and weight is 30. | ||
// The swap fee is 0.01. | ||
// Use the first token as input and the second token as output. | ||
// And the output token amount is 10. | ||
console.log(calcInGivenOutWeighted(100, 20, 200, 30, 10, 0.01)); | ||
``` |
Oops, something went wrong.