-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overhauled account type system to be more general.
- Loading branch information
Showing
35 changed files
with
585 additions
and
628 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { selectorFamily } from 'recoil' | ||
|
||
import { | ||
AccountType, | ||
ChainId, | ||
ValenceAccount, | ||
ValenceAccountConfig, | ||
WithChainId, | ||
} from '@dao-dao/types' | ||
|
||
import { queryWalletIndexerSelector } from './indexer' | ||
|
||
// Retrieve the valence accounts for a given address. | ||
export const valenceAccountsSelector = selectorFamily< | ||
ValenceAccount[], | ||
WithChainId<{ address: string }> | ||
>({ | ||
key: 'valenceAccounts', | ||
get: | ||
({ address, chainId }) => | ||
async ({ get }) => { | ||
// Get valence accounts from indexer. | ||
const valenceAccountAddresses = get( | ||
queryWalletIndexerSelector({ | ||
chainId, | ||
walletAddress: address, | ||
formula: 'valence/accounts', | ||
required: true, | ||
}) | ||
) | ||
if (!valenceAccountAddresses || !Array.isArray(valenceAccountAddresses)) { | ||
return [] | ||
} | ||
|
||
const accounts = valenceAccountAddresses.map( | ||
(address): ValenceAccount => { | ||
// TODO(rebalancer): Get config | ||
const config: ValenceAccountConfig = { | ||
rebalancer: { | ||
targets: [ | ||
{ | ||
source: { | ||
chainId: ChainId.NeutronMainnet, | ||
denomOrAddress: 'untrn', | ||
}, | ||
targets: [ | ||
{ | ||
timestamp: 0, | ||
target: 0.75, | ||
}, | ||
], | ||
}, | ||
{ | ||
source: { | ||
chainId: 'axelar-dojo-1', | ||
denomOrAddress: 'uusdc', | ||
}, | ||
targets: [ | ||
{ | ||
timestamp: 0, | ||
target: 0.25, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
return { | ||
type: AccountType.Valence, | ||
chainId, | ||
address, | ||
config, | ||
} | ||
} | ||
) | ||
|
||
return accounts | ||
}, | ||
}) |
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
Oops, something went wrong.