-
Notifications
You must be signed in to change notification settings - Fork 10
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 #331 from oraichain/feat/zapper-2
Feat/zapper 2
- Loading branch information
Showing
27 changed files
with
1,743 additions
and
155 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# name: publish_package_oraiswap_v3 | ||
|
||
# # Controls when the action will run. | ||
# on: | ||
# # Triggers the workflow on push or pull request events but only for the main branch | ||
# push: | ||
# branches: [feat/zapper-2] | ||
|
||
# # Allows you to run this workflow manually from the Actions tab | ||
# workflow_dispatch: | ||
|
||
# # A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
# jobs: | ||
# build: | ||
# runs-on: ubuntu-20.04 | ||
# strategy: | ||
# matrix: | ||
# node-version: ["18"] | ||
# steps: | ||
# - name: Cancel Previous Runs | ||
# uses: styfle/[email protected] | ||
# with: | ||
# access_token: ${{ github.token }} | ||
# - uses: actions/checkout@v2 | ||
# - name: Use Node.js ${{ matrix.node-version }} | ||
# uses: actions/setup-node@v2 | ||
# with: | ||
# node-version: ${{ matrix.node-version }} | ||
# - name: Get yarn cache directory path | ||
# id: yarn-cache-dir-path | ||
# run: echo "::set-output name=dir::$(yarn cache dir)" | ||
# - uses: actions/cache@v4 | ||
# id: yarn-cache | ||
# with: | ||
# path: | | ||
# ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
# ./node_modules/ | ||
# key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }} | ||
# restore-keys: | | ||
# ${{ runner.os }}-yarn- | ||
# - name: Install Dependencies | ||
# run: yarn | ||
# - name: Build | ||
# run: yarn build | ||
# - name: Authenticate with private NPM package | ||
# run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | ||
# - name: Publish Oraiswap v3 | ||
# id: publish-oraiswap-v3 | ||
# continue-on-error: true | ||
# run: yarn deploy:beta packages/oraiswap-v3 | ||
# env: | ||
# CI: false | ||
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
# - name: Publish Contract SDK | ||
# id: publish-oraidex-contracts-sdk | ||
# continue-on-error: true | ||
# run: yarn deploy:beta packages/contracts-sdk | ||
# env: | ||
# CI: false | ||
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
# - name: Publish Contract Build | ||
# id: publish-oraidex-contracts-build | ||
# continue-on-error: true | ||
# run: yarn deploy:beta packages/contracts-build | ||
# env: | ||
# CI: false | ||
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
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 |
---|---|---|
|
@@ -35,4 +35,7 @@ cache/ | |
packages/contract-state-simulate/public/ | ||
coverage | ||
|
||
.nx/cache | ||
.nx/cache | ||
.nx/workspace-data | ||
|
||
.yarn |
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 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
yarn-path ".yarn/releases/yarn-1.22.22.cjs" |
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
Binary file not shown.
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
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,166 @@ | ||
/** | ||
* This file was automatically generated by @oraichain/[email protected]. | ||
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, | ||
* and run the @oraichain/ts-codegen generate command to regenerate this file. | ||
*/ | ||
|
||
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate"; | ||
import { Coin, StdFee } from "@cosmjs/amino"; | ||
import {Addr, InstantiateMsg, ExecuteMsg, Uint128, AssetInfo, Liquidity, Percentage, SwapOperation, AssetInfo2, Decimal, Asset, PoolKey, FeeTier, Route, QueryMsg, MigrateMsg, Config, ProtocolFee} from "./Zapper.types"; | ||
export interface ZapperReadOnlyInterface { | ||
contractAddress: string; | ||
config: () => Promise<Config>; | ||
protocolFee: () => Promise<ProtocolFee>; | ||
} | ||
export class ZapperQueryClient implements ZapperReadOnlyInterface { | ||
client: CosmWasmClient; | ||
contractAddress: string; | ||
|
||
constructor(client: CosmWasmClient, contractAddress: string) { | ||
this.client = client; | ||
this.contractAddress = contractAddress; | ||
this.config = this.config.bind(this); | ||
this.protocolFee = this.protocolFee.bind(this); | ||
} | ||
|
||
config = async (): Promise<Config> => { | ||
return this.client.queryContractSmart(this.contractAddress, { | ||
config: {} | ||
}); | ||
}; | ||
protocolFee = async (): Promise<ProtocolFee> => { | ||
return this.client.queryContractSmart(this.contractAddress, { | ||
protocol_fee: {} | ||
}); | ||
}; | ||
} | ||
export interface ZapperInterface extends ZapperReadOnlyInterface { | ||
contractAddress: string; | ||
sender: string; | ||
updateConfig: ({ | ||
admin, | ||
dexV3, | ||
mixedRouter | ||
}: { | ||
admin?: Addr; | ||
dexV3?: Addr; | ||
mixedRouter?: Addr; | ||
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>; | ||
zapInLiquidity: ({ | ||
assetIn, | ||
minimumLiquidity, | ||
poolKey, | ||
routes, | ||
tickLowerIndex, | ||
tickUpperIndex | ||
}: { | ||
assetIn: Asset; | ||
minimumLiquidity?: Liquidity; | ||
poolKey: PoolKey; | ||
routes: Route[]; | ||
tickLowerIndex: number; | ||
tickUpperIndex: number; | ||
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>; | ||
zapOutLiquidity: ({ | ||
positionIndex, | ||
routes | ||
}: { | ||
positionIndex: number; | ||
routes: Route[]; | ||
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>; | ||
registerProtocolFee: ({ | ||
feeReceiver, | ||
percent | ||
}: { | ||
feeReceiver: Addr; | ||
percent: Decimal; | ||
}, _fee?: number | StdFee | "auto", _memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>; | ||
} | ||
export class ZapperClient extends ZapperQueryClient implements ZapperInterface { | ||
client: SigningCosmWasmClient; | ||
sender: string; | ||
contractAddress: string; | ||
|
||
constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) { | ||
super(client, contractAddress); | ||
this.client = client; | ||
this.sender = sender; | ||
this.contractAddress = contractAddress; | ||
this.updateConfig = this.updateConfig.bind(this); | ||
this.zapInLiquidity = this.zapInLiquidity.bind(this); | ||
this.zapOutLiquidity = this.zapOutLiquidity.bind(this); | ||
this.registerProtocolFee = this.registerProtocolFee.bind(this); | ||
} | ||
|
||
updateConfig = async ({ | ||
admin, | ||
dexV3, | ||
mixedRouter | ||
}: { | ||
admin?: Addr; | ||
dexV3?: Addr; | ||
mixedRouter?: Addr; | ||
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => { | ||
return await this.client.execute(this.sender, this.contractAddress, { | ||
update_config: { | ||
admin, | ||
dex_v3: dexV3, | ||
mixed_router: mixedRouter | ||
} | ||
}, _fee, _memo, _funds); | ||
}; | ||
zapInLiquidity = async ({ | ||
assetIn, | ||
minimumLiquidity, | ||
poolKey, | ||
routes, | ||
tickLowerIndex, | ||
tickUpperIndex | ||
}: { | ||
assetIn: Asset; | ||
minimumLiquidity?: Liquidity; | ||
poolKey: PoolKey; | ||
routes: Route[]; | ||
tickLowerIndex: number; | ||
tickUpperIndex: number; | ||
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => { | ||
return await this.client.execute(this.sender, this.contractAddress, { | ||
zap_in_liquidity: { | ||
asset_in: assetIn, | ||
minimum_liquidity: minimumLiquidity, | ||
pool_key: poolKey, | ||
routes, | ||
tick_lower_index: tickLowerIndex, | ||
tick_upper_index: tickUpperIndex | ||
} | ||
}, _fee, _memo, _funds); | ||
}; | ||
zapOutLiquidity = async ({ | ||
positionIndex, | ||
routes | ||
}: { | ||
positionIndex: number; | ||
routes: Route[]; | ||
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => { | ||
return await this.client.execute(this.sender, this.contractAddress, { | ||
zap_out_liquidity: { | ||
position_index: positionIndex, | ||
routes | ||
} | ||
}, _fee, _memo, _funds); | ||
}; | ||
registerProtocolFee = async ({ | ||
feeReceiver, | ||
percent | ||
}: { | ||
feeReceiver: Addr; | ||
percent: Decimal; | ||
}, _fee: number | StdFee | "auto" = "auto", _memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => { | ||
return await this.client.execute(this.sender, this.contractAddress, { | ||
register_protocol_fee: { | ||
fee_receiver: feeReceiver, | ||
percent | ||
} | ||
}, _fee, _memo, _funds); | ||
}; | ||
} |
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,99 @@ | ||
export type Addr = string; | ||
export interface InstantiateMsg { | ||
admin: Addr; | ||
dex_v3: Addr; | ||
mixed_router: Addr; | ||
} | ||
export type ExecuteMsg = { | ||
update_config: { | ||
admin?: Addr | null; | ||
dex_v3?: Addr | null; | ||
mixed_router?: Addr | null; | ||
}; | ||
} | { | ||
zap_in_liquidity: { | ||
asset_in: Asset; | ||
minimum_liquidity?: Liquidity | null; | ||
pool_key: PoolKey; | ||
routes: Route[]; | ||
tick_lower_index: number; | ||
tick_upper_index: number; | ||
}; | ||
} | { | ||
zap_out_liquidity: { | ||
position_index: number; | ||
routes: Route[]; | ||
}; | ||
} | { | ||
register_protocol_fee: { | ||
fee_receiver: Addr; | ||
percent: Decimal; | ||
}; | ||
}; | ||
export type Uint128 = string; | ||
export type AssetInfo = { | ||
token: { | ||
contract_addr: Addr; | ||
}; | ||
} | { | ||
native_token: { | ||
denom: string; | ||
}; | ||
}; | ||
export type Liquidity = string; | ||
export type Percentage = number; | ||
export type SwapOperation = { | ||
orai_swap: { | ||
ask_asset_info: AssetInfo2; | ||
offer_asset_info: AssetInfo2; | ||
}; | ||
} | { | ||
swap_v3: { | ||
pool_key: PoolKey; | ||
x_to_y: boolean; | ||
}; | ||
}; | ||
export type AssetInfo2 = { | ||
token: { | ||
contract_addr: Addr; | ||
}; | ||
} | { | ||
native_token: { | ||
denom: string; | ||
}; | ||
}; | ||
export type Decimal = string; | ||
export interface Asset { | ||
amount: Uint128; | ||
info: AssetInfo; | ||
} | ||
export interface PoolKey { | ||
fee_tier: FeeTier; | ||
token_x: string; | ||
token_y: string; | ||
} | ||
export interface FeeTier { | ||
fee: Percentage; | ||
tick_spacing: number; | ||
} | ||
export interface Route { | ||
minimum_receive?: Uint128 | null; | ||
offer_amount: Uint128; | ||
operations: SwapOperation[]; | ||
token_in: string; | ||
} | ||
export type QueryMsg = { | ||
config: {}; | ||
} | { | ||
protocol_fee: {}; | ||
}; | ||
export interface MigrateMsg {} | ||
export interface Config { | ||
admin: Addr; | ||
dex_v3: Addr; | ||
mixed_router: Addr; | ||
} | ||
export interface ProtocolFee { | ||
fee_receiver: Addr; | ||
percent: Decimal; | ||
} |
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
Oops, something went wrong.