Skip to content

Commit

Permalink
♻️ redirect tokens management to token manager contract
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin Burg committed Oct 17, 2023
1 parent d12cc13 commit 4b29f2d
Show file tree
Hide file tree
Showing 10 changed files with 382 additions and 258 deletions.
9 changes: 6 additions & 3 deletions batcher-ui/src/components/SelectPair.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { useSelector } from 'react-redux';
import { currentSwapSelector } from 'src/reducers';
import { useDispatch } from 'react-redux';
import { changePair } from 'src/actions';
import { getTokensMetadata } from 'src/utils/utils';
import Image from 'next/image';
import { getTokensMetadata } from 'src/utils/token-manager';

interface SelectPairProps {
isFrom: boolean;
Expand All @@ -33,8 +33,11 @@ const SelectPair = ({ isFrom }: SelectPairProps) => {

useEffect(() => {
getTokensMetadata().then(
(tokens: { name: string; address: string; icon: string | undefined }[]) =>
setAvailableTokens(tokens)
(
tokens: { name: string; address: string; icon: string | undefined }[]
) => {
setAvailableTokens(tokens);
}
);
}, []);

Expand Down
Empty file removed batcher-ui/src/types/config.ts
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Token } from './state';
import { Token } from '../state';

export enum BatcherStatus {
OPEN = 'OPEN',
Expand Down Expand Up @@ -119,10 +119,6 @@ export type Vault = {

export type address = string;

export type UserHoldingKey = [address, string];

export type UserHoldings = Map<UserHoldingKey, number>;

export type MarketVaultHolding = {
id: number;
token: string;
Expand All @@ -132,19 +128,6 @@ export type MarketVaultHolding = {
};
export type VaultHoldings = Map<number, MarketVaultHolding>;

export type MarketMakerStorage = {
metadata: unknown;
valid_tokens: Map<TokenNames, Token>;
valid_swaps: Map<
SwapNames,
{ swap: Swap; is_disabled_for_deposits: boolean }
>;
vaults: Map<TokenNames, Vault>;
last_holding_id: number;
user_holdings: UserHoldings;
vault_holdings: VaultHoldings;
};

export type BatcherStorage = {
metadata: number; //! ID of metadata bigmap
valid_tokens: Record<TokenNames, ContractToken>;
Expand Down Expand Up @@ -189,73 +172,3 @@ export type BatchBigmap = {
export type OrderBookBigmap = {
[key: string]: Array<UserOrder>;
};

// MARKET MAKER HOLDINGS

export type BatcherMarketMakerStorage = {
metadata: number; //! ID of metadata bigmap
// valid_tokens: Record<TokenNames, ContractToken>;
valid_tokens: Record<string, ContractToken>;
valid_swaps: Record<
SwapNames,
{
swap: Swap;
is_disabled_for_deposits: boolean;
oracle_address: string;
oracle_precision: string;
oracle_asset_name: string;
}
>;
// rates_current: number; //! ID of rates_current bigmap
// fee_in_mutez: number;
// batch_set: {
// batches: number; //! ID of batches bigmap
// current_batch_indices: Record<SwapNames, string>; //! Ex: tzBTC/USDT: "300"
// };
administrator: string; //! Address to admin
// fee_recipient: string; //! Address
// last_order_number: string; //! number in string
// user_batch_ordertypes: number; //! ID of order book bigmap
limit_on_tokens_or_pairs: string; //! 10 per default
// deposit_time_window_in_seconds: string; //! 600 at this time
// scale_factor_for_oracle_staleness: string; //! "1"

vault_holdings: number; //! ID of vault_holdings bigmap
vaults: number; //! ID of vaults bigmap
user_holdings: number; //! ID of user_holdings bigmap
batcher: string; //! burn address
};

export type UserHoldingsBigMapItem = {
key: {
string: TokenNames;
address: string;
};
value: string; // number
};

export type VaultHoldingsBigMapItem = {
key: string;
active: boolean;
value: {
id: string;
token: TokenNames;
holder: string;
shares: string; // number
unclaimed: string; // number
}; // number
};

export type VaultsBigMapItem = {
key: TokenNames;
value: {
foreign_tokens: Record<TokenNames, { token: Token; amount: string }>;
total_shares: string; // number
native_token: {
token: Token;
amount: string;
};
holdings: Array<string>; // Array<number>
}; // number
};

99 changes: 99 additions & 0 deletions batcher-ui/src/types/contracts/market-maker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
export type MarketMakerStorage = {
vaults: {
keys: Array<string>;
/**
* Bigmap ID
*/
values: string; // Bigmap addr
};
administrator: string;
batcher: string;
tokenmanager: string;
};

// OLD types

// export type UserHoldingKey = [address, string];

// export type UserHoldings = Map<UserHoldingKey, number>;
// export type MarketMakerStorage = {
// metadata: unknown;
// valid_tokens: Map<TokenNames, Token>;
// valid_swaps: Map<
// SwapNames,
// { swap: Swap; is_disabled_for_deposits: boolean }
// >;
// vaults: Map<TokenNames, Vault>;
// last_holding_id: number;
// user_holdings: UserHoldings;
// vault_holdings: VaultHoldings;
// };

// MARKET MAKER HOLDINGS

// export type BatcherMarketMakerStorage = {
// metadata: number; //! ID of metadata bigmap
// // valid_tokens: Record<TokenNames, ContractToken>;
// valid_tokens: Record<string, ContractToken>;
// valid_swaps: Record<
// SwapNames,
// {
// swap: Swap;
// is_disabled_for_deposits: boolean;
// oracle_address: string;
// oracle_precision: string;
// oracle_asset_name: string;
// }
// >;
// // rates_current: number; //! ID of rates_current bigmap
// // fee_in_mutez: number;
// // batch_set: {
// // batches: number; //! ID of batches bigmap
// // current_batch_indices: Record<SwapNames, string>; //! Ex: tzBTC/USDT: "300"
// // };
// administrator: string; //! Address to admin
// // fee_recipient: string; //! Address
// // last_order_number: string; //! number in string
// // user_batch_ordertypes: number; //! ID of order book bigmap
// limit_on_tokens_or_pairs: string; //! 10 per default
// // deposit_time_window_in_seconds: string; //! 600 at this time
// // scale_factor_for_oracle_staleness: string; //! "1"

// vault_holdings: number; //! ID of vault_holdings bigmap
// vaults: number; //! ID of vaults bigmap
// user_holdings: number; //! ID of user_holdings bigmap
// batcher: string; //! burn address
// };

// export type UserHoldingsBigMapItem = {
// key: {
// string: TokenNames;
// address: string;
// };
// value: string; // number
// };

// export type VaultHoldingsBigMapItem = {
// key: string;
// active: boolean;
// value: {
// id: string;
// token: TokenNames;
// holder: string;
// shares: string; // number
// unclaimed: string; // number
// }; // number
// };

// export type VaultsBigMapItem = {
// key: TokenNames;
// value: {
// foreign_tokens: Record<TokenNames, { token: Token; amount: string }>;
// total_shares: string; // number
// native_token: {
// token: Token;
// amount: string;
// };
// holdings: Array<string>; // Array<number>
// }; // number
// };
40 changes: 40 additions & 0 deletions batcher-ui/src/types/contracts/token-manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export type TokenManagerStorage = {
valid_swaps: {
/**
* Ex : "tzBTC/USDT"
*/
keys: Array<string>;
/**
* Bigmap ID
*/
values: number;
};
valid_tokens: {
/**
* Ex : "tzBTC"
*/
keys: Array<string>;
/**
* Bigmap ID
*/
values: number;
};
administrator: string;
/**
* Number. Currently 10
*/
limit_on_tokens_or_pairs: string;
};

export type ValidToken = {
name: string;
address: string;
token_id: string;
decimals: string;
standard: string;
};

export type ValidTokensBigmapItem = {
key: string;
value: ValidToken;
};
37 changes: 37 additions & 0 deletions batcher-ui/src/types/contracts/token-vault.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export type TokenVaultStorage = {
batcher: string;
marketmaker: string;
native_token: {
token: {
name: string;
address: string;
/**
* Number
*/
decimals: string;
standard: string;
/**
* Number, in most case 0
*/
token_id: string;
};
/**
* Number
*/
amount: string;
};
tokenmanager: string;
/**
* Number
*/
total_shares: string;
administrator: string;
/**
* TODO types
*/
foreign_tokens: '';
/**
* Bigmap ID
*/
vault_holdings: number;
};
7 changes: 5 additions & 2 deletions batcher-ui/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export * from './contract';
export * from './contracts/batcher';
export * from './contracts/token-manager';
export * from './contracts/token-vault';
export * from './contracts/market-maker';
export * from './state';
export * from './events';
export * from './events';
Loading

0 comments on commit 4b29f2d

Please sign in to comment.