Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0n00gler committed Apr 2, 2024
1 parent 4d8bf19 commit 9ac8f50
Show file tree
Hide file tree
Showing 24 changed files with 2,394 additions and 190 deletions.
101 changes: 93 additions & 8 deletions lib/astroportOracle.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult, InstantiateResult } from "@cosmjs/cosmwasm-stargate";
import { StdFee } from "@cosmjs/amino";
import { Coin } from "@cosmjs/amino";
/**
Expand All @@ -23,6 +23,18 @@ export type AssetInfo = {
* This type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.
*/
export type Addr = string;
/**
* This enum describes available pair types. ## Available pool types ``` # use astroport::factory::PairType::{Custom, Stable, Xyk}; Xyk {}; Stable {}; Custom(String::from("Custom")); ```
*/
export type PairType = {
xyk: {};
} | {
stable: {};
} | {
concentrated: {};
} | {
custom: string;
};
/**
* An implementation of u256 that is using strings for JSON encoding/decoding, such that the full u256 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.
*
Expand All @@ -33,14 +45,15 @@ export type Addr = string;
* ``` # use cosmwasm_std::Uint256; let a = Uint256::from(258u128); let b = Uint256::new([ 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 2u8, ]); assert_eq!(a, b); ```
*/
export type Uint256 = string;
export type TupleOf_AssetInfoAnd_Uint256 = [AssetInfo, Uint256][];
export type ArrayOfTupleOf_AssetInfoAnd_Uint256 = [AssetInfo, Uint256][];
export type Uint64 = number;
/**
* A fixed-point decimal value with 18 fractional digits, i.e. Decimal256(1_000_000_000_000_000_000) == 1.0
*
* The greatest possible value that can be represented is 115792089237316195423570985008687907853269984665640564039457.584007913129639935 (which is (2^256 - 1) / 10^18)
*/
export type Decimal256 = string;
export type TupleOf_AssetInfoAnd_Decimal256 = [AssetInfo, Decimal256][];
export type ArrayOfTupleOf_AssetInfoAnd_Decimal256 = [AssetInfo, Decimal256][];
/**
* A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.
*
Expand All @@ -66,13 +79,64 @@ export type Uint128 = string;
*
* let b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```
*/
export type Uint64 = string;
export type Uint641 = string;
export interface AstroportOracleSchema {
responses: TupleOf_AssetInfoAnd_Uint256 | TupleOf_AssetInfoAnd_Decimal256;
responses: Config | ArrayOfTupleOf_AssetInfoAnd_Uint256 | Uint64 | ArrayOfTupleOf_AssetInfoAnd_Decimal256;
query: ConsultArgs | TWAPAtHeightArgs;
execute: UpdatePeriodArgs | UpdateManagerArgs;
instantiate?: InstantiateMsg;
[k: string]: unknown;
}
/**
* Global configuration for the contract
*/
export interface Config {
/**
* The assets in the pool. Each asset is described using a [`AssetInfo`]
*/
asset_infos?: AssetInfo[] | null;
/**
* The factory contract address
*/
factory: Addr;
/**
* Manager is the only one who can set pair info, if not set already
*/
manager: Addr;
/**
* The address that's allowed to change contract parameters
*/
owner: Addr;
/**
* Information about the pair (LP token address, pair type etc)
*/
pair?: PairInfo | null;
/**
* Time between two consecutive TWAP updates.
*/
period: number;
}
/**
* This structure stores the main parameters for an Astroport pair
*/
export interface PairInfo {
/**
* Asset information for the assets in the pool
*/
asset_infos: AssetInfo[];
/**
* Pair contract address
*/
contract_addr: Addr;
/**
* Pair LP token address
*/
liquidity_token: Addr;
/**
* The pool type (xyk, stableswap etc) available in [`PairType`]
*/
pair_type: PairType;
}
export interface ConsultArgs {
/**
* The amount of tokens for which to compute the token price
Expand All @@ -87,7 +151,7 @@ export interface TWAPAtHeightArgs {
/**
* The amount of tokens for which to compute the token price
*/
height: Uint64;
height: Uint641;
/**
* The asset for which to compute a new TWAP value
*/
Expand All @@ -99,13 +163,34 @@ export interface UpdatePeriodArgs {
export interface UpdateManagerArgs {
new_manager: string;
}
/**
* This structure stores general parameters for the contract. Modified by us
*/
export interface InstantiateMsg {
/**
* The factory contract address
*/
factory_contract: string;
/**
* Manager is the only one who can set pair info, if not set already
*/
manager: string;
/**
* Minimal interval between Update{}'s
*/
period: number;
}
export declare class Client {
private readonly client;
contractAddress: string;
constructor(client: CosmWasmClient | SigningCosmWasmClient, contractAddress: string);
mustBeSigningClient(): Error;
queryConsult: (args: ConsultArgs) => Promise<TupleOf_AssetInfoAnd_Uint256[]>;
queryTWAPAtHeight: (args: TWAPAtHeightArgs) => Promise<TupleOf_AssetInfoAnd_Decimal256[]>;
static instantiate(client: SigningCosmWasmClient, sender: string, codeId: number, initMsg: InstantiateMsg, label: string, fees: StdFee | 'auto' | number, initCoins?: readonly Coin[]): Promise<InstantiateResult>;
static instantiate2(client: SigningCosmWasmClient, sender: string, codeId: number, salt: number, initMsg: InstantiateMsg, label: string, fees: StdFee | 'auto' | number, initCoins?: readonly Coin[]): Promise<InstantiateResult>;
queryConsult: (args: ConsultArgs) => Promise<ArrayOfTupleOf_AssetInfoAnd_Uint256>;
queryTWAPAtHeight: (args: TWAPAtHeightArgs) => Promise<ArrayOfTupleOf_AssetInfoAnd_Decimal256>;
queryConfig: () => Promise<Config>;
queryLastUpdateTimestamp: () => Promise<Uint64>;
update: (sender: string, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise<ExecuteResult>;
updatePeriod: (sender: string, args: UpdatePeriodArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise<ExecuteResult>;
updateManager: (sender: string, args: UpdateManagerArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise<ExecuteResult>;
Expand Down
18 changes: 18 additions & 0 deletions lib/astroportOracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,30 @@ class Client {
mustBeSigningClient() {
return new Error("This client is not a SigningCosmWasmClient");
}
static async instantiate(client, sender, codeId, initMsg, label, fees, initCoins) {
const res = await client.instantiate(sender, codeId, initMsg, label, fees, {
...(initCoins && initCoins.length && { funds: initCoins }),
});
return res;
}
static async instantiate2(client, sender, codeId, salt, initMsg, label, fees, initCoins) {
const res = await client.instantiate2(sender, codeId, new Uint8Array([salt]), initMsg, label, fees, {
...(initCoins && initCoins.length && { funds: initCoins }),
});
return res;
}
queryConsult = async (args) => {
return this.client.queryContractSmart(this.contractAddress, { consult: args });
};
queryTWAPAtHeight = async (args) => {
return this.client.queryContractSmart(this.contractAddress, { t_w_a_p_at_height: args });
};
queryConfig = async () => {
return this.client.queryContractSmart(this.contractAddress, { config: {} });
};
queryLastUpdateTimestamp = async () => {
return this.client.queryContractSmart(this.contractAddress, { last_update_timestamp: {} });
};
update = async (sender, fee, memo, funds) => {
if (!isSigningCosmWasmClient(this.client)) {
throw this.mustBeSigningClient();
Expand Down
31 changes: 19 additions & 12 deletions lib/credits.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult, InstantiateResult } from "@cosmjs/cosmwasm-stargate";
import { StdFee } from "@cosmjs/amino";
import { Coin } from "@cosmjs/amino";
/**
Expand All @@ -23,9 +23,7 @@ export type Expiration = {
} | {
at_time: Timestamp;
} | {
never: {
[k: string]: unknown;
};
never: {};
};
/**
* A point in time in nanosecond precision.
Expand Down Expand Up @@ -64,8 +62,9 @@ export type Addr = string;
export type Nullable_MinterResponse = MinterResponse | null;
export interface CreditsSchema {
responses: AllAccountsResponse | AllAllowancesResponse | Allocation | AllowanceResponse | BalanceResponse | BalanceResponse1 | Config | Nullable_MinterResponse | TokenInfoResponse | TotalSupplyResponse | VestedAmountResponse | WithdrawableAmountResponse;
query: WithdrawableAmountArgs | VestedAmountArgs | AllocationArgs | BalanceArgs | BalanceAtHeightArgs | AllowanceArgs | AllAllowancesArgs;
query: WithdrawableAmountArgs | VestedAmountArgs | AllocationArgs | BalanceArgs | TotalSupplyAtHeightArgs | BalanceAtHeightArgs | AllowanceArgs | AllAllowancesArgs | AllAccountsArgs;
execute: UpdateConfigArgs | AddVestingArgs | TransferArgs | BurnArgs | BurnFromArgs;
instantiate?: InstantiateMsg;
[k: string]: unknown;
}
export interface AllAccountsResponse {
Expand All @@ -80,7 +79,6 @@ export interface AllowanceInfo {
allowance: Uint128;
expires: Expiration;
spender: string;
[k: string]: unknown;
}
export interface Allocation {
/**
Expand Down Expand Up @@ -119,11 +117,9 @@ export interface AllowanceResponse {
}
export interface BalanceResponse {
balance: Uint128;
[k: string]: unknown;
}
export interface BalanceResponse1 {
balance: Uint128;
[k: string]: unknown;
}
export interface Config {
/**
Expand All @@ -150,14 +146,12 @@ export interface MinterResponse {
*/
cap?: Uint128 | null;
minter: string;
[k: string]: unknown;
}
export interface TokenInfoResponse {
decimals: number;
name: string;
symbol: string;
total_supply: Uint128;
[k: string]: unknown;
}
export interface TotalSupplyResponse {
total_supply: Uint128;
Expand Down Expand Up @@ -189,6 +183,9 @@ export interface AllocationArgs {
export interface BalanceArgs {
address: string;
}
export interface TotalSupplyAtHeightArgs {
height?: number | null;
}
export interface BalanceAtHeightArgs {
address: string;
height?: number | null;
Expand All @@ -202,6 +199,10 @@ export interface AllAllowancesArgs {
owner: string;
start_after?: string | null;
}
export interface AllAccountsArgs {
limit?: number | null;
start_after?: string | null;
}
export interface UpdateConfigArgs {
config: UpdateConfigMsg;
[k: string]: unknown;
Expand Down Expand Up @@ -242,22 +243,28 @@ export interface BurnFromArgs {
owner: string;
[k: string]: unknown;
}
export interface InstantiateMsg {
dao_address: string;
[k: string]: unknown;
}
export declare class Client {
private readonly client;
contractAddress: string;
constructor(client: CosmWasmClient | SigningCosmWasmClient, contractAddress: string);
mustBeSigningClient(): Error;
static instantiate(client: SigningCosmWasmClient, sender: string, codeId: number, initMsg: InstantiateMsg, label: string, fees: StdFee | 'auto' | number, initCoins?: readonly Coin[]): Promise<InstantiateResult>;
static instantiate2(client: SigningCosmWasmClient, sender: string, codeId: number, salt: number, initMsg: InstantiateMsg, label: string, fees: StdFee | 'auto' | number, initCoins?: readonly Coin[]): Promise<InstantiateResult>;
queryWithdrawableAmount: (args: WithdrawableAmountArgs) => Promise<WithdrawableAmountResponse>;
queryVestedAmount: (args: VestedAmountArgs) => Promise<VestedAmountResponse>;
queryAllocation: (args: AllocationArgs) => Promise<Allocation>;
queryBalance: (args: BalanceArgs) => Promise<BalanceResponse>;
queryTotalSupplyAtHeight: () => Promise<TotalSupplyResponse>;
queryTotalSupplyAtHeight: (args: TotalSupplyAtHeightArgs) => Promise<TotalSupplyResponse>;
queryBalanceAtHeight: (args: BalanceAtHeightArgs) => Promise<BalanceResponse>;
queryTokenInfo: () => Promise<TokenInfoResponse>;
queryMinter: () => Promise<Nullable_MinterResponse>;
queryAllowance: (args: AllowanceArgs) => Promise<AllowanceResponse>;
queryAllAllowances: (args: AllAllowancesArgs) => Promise<AllAllowancesResponse>;
queryAllAccounts: () => Promise<AllAccountsResponse>;
queryAllAccounts: (args: AllAccountsArgs) => Promise<AllAccountsResponse>;
queryConfig: () => Promise<Config>;
updateConfig: (sender: string, args: UpdateConfigArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise<ExecuteResult>;
addVesting: (sender: string, args: AddVestingArgs, fee?: number | StdFee | "auto", memo?: string, funds?: Coin[]) => Promise<ExecuteResult>;
Expand Down
20 changes: 16 additions & 4 deletions lib/credits.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ class Client {
mustBeSigningClient() {
return new Error("This client is not a SigningCosmWasmClient");
}
static async instantiate(client, sender, codeId, initMsg, label, fees, initCoins) {
const res = await client.instantiate(sender, codeId, initMsg, label, fees, {
...(initCoins && initCoins.length && { funds: initCoins }),
});
return res;
}
static async instantiate2(client, sender, codeId, salt, initMsg, label, fees, initCoins) {
const res = await client.instantiate2(sender, codeId, new Uint8Array([salt]), initMsg, label, fees, {
...(initCoins && initCoins.length && { funds: initCoins }),
});
return res;
}
queryWithdrawableAmount = async (args) => {
return this.client.queryContractSmart(this.contractAddress, { withdrawable_amount: args });
};
Expand All @@ -26,8 +38,8 @@ class Client {
queryBalance = async (args) => {
return this.client.queryContractSmart(this.contractAddress, { balance: args });
};
queryTotalSupplyAtHeight = async () => {
return this.client.queryContractSmart(this.contractAddress, { total_supply_at_height: {} });
queryTotalSupplyAtHeight = async (args) => {
return this.client.queryContractSmart(this.contractAddress, { total_supply_at_height: args });
};
queryBalanceAtHeight = async (args) => {
return this.client.queryContractSmart(this.contractAddress, { balance_at_height: args });
Expand All @@ -44,8 +56,8 @@ class Client {
queryAllAllowances = async (args) => {
return this.client.queryContractSmart(this.contractAddress, { all_allowances: args });
};
queryAllAccounts = async () => {
return this.client.queryContractSmart(this.contractAddress, { all_accounts: {} });
queryAllAccounts = async (args) => {
return this.client.queryContractSmart(this.contractAddress, { all_accounts: args });
};
queryConfig = async () => {
return this.client.queryContractSmart(this.contractAddress, { config: {} });
Expand Down
Loading

0 comments on commit 9ac8f50

Please sign in to comment.