Compare commits
3 Commits
4783e2dcb3
...
a04f7ee66c
| Author | SHA1 | Date | |
|---|---|---|---|
| a04f7ee66c | |||
| 52e1be1104 | |||
| d7ae1cc096 |
133
dev/api.go
133
dev/api.go
@ -6,9 +6,7 @@ import (
|
|||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -740,71 +738,88 @@ func (das *DevAccountService) RequestAlias(ctx context.Context, publicKey string
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (das *DevAccountService) FetchTopPools(ctx context.Context) ([]models.Pool, error) {
|
func (das *DevAccountService) FetchTopPools(ctx context.Context, publicKey string) ([]dataserviceapi.PoolDetails, error) {
|
||||||
var (
|
topPools := []dataserviceapi.PoolDetails{
|
||||||
r struct {
|
{
|
||||||
OK bool `json:"ok"`
|
PoolName: "Kenya ROLA Pool",
|
||||||
Description string `json:"description"`
|
PoolSymbol: "ROLA",
|
||||||
Result struct {
|
PoolContractAdrress: "0x48a953cA5cf5298bc6f6Af3C608351f537AAcb9e",
|
||||||
Pools []models.Pool `json:"topPools"`
|
LimiterAddress: "",
|
||||||
} `json:"result"`
|
VoucherRegistry: "",
|
||||||
}
|
},
|
||||||
)
|
{
|
||||||
data, err := os.ReadFile("./data/top_pools.json")
|
PoolName: "Nairobi ROLA Pool",
|
||||||
if err != nil {
|
PoolSymbol: "NAIROBI",
|
||||||
log.Fatal(err)
|
PoolContractAdrress: "0xB0660Ac1Ee3d32ea35bc728D7CA1705Fa5A37528",
|
||||||
|
LimiterAddress: "",
|
||||||
|
VoucherRegistry: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PoolName: "Friends of Kiriba Ecosystem",
|
||||||
|
PoolSymbol: "FRIENDS",
|
||||||
|
PoolContractAdrress: "0xC4848263821FA02baB2181910A2eFb9CECb2c21C",
|
||||||
|
LimiterAddress: "",
|
||||||
|
VoucherRegistry: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PoolName: "Resilient Community Waqfs",
|
||||||
|
PoolSymbol: "REZILIENS",
|
||||||
|
PoolContractAdrress: "0x1e40951d7a28147D8B4A554C60c42766C92e2Fc6",
|
||||||
|
LimiterAddress: "",
|
||||||
|
VoucherRegistry: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PoolName: "GrE Tech",
|
||||||
|
PoolSymbol: "GRET",
|
||||||
|
PoolContractAdrress: "0xb7B9d0A264eD1a8E2418571B7AC5933C79C9c2B8",
|
||||||
|
LimiterAddress: "",
|
||||||
|
VoucherRegistry: "",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(data, &r)
|
return topPools, nil
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.Result.Pools, nil
|
func (das *DevAccountService) GetPoolSwappableFromVouchers(ctx context.Context, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
|
swapFromList := []dataserviceapi.TokenHoldings{
|
||||||
|
{
|
||||||
|
ContractAddress: "0xc7B78Ac9ACB9E025C8234621FC515bC58179dEAe",
|
||||||
|
TokenSymbol: "AMANI",
|
||||||
|
TokenDecimals: "6",
|
||||||
|
Balance: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddress: "0xF0C3C7581b8b96B59a97daEc8Bd48247cE078674",
|
||||||
|
TokenSymbol: "AMUA",
|
||||||
|
TokenDecimals: "6",
|
||||||
|
Balance: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddress: "0x371455a30fc62736145Bd8429Fcc6481186f235F",
|
||||||
|
TokenSymbol: "BAHARI",
|
||||||
|
TokenDecimals: "6",
|
||||||
|
Balance: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddress: "0x7cA6113b59c24a880F382C7E12d609a6Eb05246b",
|
||||||
|
TokenSymbol: "BANGLA",
|
||||||
|
TokenDecimals: "6",
|
||||||
|
Balance: "",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func (das *DevAccountService) GetPoolSwappableFromVouchers(ctx context.Context) ([]models.SwappableVoucher, error) {
|
return swapFromList, nil
|
||||||
var (
|
|
||||||
r struct {
|
|
||||||
OK bool `json:"ok"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
Result struct {
|
|
||||||
SwappableVouchers []models.SwappableVoucher `json:"filtered"`
|
|
||||||
} `json:"result"`
|
|
||||||
}
|
|
||||||
)
|
|
||||||
data, err := os.ReadFile("./data/swap_from.json")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(data, &r)
|
func (das *DevAccountService) GetPoolSwappableVouchers(ctx context.Context, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
if err != nil {
|
swapToList := []dataserviceapi.TokenHoldings{
|
||||||
log.Fatal(err)
|
{
|
||||||
|
ContractAddress: "0x765DE816845861e75A25fCA122bb6898B8B1282a",
|
||||||
|
TokenSymbol: "cUSD",
|
||||||
|
TokenDecimals: "18",
|
||||||
|
Balance: "",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.Result.SwappableVouchers, nil
|
return swapToList, nil
|
||||||
}
|
|
||||||
|
|
||||||
func (das *DevAccountService) GetPoolSwappableVouchers(ctx context.Context) ([]models.SwappableVoucher, error) {
|
|
||||||
var (
|
|
||||||
r struct {
|
|
||||||
OK bool `json:"ok"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
Result struct {
|
|
||||||
SwappableVouchers []models.SwappableVoucher `json:"filtered"`
|
|
||||||
} `json:"result"`
|
|
||||||
}
|
|
||||||
)
|
|
||||||
data, err := os.ReadFile("./data/swap_to.json")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = json.Unmarshal(data, &r)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r.Result.SwappableVouchers, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +0,0 @@
|
|||||||
package models
|
|
||||||
|
|
||||||
|
|
||||||
type Pool struct {
|
|
||||||
PoolName string `json:"poolName"`
|
|
||||||
PoolSymbol string `json:"poolSymbol"`
|
|
||||||
PoolContractAddress string `json:"poolContractAddress"`
|
|
||||||
LimiterAddress string `json:"limiterAddress"`
|
|
||||||
VoucherRegistry string `json:"voucherRegistry"`
|
|
||||||
}
|
|
||||||
@ -8,10 +8,3 @@ type VoucherDataResult struct {
|
|||||||
TokenCommodity string `json:"tokenCommodity"`
|
TokenCommodity string `json:"tokenCommodity"`
|
||||||
TokenLocation string `json:"tokenLocation"`
|
TokenLocation string `json:"tokenLocation"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SwappableVoucher struct {
|
|
||||||
ContractAddress string `json:"contractAddress"`
|
|
||||||
TokenSymbol string `json:"tokenSymbol"`
|
|
||||||
TokenDecimals string `json:"tokenDecimals"`
|
|
||||||
Balance string `json:"balance"`
|
|
||||||
}
|
|
||||||
|
|||||||
@ -239,9 +239,9 @@ func resolveAliasAddress(ctx context.Context, alias string) (*models.AliasAddres
|
|||||||
return &r, err
|
return &r, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) FetchTopPools(ctx context.Context) ([]models.Pool, error) {
|
func (as *HTTPAccountService) FetchTopPools(ctx context.Context, publicKey string) ([]dataserviceapi.PoolDetails, error) {
|
||||||
svc := dev.NewDevAccountService(ctx, as.SS)
|
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||||
return svc.FetchTopPools(ctx)
|
return svc.FetchTopPools(ctx, publicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) PoolDeposit(ctx context.Context, amount, from, poolAddress, tokenAddress string) (*models.PoolDepositResult, error) {
|
func (as *HTTPAccountService) PoolDeposit(ctx context.Context, amount, from, poolAddress, tokenAddress string) (*models.PoolDepositResult, error) {
|
||||||
@ -297,12 +297,12 @@ func (as *HTTPAccountService) GetPoolSwapQuote(ctx context.Context, amount, from
|
|||||||
return &r, nil
|
return &r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) GetPoolSwappableFromVouchers(ctx context.Context) ([]models.SwappableVoucher, error) {
|
func (as *HTTPAccountService) GetPoolSwappableFromVouchers(ctx context.Context, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
return as.GetPoolSwappableFromVouchers(ctx)
|
return as.GetPoolSwappableFromVouchers(ctx, publicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context) ([]models.SwappableVoucher, error) {
|
func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
return as.GetPoolSwappableVouchers(ctx)
|
return as.GetPoolSwappableVouchers(ctx, publicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) PoolSwap(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapResult, error) {
|
func (as *HTTPAccountService) PoolSwap(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapResult, error) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user