Compare commits
No commits in common. "a04f7ee66c3557a94d97aa902edf1732563fc4ff" and "4783e2dcb3194d70b90683de07e032dcadb4d984" have entirely different histories.
a04f7ee66c
...
4783e2dcb3
137
dev/api.go
137
dev/api.go
@ -6,7 +6,9 @@ import (
|
|||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -738,88 +740,71 @@ func (das *DevAccountService) RequestAlias(ctx context.Context, publicKey string
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (das *DevAccountService) FetchTopPools(ctx context.Context, publicKey string) ([]dataserviceapi.PoolDetails, error) {
|
func (das *DevAccountService) FetchTopPools(ctx context.Context) ([]models.Pool, error) {
|
||||||
topPools := []dataserviceapi.PoolDetails{
|
var (
|
||||||
{
|
r struct {
|
||||||
PoolName: "Kenya ROLA Pool",
|
OK bool `json:"ok"`
|
||||||
PoolSymbol: "ROLA",
|
Description string `json:"description"`
|
||||||
PoolContractAdrress: "0x48a953cA5cf5298bc6f6Af3C608351f537AAcb9e",
|
Result struct {
|
||||||
LimiterAddress: "",
|
Pools []models.Pool `json:"topPools"`
|
||||||
VoucherRegistry: "",
|
} `json:"result"`
|
||||||
},
|
}
|
||||||
{
|
)
|
||||||
PoolName: "Nairobi ROLA Pool",
|
data, err := os.ReadFile("./data/top_pools.json")
|
||||||
PoolSymbol: "NAIROBI",
|
if err != nil {
|
||||||
PoolContractAdrress: "0xB0660Ac1Ee3d32ea35bc728D7CA1705Fa5A37528",
|
log.Fatal(err)
|
||||||
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: "",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return topPools, nil
|
err = json.Unmarshal(data, &r)
|
||||||
}
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
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: "",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return swapFromList, nil
|
return r.Result.Pools, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (das *DevAccountService) GetPoolSwappableVouchers(ctx context.Context, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
func (das *DevAccountService) GetPoolSwappableFromVouchers(ctx context.Context) ([]models.SwappableVoucher, error) {
|
||||||
swapToList := []dataserviceapi.TokenHoldings{
|
var (
|
||||||
{
|
r struct {
|
||||||
ContractAddress: "0x765DE816845861e75A25fCA122bb6898B8B1282a",
|
OK bool `json:"ok"`
|
||||||
TokenSymbol: "cUSD",
|
Description string `json:"description"`
|
||||||
TokenDecimals: "18",
|
Result struct {
|
||||||
Balance: "",
|
SwappableVouchers []models.SwappableVoucher `json:"filtered"`
|
||||||
},
|
} `json:"result"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
data, err := os.ReadFile("./data/swap_from.json")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return swapToList, nil
|
err = json.Unmarshal(data, &r)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r.Result.SwappableVouchers, 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
|
||||||
}
|
}
|
||||||
|
|||||||
10
models/pool.go
Normal file
10
models/pool.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
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,3 +8,10 @@ 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, publicKey string) ([]dataserviceapi.PoolDetails, error) {
|
func (as *HTTPAccountService) FetchTopPools(ctx context.Context) ([]models.Pool, error) {
|
||||||
svc := dev.NewDevAccountService(ctx, as.SS)
|
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||||
return svc.FetchTopPools(ctx, publicKey)
|
return svc.FetchTopPools(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
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, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
func (as *HTTPAccountService) GetPoolSwappableFromVouchers(ctx context.Context) ([]models.SwappableVoucher, error) {
|
||||||
return as.GetPoolSwappableFromVouchers(ctx, publicKey)
|
return as.GetPoolSwappableFromVouchers(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context) ([]models.SwappableVoucher, error) {
|
||||||
return as.GetPoolSwappableVouchers(ctx, publicKey)
|
return as.GetPoolSwappableVouchers(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
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