-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/zapper 2 #331
Feat/zapper 2 #331
Changes from all commits
342e78c
85dfe38
a3410b6
c68db19
fe3cdb7
1fe8372
56299f3
02bcbee
f331f44
5091880
85f3045
e2a2b2e
aaf67b1
acb3c9b
c634d10
31b2306
c693a52
bcb2d05
68d1e1a
dfbcde6
f38d717
5882001
197d6af
2494759
cf902d3
db0a16e
9421414
e9a483a
450c8e5
6949d28
dc6ad07
8e134db
7b93d0a
a1180c4
62e2544
537d17c
884a589
43d05c3
5a6eda5
0f333ea
84be2d8
68af563
e61170b
6b9eca2
4c074d5
a1f92e2
677c539
9f8e476
d435cb0
ad9674d
83f0435
a2ce6fd
b7e26be
cf19d58
bb5a66e
4339361
07aba3a
b041c5f
f626938
06f9e17
38ddddc
f876dd5
8eb7267
26af1bb
e2803b4
4b10b58
78f7a1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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/cancel-workflow-action@0.8.0 | ||
# 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 }} |
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 |
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" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
/** | ||
* This file was automatically generated by @oraichain/ts-codegen@0.35.9. | ||
* 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); | ||
}; | ||
} |
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 {} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a type alias instead of an empty interface. An empty interface is equivalent to For example: -export interface MigrateMsg {}
+export type MigrateMsg = Record<string, never>; Committable suggestion
Suggested change
ToolsBiome
|
||||||
export interface Config { | ||||||
admin: Addr; | ||||||
dex_v3: Addr; | ||||||
mixed_router: Addr; | ||||||
} | ||||||
export interface ProtocolFee { | ||||||
fee_receiver: Addr; | ||||||
percent: Decimal; | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the type definition to explicitly define the shape of the query messages.
Using
{}
as a type is not recommended because it means "any non-nullable value" and does not provide type safety. Consider updating the type definition to explicitly define the shape of the query messages.For example:
Tools
Biome